Questify: Fix Button Logic.... (#1065)
* Fix Button Logic. * Fix Quest Button Logic.
This commit is contained in:
parent
02d94f797f
commit
863f5e89bd
3 changed files with 29 additions and 15 deletions
|
|
@ -7,6 +7,7 @@
|
|||
import { QuestRewardType, QuestTaskType } from "@vencord/discord-types/enums";
|
||||
import type { JSX } from "react";
|
||||
|
||||
import { enabledOnStartup } from "..";
|
||||
import { getQuestifySettings, useQuestifySettings } from "../settings/access";
|
||||
import { type QuestButtonAction, type QuestButtonDisplayMode, type QuestButtonIncludedTypes, type QuestButtonIndicatorMode } from "../settings/def";
|
||||
import { startAutoFetchingQuests } from "../settings/fetching";
|
||||
|
|
@ -142,7 +143,7 @@ export function QuestButtonSetting(): JSX.Element {
|
|||
<SettingsHeader> Quest Button </SettingsHeader>
|
||||
<SettingsDescription> Show a Quest Button in the server list with an optional indicator for unclaimed and unignored Quests. </SettingsDescription>
|
||||
</SettingsRowItem>
|
||||
<SettingsRowItem width="content">
|
||||
{enabledOnStartup && <SettingsRowItem width="content">
|
||||
<DummyQuestButton
|
||||
badgeColor={questButton.questButtonBadgeColor}
|
||||
leftClickAction={questButton.questButtonLeftClickAction}
|
||||
|
|
@ -152,7 +153,7 @@ export function QuestButtonSetting(): JSX.Element {
|
|||
showPill={canShowPill(questButton.questButtonIndicator)}
|
||||
visible={canShowButton(questButton.questButtonDisplay)}
|
||||
/>
|
||||
</SettingsRowItem>
|
||||
</SettingsRowItem>}
|
||||
</SettingsRow>
|
||||
<SettingsSubheader className="no-top-margin"> Button Behavior </SettingsSubheader>
|
||||
<SettingsRow>
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import "./styles.css";
|
|||
|
||||
import { playAudio } from "@api/AudioPlayer";
|
||||
import { addServerListElement, removeServerListElement, ServerListRenderPosition } from "@api/ServerList";
|
||||
import { Settings } from "@api/Settings";
|
||||
import { PlainSettings, Settings } from "@api/Settings";
|
||||
import { ErrorBoundary } from "@components/index";
|
||||
import { EquicordDevs } from "@utils/constants";
|
||||
import definePlugin, { StartAt } from "@utils/types";
|
||||
|
|
@ -23,7 +23,7 @@ import { getQuestifySettings } from "./settings/access";
|
|||
import { resetQuestsToResume, startAutoFetchingQuests, stopAutoFetchingQuests } from "./settings/fetching";
|
||||
import { validateIgnoredQuests } from "./settings/ignoredQuests";
|
||||
import { rerenderQuests, useQuestRerender } from "./settings/rerender";
|
||||
import { disposeRestartTracking, initializeRestartTracking, promptToRestartIfDirty } from "./settings/restartTracking";
|
||||
import { disposeRestartTracking, initializeRestartTracking, promptToRestartIfDirty, setRestartDirty } from "./settings/restartTracking";
|
||||
import { settings } from "./settings/store";
|
||||
import { getSettingsModalOpen, initialQuestDataFetched, setInitialQuestDataFetched, setSettingsModalOpen } from "./state";
|
||||
import { canAutoCompleteQuest, getActiveAutoCompletes, getQuestAutoCompleteProgress, getQuestButtonProps, getQuestPanelSubtitleText, hasEnabledAutoCompleteQuestTypes, processQuestForAutoComplete, resumeInterruptedAutoCompletes, setHeartbeatStackTracePatchSucceeded, setVideoProgressStackTracePatchSucceeded, stopAllAutoCompletes, stopAutoCompletesForRunningGames, stopQuestAutoComplete } from "./utils/completion";
|
||||
|
|
@ -37,6 +37,7 @@ import { formatLowerBadge, QUEST_PAGE } from "./utils/ui";
|
|||
let isSwitchingAccount = false;
|
||||
let didAttemptAutoCompleteResume = false;
|
||||
const notifiedCompletedQuests = new Set<string>();
|
||||
export const enabledOnStartup = PlainSettings.plugins.Questify?.enabled;
|
||||
|
||||
function setOnQuestsPage(force?: boolean): void {
|
||||
getQuestifySettings().isOnQuestsPage = force ?? (window.location.pathname === QUEST_PAGE);
|
||||
|
|
@ -381,27 +382,28 @@ export default definePlugin({
|
|||
replace: "!$self.canAutoCompleteQuest(arguments[0].quest)&&"
|
||||
},
|
||||
// If this group becomes unruly due to Discord refactoring and is unfixable,
|
||||
// the 2nd, 3rd, and 4th can be commented out in favor of just the 1st at the
|
||||
// expense of not seeing CTA buttons on completed but unclaimed Quests.
|
||||
// the 2nd, 3rd, and 4th can be commented out in favor of just the 1st at the expense
|
||||
// of not seeing CTA buttons on completed but unclaimed Quests. Also, questifyCanAutoComplete
|
||||
// would need to be replaced as the 2nd patch defines it.
|
||||
{
|
||||
// Always expose the CTA button when available instead of only for videos and activities.
|
||||
match: /(?<=wrap:!1,children:\[)\i&&[^?]+/,
|
||||
replace: "!!arguments[0].quest.config.ctaConfig"
|
||||
match: /(?<=wrap:!1,children:\[)(\i&&[^?]+)/,
|
||||
replace: "((!!arguments[0].quest.config.ctaConfig&&questifyCanAutoComplete)||($1))"
|
||||
},
|
||||
{
|
||||
// Let completed/claimed expired Quests with CTAs use the CTA-aware completed branch.
|
||||
match: /(?<=return\()(?=\i.enabled&&\i===\i\.\i\.EXPIRED_CLAIMABLE&&\i\.\i\.has\(\i\))/,
|
||||
replace: "!arguments[0].quest.config.ctaConfig&&"
|
||||
match: /(return\()(?=\i.enabled&&\i===\i\.\i\.EXPIRED_CLAIMABLE&&\i\.\i\.has\(\i\))/,
|
||||
replace: "const questifyCanAutoComplete=$self.canAutoCompleteQuest(arguments[0].quest);$1(questifyCanAutoComplete?!arguments[0].quest.config.ctaConfig:true)&&"
|
||||
},
|
||||
{
|
||||
// Let completed/claimed expired Quests with CTAs use the CTA-aware completed branch.
|
||||
match: /(?<=\):\i\?\i=)(\i)(?=\?\(0,\i\.jsx\)\(\i,\{quest:\i,sourceQuestContent:\i,onClick:\i,text:\i\}\):\(0,\i\.\i\)\(\i\)\?)/,
|
||||
replace: "arguments[0].quest.config.ctaConfig||$1"
|
||||
match: /(?<=\):\i\?\i=)(\i)(?=\?\(0,\i\.jsx\)\(\i,\{quest:\i,sourceQuestContent:\i,onClick:\i,text:\i\}\):)/,
|
||||
replace: "((arguments[0].quest.config.ctaConfig&&questifyCanAutoComplete)||($1))"
|
||||
},
|
||||
{
|
||||
// Force the CTA-aware complete branch.
|
||||
match: /(?<=analyticsCtxQuestContentRowIndex:\i}\)}\):\i&&\i)(.{0,200}?fullWidth:!0}\)}\):)(\i.enabled)(.{0,50}?CLAIMED\))&&\i.\i.has\(\i\)(\?\i=)\i/,
|
||||
replace: "&&false$1arguments[0].quest.config.ctaConfig&&arguments[0].quest.userStatus?.completedAt&&($2||true)$3$4true"
|
||||
match: /(?<=analyticsCtxQuestContentRowIndex:\i}\)}\):\i&&\i)(.{0,200}?fullWidth:!0}\)}\):)(\i.enabled.{0,50}?CLAIMED\)&&\i.\i.has\(\i\))(\?\i=)(\i)/,
|
||||
replace: "&&!questifyCanAutoComplete$1((questifyCanAutoComplete&&arguments[0].quest.config.ctaConfig&&arguments[0].quest.userStatus?.completedAt)||($2))$3(questifyCanAutoComplete||$4)"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
@ -615,8 +617,15 @@ export default definePlugin({
|
|||
renderQuestifyButton: ErrorBoundary.wrap(QuestButton, { noop: true }),
|
||||
|
||||
start() {
|
||||
if (!enabledOnStartup && PlainSettings.plugins.Questify?.enabled) {
|
||||
setRestartDirty(true);
|
||||
}
|
||||
|
||||
initializeRestartTracking(settings);
|
||||
addServerListElement(ServerListRenderPosition.Above, this.renderQuestifyButton);
|
||||
|
||||
if (enabledOnStartup) {
|
||||
addServerListElement(ServerListRenderPosition.Above, this.renderQuestifyButton);
|
||||
}
|
||||
|
||||
onceReady.then(() => {
|
||||
if (!getQuestifySettings().disableQuestsEverything) {
|
||||
|
|
|
|||
|
|
@ -48,6 +48,10 @@ export function isRestartDirty(): boolean {
|
|||
return restartDirty;
|
||||
}
|
||||
|
||||
export function setRestartDirty(dirty: boolean): void {
|
||||
restartDirty = dirty;
|
||||
}
|
||||
|
||||
export function promptToRestartIfDirty(): boolean {
|
||||
if (!restartDirty) {
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue