216 lines
8.8 KiB
TypeScript
216 lines
8.8 KiB
TypeScript
// Metro module 14118 (f14119).
|
|
import { useMemo, useEffect, useCallback } from "react";
|
|
import ActionSheetStore from "../../action_sheet/native/ActionSheetStore";
|
|
import ApplicationStore from "../../applications/ApplicationStore";
|
|
import QuestStore from "../QuestStore";
|
|
import { QUEST_REWARD_CODE_CLAIM_BOTTOM_SHEET_KEY, QuestVariants } from "../QuestConstants";
|
|
import { CAPTCHA_MODAL_KEY } from "../../captcha/CaptchaConstants";
|
|
import { ThemeTypes } from "../../../_bundle/Module505";
|
|
import { useQuestDockExternalOffset } from "./QuestDock/QuestDockHooks";
|
|
import NewAdRequestBehaviorExperiment from "../experiments/NewAdRequestBehaviorExperiment";
|
|
import { useStateFromStores } from "../../../_bundle/Module589";
|
|
import { QuestContent, AdPlacement } from "../QuestTypes";
|
|
import { isDismissed, getQuestForPlacement } from "../utils/QuestDataUtils";
|
|
import useQuestForPlacement from "../useQuestForPlacement";
|
|
import { useIsChannelFocused } from "../../panels/isChannelFocused.native";
|
|
import { coerceGuildsRoute, useCurrentNavigationRouteName } from "../../main_tabs_v2/helpers/NavigationRouteUtils.native";
|
|
import useIsWindowLarge from "../../screen/native/useIsWindowLarge";
|
|
import { useIsQuestExpired } from "../hooks/QuestHooks";
|
|
import { getIsEligibleForQuests } from "../lib/QuestsEligibility";
|
|
import { getQuestAsset, QuestAssetType, resolveAsset, EXTENSION_RE } from "../lib/AssetUtils";
|
|
import { hasWatchVideoOnMobileTasks, getActivityApplicationId } from "../utils/QuestTaskUtils";
|
|
import * as _canLaunchFrame from "../../frames/utils/canLaunchFrame";
|
|
import { canLaunchActivity } from "../utils/QuestUtils";
|
|
import isActivitySupportedOnClientPlatform from "../../activities/utils/isActivitySupportedOnClientPlatform";
|
|
import ApplicationActionCreators from "../../applications/ApplicationActionCreators";
|
|
import FramesActionCreators_native from "../../frames/FramesActionCreators.native";
|
|
import { launchActivityInBotDM } from "../../app_launcher/utils/AppLauncherPlayUtils";
|
|
let useIsMobileQuestDockRendered;
|
|
const useIsMobileQuestDockRenderedBase = function useIsMobileQuestDockRenderedBase(mobileQuestDock) {
|
|
let r42;
|
|
const isWindowLarge = useIsWindowLarge();
|
|
const stateFromStores3 = useStateFromStores([QuestStore], () => QuestStore.getQuestPreviewOverride(QuestContent.QUEST_BAR_MOBILE) != null, []);
|
|
const r21 = mobileQuestDock?.userStatus != null && isDismissed(mobileQuestDock.userStatus, QuestContent.QUEST_BAR_MOBILE);
|
|
const r30 = mobileQuestDock == null ? void 0 : mobileQuestDock.userStatus?.claimedAt;
|
|
L23: {
|
|
const r33 = r30 != null;
|
|
const isQuestExpired = useIsQuestExpired(mobileQuestDock);
|
|
const isEligibleForQuests = getIsEligibleForQuests();
|
|
if (stateFromStores3 && !r33) {
|
|
r42 = mobileQuestDock != null;
|
|
if (!r42) {
|
|
break L23;
|
|
}
|
|
r42 = !isWindowLarge;
|
|
} else {
|
|
r42 = mobileQuestDock != null && isEligibleForQuests && !isQuestExpired && !r33 && !r21 && !isWindowLarge;
|
|
}
|
|
}
|
|
return r42;
|
|
};
|
|
useIsMobileQuestDockRendered = function useIsMobileQuestDockRendered() {
|
|
let stateFromStores;
|
|
const enableNewRequestBehavior = NewAdRequestBehaviorExperiment.useConfig({
|
|
location: "QuestMobileDock"
|
|
}).enableNewRequestBehavior;
|
|
let r21 = useStateFromStores([QuestStore], () => QuestStore.getQuestPreviewOverride(QuestContent.QUEST_BAR_MOBILE), []);
|
|
let r27 = useStateFromStores([QuestStore], () => {
|
|
let r14 = getQuestForPlacement(QuestStore.quests, QuestStore.questToDeliverForPlacement, AdPlacement.MOBILE_HOME_DOCK_AREA);
|
|
if (r14 == null) {
|
|
r14 = null;
|
|
}
|
|
return r14;
|
|
});
|
|
stateFromStores = useStateFromStores([QuestStore], () => {
|
|
let r11 = QuestStore.questAdDecisionByPlacement.get(AdPlacement.MOBILE_HOME_DOCK_AREA);
|
|
if (r11 == null) {
|
|
r11 = null;
|
|
}
|
|
return r11;
|
|
});
|
|
const stateFromStores3 = useStateFromStores([QuestStore], () => {
|
|
const r7 = stateFromStores?.questId != null;
|
|
let r8 = null;
|
|
if (r7) {
|
|
let r12 = QuestStore.quests.get(stateFromStores.questId);
|
|
if (r12 == null) {
|
|
r12 = null;
|
|
}
|
|
r8 = r12;
|
|
}
|
|
return r8;
|
|
}, [stateFromStores]);
|
|
if (r21 == null) {
|
|
if (enableNewRequestBehavior) {
|
|
r27 = stateFromStores3;
|
|
}
|
|
r21 = r27;
|
|
}
|
|
return useIsMobileQuestDockRenderedBase(r21);
|
|
};
|
|
export function useMobileQuestDockHeight() {
|
|
const isMobileQuestDockRendered = useIsMobileQuestDockRendered();
|
|
const questDockExternalOffset = useQuestDockExternalOffset();
|
|
return isMobileQuestDockRendered ? questDockExternalOffset : 0;
|
|
}
|
|
export function useMobileQuestDock() {
|
|
const enableNewRequestBehavior = NewAdRequestBehaviorExperiment.useConfig({
|
|
location: "QuestMobileDock"
|
|
}).enableNewRequestBehavior;
|
|
let r18 = useStateFromStores([QuestStore], () => QuestStore.getQuestPreviewOverride(QuestContent.QUEST_BAR_MOBILE), []);
|
|
let r24 = useStateFromStores([QuestStore], () => {
|
|
let r14 = getQuestForPlacement(QuestStore.quests, QuestStore.questToDeliverForPlacement, AdPlacement.MOBILE_HOME_DOCK_AREA);
|
|
if (r14 == null) {
|
|
r14 = null;
|
|
}
|
|
return r14;
|
|
});
|
|
const questForPlacement = useQuestForPlacement(AdPlacement.MOBILE_HOME_DOCK_AREA);
|
|
if (r18 == null) {
|
|
if (enableNewRequestBehavior) {
|
|
r24 = questForPlacement;
|
|
}
|
|
r18 = r24;
|
|
}
|
|
return r18;
|
|
}
|
|
export function useIsMobileQuestDockVisibleToUser(c20921_0, a1) {
|
|
let r13 = a1;
|
|
const isChannelFocused = useIsChannelFocused();
|
|
let r22 = coerceGuildsRoute({
|
|
name: useCurrentNavigationRouteName()
|
|
}) != null;
|
|
let r28 = useStateFromStores([QuestStore], () => c20921_0 != null && QuestStore.isClaimingReward(c20921_0.id));
|
|
const stateFromStores3 = useStateFromStores([ActionSheetStore], () => {
|
|
const key = ActionSheetStore.getKey();
|
|
return key === CAPTCHA_MODAL_KEY || key === QUEST_REWARD_CODE_CLAIM_BOTTOM_SHEET_KEY;
|
|
});
|
|
if (a1) {
|
|
r13 = !isChannelFocused;
|
|
}
|
|
if (r13) {
|
|
if (!r22) {
|
|
if (r28) {
|
|
r28 = stateFromStores3;
|
|
}
|
|
r22 = r28;
|
|
}
|
|
r13 = r22;
|
|
}
|
|
return r13;
|
|
}
|
|
export { useIsMobileQuestDockRenderedBase };
|
|
export { useIsMobileQuestDockRendered };
|
|
export function useQuestGameLogotypeAssetUrl(a0) {
|
|
return useMemo(() => getQuestAsset(a0, QuestAssetType.LOGO_TYPE, ThemeTypes.DARK).url, [a0]);
|
|
}
|
|
export function useQuestDockHeroAsset(a0) {
|
|
return useMemo(() => {
|
|
const questAsset = getQuestAsset(a0, QuestAssetType.QUEST_BAR_HERO);
|
|
const videoAsset = a0.config.assets.questBarHeroVideo != null ? resolveAsset(a0.id, a0.config.assets.questBarHeroVideo) : null;
|
|
const { isAnimated, url } = questAsset;
|
|
return {
|
|
staticUrl: isAnimated ? url.replace(EXTENSION_RE, ".png") : url,
|
|
videoAsset
|
|
};
|
|
}, [a0]);
|
|
}
|
|
export function useHasWatchVideoOnMobileTasks(a0) {
|
|
const config = a0;
|
|
return useMemo(() => hasWatchVideoOnMobileTasks({
|
|
config
|
|
}), [a0]);
|
|
}
|
|
export function useMobileActivityQuest(a0) {
|
|
let canLaunchFrame, c20925_4;
|
|
const activityApplicationId = getActivityApplicationId(a0);
|
|
const stateFromStores2 = useStateFromStores([ApplicationStore], () => ApplicationStore.getApplication(activityApplicationId));
|
|
canLaunchFrame = _canLaunchFrame.canLaunchFrame(stateFromStores2);
|
|
let isMobileActivityQuest = canLaunchActivity(a0) && a0.config.features.includes(QuestVariants.MOBILE_ACTIVITY_QUEST) && isActivitySupportedOnClientPlatform(stateFromStores2 == null ? void 0 : stateFromStores2.embeddedActivityConfig?.supported_platforms);
|
|
if (isMobileActivityQuest) {
|
|
let r38 = canLaunchFrame;
|
|
if (!canLaunchFrame) {
|
|
r38 = (stateFromStores2 == null ? void 0 : stateFromStores2.bot?.id) != null;
|
|
}
|
|
isMobileActivityQuest = r38;
|
|
}
|
|
c20925_4 = isMobileActivityQuest;
|
|
useEffect(() => {
|
|
if (stateFromStores2 == null && activityApplicationId != null && a0.config.features.includes(QuestVariants.MOBILE_ACTIVITY_QUEST)) {
|
|
ApplicationActionCreators.fetchApplications([activityApplicationId], false);
|
|
}
|
|
}, [stateFromStores2, activityApplicationId, a0.config.features]);
|
|
return {
|
|
isMobileActivityQuest,
|
|
questApplication: stateFromStores2,
|
|
launchMobileActivity: useCallback(async () => {
|
|
L19: {
|
|
L18: {
|
|
L16: {
|
|
if (!c20925_4) {
|
|
break L19;
|
|
}
|
|
if (canLaunchFrame) {
|
|
await FramesActionCreators_native.launchFrame({
|
|
applicationId: stateFromStores2.id
|
|
});
|
|
break L18;
|
|
}
|
|
if ((stateFromStores2 == null ? void 0 : stateFromStores2.bot?.id) != null) {
|
|
await launchActivityInBotDM({
|
|
appId: stateFromStores2.id,
|
|
botId: stateFromStores2.bot.id,
|
|
analyticsLocations: []
|
|
});
|
|
break L16;
|
|
}
|
|
break L19;
|
|
}
|
|
return void 0;
|
|
}
|
|
return void 0;
|
|
}
|
|
}, [canLaunchFrame, stateFromStores2, isMobileActivityQuest])
|
|
};
|
|
}
|