330 lines
12 KiB
TypeScript
330 lines
12 KiB
TypeScript
// Metro module 10960 (f10961).
|
|
import QuestHomeNavigationStore from "../QuestHomeNavigationStore";
|
|
import { QUEST_REWARD_CODE_CLAIM_BOTTOM_SHEET_KEY, QuestsExperimentLocations, QUEST_REWARD_DETAILS_BOTTOM_SHEET_KEY, QuestVariants } from "../QuestConstants";
|
|
import { UserSettingsSections } from "../../../Constants";
|
|
import { jsxs, Fragment } from "react/jsx-runtime";
|
|
import ActionSheetActionCreators from "../../action_sheet/native/ActionSheetActionCreators";
|
|
import { hasQuestRewardCode, hasVirtualCurrencyReward, getDefaultPlatform } from "../utils/QuestRewardUtils";
|
|
import { openQuestOrbsRewardModal } from "./QuestOrbsRewardModal.native";
|
|
import { openQuestCollectibleRewardModal } from "./openQuestCollectibleRewardModal";
|
|
import { getQuestLogger } from "../lib/getQuestLogger";
|
|
import { claimQuestReward, fetchCurrentQuests } from "../QuestActionCreators";
|
|
import { QuestContent } from "../QuestTypes";
|
|
import ToastActionCreators from "../../toast/native/ToastActionCreators";
|
|
import { intl, t } from "../../../intl/index.native";
|
|
import Module9172 from "../../../_bundle/Module9172";
|
|
import EmailVerificationModalActionCreators from "../../../actions/native/EmailVerificationModalActionCreators";
|
|
import { getIsEligibleForQuests } from "../lib/QuestsEligibility";
|
|
import { setQuestHomeUtmContext, canLaunchActivity } from "../utils/QuestUtils";
|
|
import closeVoicePanels from "../../voice_panel/native/utils/closeVoicePanels";
|
|
import { getRootNavigationRef } from "../../main_tabs_v2/RootNavigationRef.native";
|
|
import { openUserSettings } from "../../user_settings/core/native/openUserSettings";
|
|
import * as _PlatformUtils from "../../../utils/PlatformUtils";
|
|
import Linking from "../../../lib/native/Linking";
|
|
import Module712 from "../../../_bundle/Module712";
|
|
import { CloudIcon } from "../../../design/components/Icon/native/redesign/generated/CloudIcon";
|
|
import { GameControllerIcon } from "../../../design/components/Icon/native/redesign/generated/GameControllerIcon";
|
|
import { openAlert } from "../../../design/components/AlertModal/native/useAlertStore.native";
|
|
import { AlertModal, AlertActionButton } from "../../../design/components/AlertModal/native/AlertModal.native";
|
|
import { CommonActions } from "../../../_bundle/Module1481";
|
|
function $mk116078($env) {
|
|
return function handleRewardClaim() {
|
|
return $env[15].apply(this, arguments);
|
|
};
|
|
}
|
|
let viewReward;
|
|
let env7383 = {};
|
|
const openRewardClaimBottomSheet = function openRewardClaimBottomSheet({ questId, questContent, questContentPosition, sourceQuestContent }) {
|
|
return ActionSheetActionCreators.openLazy(import("./QuestRewardCodeClaimBottomSheet.native"), QUEST_REWARD_CODE_CLAIM_BOTTOM_SHEET_KEY, {
|
|
questId,
|
|
questContent,
|
|
questContentPosition,
|
|
sourceQuestContent
|
|
});
|
|
};
|
|
viewReward = function viewReward({ quest, product, questContent, questContentPosition, onSuccess, sourceQuestContent }) {
|
|
if (hasQuestRewardCode(quest.config)) {
|
|
const id = quest.id;
|
|
ActionSheetActionCreators.openLazy(import("./QuestRewardCodeClaimBottomSheet.native"), QUEST_REWARD_CODE_CLAIM_BOTTOM_SHEET_KEY, {
|
|
questId: id,
|
|
questContent,
|
|
questContentPosition,
|
|
sourceQuestContent
|
|
});
|
|
} else if (hasVirtualCurrencyReward(quest.config)) {
|
|
openQuestOrbsRewardModal({
|
|
quest
|
|
});
|
|
} else {
|
|
openQuestCollectibleRewardModal({
|
|
quest,
|
|
product,
|
|
onSuccess
|
|
});
|
|
}
|
|
};
|
|
env7383[15] = function _handleRewardClaim() {
|
|
const r8 = async (c26878_0) => {
|
|
let c26878_3;
|
|
let c26878_4 = 0;
|
|
let c30313_0, c30313_1;
|
|
try {
|
|
c30313_0 = void 0;
|
|
c30313_0 = getQuestLogger({
|
|
location: QuestsExperimentLocations.QUEST_HOME_MOBILE
|
|
});
|
|
const defaultPlatform = getDefaultPlatform(c26878_0.config);
|
|
c26878_4 = 1;
|
|
await claimQuestReward(c26878_0.id, defaultPlatform, QuestContent.QUEST_HOME_MOBILE);
|
|
c26878_4 = 0;
|
|
} catch ($e) {
|
|
const r30 = $e;
|
|
let r7 = r30;
|
|
c26878_3 = r30;
|
|
if (c26878_4 !== 0) {
|
|
while (true) {
|
|
try {
|
|
const r82 = c26878_3;
|
|
c26878_4 = 0;
|
|
c30313_1 = r82;
|
|
c30313_0.error("Error claiming reward", c30313_1);
|
|
ToastActionCreators.open({
|
|
key: "CLAIM_QUEST_REWARD_ERROR",
|
|
content: intl.string(t.CKsXk3),
|
|
icon: Module9172
|
|
});
|
|
} catch (r78) {
|
|
r7 = r78;
|
|
c26878_3 = r78;
|
|
if (c26878_4 === 0) {
|
|
break;
|
|
}
|
|
continue;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
throw r7;
|
|
}
|
|
return true;
|
|
};
|
|
env7383[15] = r8;
|
|
return r8.apply(this, arguments);
|
|
};
|
|
export function openRewardDetailsBottomSheet({ questId }) {
|
|
return ActionSheetActionCreators.openLazy(import("./QuestRewardDetailsBottomSheet.native"), QUEST_REWARD_DETAILS_BOTTOM_SHEET_KEY, {
|
|
questId
|
|
});
|
|
}
|
|
export { viewReward };
|
|
export async function handleRewardClaimThenView(c26879_0) {
|
|
let r120;
|
|
let c26879_1, c26879_2;
|
|
L25: {
|
|
L22: {
|
|
L21: {
|
|
let env30314;
|
|
const r29 = env7383;
|
|
c26879_2 = r29;
|
|
const r30 = env30314 = {
|
|
$parent: r29
|
|
};
|
|
c26879_1 = r30;
|
|
env30314[0] = void 0;
|
|
env30314[1] = void 0;
|
|
env30314[2] = void 0;
|
|
env30314[3] = void 0;
|
|
env30314[4] = void 0;
|
|
env30314[5] = void 0;
|
|
env30314[6] = void 0;
|
|
env30314[7] = void 0;
|
|
env30314[8] = void 0;
|
|
env30314[0] = c26879_0.quest;
|
|
env30314[1] = c26879_0.questContent;
|
|
env30314[2] = c26879_0.questContentPosition;
|
|
env30314[3] = c26879_0.product;
|
|
env30314[4] = c26879_0.hideActionSheet;
|
|
env30314[5] = c26879_0.currentUserHasVerifiedEmailOrPhone;
|
|
env30314[6] = c26879_0.currentUserHasVerifiedEmail;
|
|
env30314[7] = c26879_0.onSuccess;
|
|
env30314[8] = c26879_0.sourceQuestContent;
|
|
env30314[9] = void 0;
|
|
await void 0;
|
|
if (env30314[4] === true) {
|
|
ActionSheetActionCreators.hideActionSheet();
|
|
}
|
|
L11: {
|
|
if (env30314[5]) {
|
|
if (!env30314[6]) {
|
|
if (hasVirtualCurrencyReward(env30314[0].config)) {
|
|
break L11;
|
|
}
|
|
}
|
|
if (hasQuestRewardCode(env30314[0].config)) {
|
|
(0, openRewardClaimBottomSheet)({
|
|
questId: env30314[0].id,
|
|
questContent: env30314[1],
|
|
questContentPosition: env30314[2],
|
|
sourceQuestContent: env30314[8]
|
|
});
|
|
break L22;
|
|
}
|
|
const r100 = env30314[0];
|
|
env30314[9] = await $mk116078(env7383)(r100);
|
|
if (env30314[9]) {
|
|
(0, viewReward)({
|
|
quest: env30314[0],
|
|
product: env30314[3],
|
|
questContent: env30314[1],
|
|
questContentPosition: env30314[2],
|
|
onSuccess: env30314[7],
|
|
sourceQuestContent: env30314[8]
|
|
});
|
|
}
|
|
r120 = env30314[9];
|
|
break L21;
|
|
}
|
|
}
|
|
if (!env30314[6]) {
|
|
EmailVerificationModalActionCreators.open();
|
|
}
|
|
ToastActionCreators.open({
|
|
key: "CLAIM_QUEST_REWARD_ERROR",
|
|
content: intl.string(t["HZlu0+"]),
|
|
icon: Module9172
|
|
});
|
|
break L25;
|
|
}
|
|
return r120;
|
|
}
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
export function openQuestHome(a0) {
|
|
let scrollToQuestId2 = a0.scrollToQuestId;
|
|
const scrollToQuestId = scrollToQuestId2;
|
|
let mergeExistingRoutes = a0.mergeExistingRoutes;
|
|
if (mergeExistingRoutes === void 0) {
|
|
mergeExistingRoutes = false;
|
|
}
|
|
let c18397_1 = mergeExistingRoutes;
|
|
let sort2 = a0.sort;
|
|
if (sort2 === void 0) {
|
|
sort2 = null;
|
|
}
|
|
const sort = sort2;
|
|
let filter2 = a0.filter;
|
|
if (filter2 === void 0) {
|
|
filter2 = null;
|
|
}
|
|
const filter = filter2;
|
|
const fromContent = a0.fromContent;
|
|
if (getIsEligibleForQuests()) {
|
|
if (scrollToQuestId == null) {
|
|
scrollToQuestId2 = void 0;
|
|
}
|
|
setQuestHomeUtmContext({
|
|
questId: scrollToQuestId2,
|
|
fromContent
|
|
});
|
|
closeVoicePanels();
|
|
setTimeout(() => {
|
|
L14: {
|
|
const rootNavigationRef = getRootNavigationRef();
|
|
if (rootNavigationRef != null && rootNavigationRef.isReady()) {
|
|
let r8 = null;
|
|
if (c18397_1) {
|
|
let searchRoutes2;
|
|
const isQuestsRoute2 = function isQuestsRoute(a0) {
|
|
return a0.name === "settings" && a0.params?.screen === UserSettingsSections.QUESTS;
|
|
};
|
|
const rootState = rootNavigationRef.getRootState();
|
|
const routes = rootState?.routes;
|
|
let r21 = null;
|
|
if (routes) {
|
|
searchRoutes2 = function searchRoutes(a0) {
|
|
for (const item of a0) {
|
|
const isQuestsRoute22 = isQuestsRoute2(item);
|
|
if (!isQuestsRoute22) {
|
|
if (!item.state?.routes) {
|
|
continue;
|
|
}
|
|
const r34 = searchRoutes2(item.state.routes);
|
|
if (!r34) {
|
|
continue;
|
|
}
|
|
return r34;
|
|
}
|
|
return item;
|
|
}
|
|
return null;
|
|
};
|
|
r21 = searchRoutes2(rootState.routes);
|
|
}
|
|
r8 = r21;
|
|
}
|
|
let scrollToQuestId2 = scrollToQuestId;
|
|
if (scrollToQuestId == null) {
|
|
scrollToQuestId2 = "";
|
|
}
|
|
QuestHomeNavigationStore.setState({
|
|
sort,
|
|
filter,
|
|
scrollToQuestId: scrollToQuestId2
|
|
});
|
|
const params = {
|
|
screen: UserSettingsSections.QUESTS
|
|
};
|
|
if (c18397_1 && r8 != null) {
|
|
rootNavigationRef.navigate({
|
|
name: "settings",
|
|
key: r8.key,
|
|
params
|
|
});
|
|
break L14;
|
|
}
|
|
openUserSettings(params);
|
|
}
|
|
}
|
|
}, 1);
|
|
}
|
|
}
|
|
export function isHeroVideoSupported(a0) {
|
|
const isIOS = _PlatformUtils.isIOS();
|
|
const r1 = a0.mimetype === "video/mp4";
|
|
return isIOS ? r1 : r1 ? r1 : a0.mimetype === "video/webm";
|
|
}
|
|
export function openDiscordQuestsFAQ() {
|
|
Linking.openURL("https://support.discord.com/hc/en-us/articles/22225719947543-Discord-Quests-FAQ#h_01HVPBZR5FBM7QBFR9KDBASXP5");
|
|
}
|
|
export function getPrimaryCtaIcon(a0, r8 = false) {
|
|
if (canLaunchActivity(a0)) {
|
|
if (a0.config.features.includes(QuestVariants.MOBILE_ACTIVITY_QUEST)) {
|
|
const style = {
|
|
marginRight: r8 ? Module712.space.PX_4 : 0
|
|
};
|
|
return a0.config.features.includes(QuestVariants.CLOUD_GAMING_ACTIVITY) ? <CloudIcon size="sm" style={style} color={Module712.colors.WHITE} /> : <GameControllerIcon size="sm" style={style} color={Module712.colors.WHITE} />;
|
|
}
|
|
}
|
|
}
|
|
export function showQuestUnavailableAlert() {
|
|
openAlert("quest-unavailable", <AlertModal title={intl.string(t.Lhpq2P)} content={intl.string(t.iyF4WB)} actions={(0, jsxs)(Fragment, {
|
|
children: [<AlertActionButton text={intl.string(t.H0vjGc)} onPress={fetchCurrentQuests} />, <AlertActionButton text={intl.string(t["6XS10x"])} variant="secondary" />]
|
|
})} />);
|
|
}
|
|
export function dismissOverlayScreens() {
|
|
const rootNavigationRef = getRootNavigationRef();
|
|
if (rootNavigationRef != null && rootNavigationRef.isReady()) {
|
|
const rootState = rootNavigationRef.getRootState();
|
|
const routes = rootState.routes.filter((route) => route.name !== "you" && route.name !== "settings");
|
|
if (routes.length < rootState.routes.length) {
|
|
rootNavigationRef.dispatch(CommonActions.reset({
|
|
...rootState,
|
|
routes,
|
|
index: routes.length - 1
|
|
}));
|
|
}
|
|
}
|
|
}
|