decord/source/modules/nuf/native/NotificationPermissionUtil.tsx

372 lines
13 KiB
TypeScript
Raw Normal View History

2026-08-24 06:08:38 +00:00
// Module ID: 11632
// Function ID: 11633
2026-07-20 16:05:17 +00:00
// Name: _requestPushNotificationPermission
2026-08-24 06:08:38 +00:00
// Dependencies: [32, 5, 19, 17, 11627, 11631, 676, 4844, 11630, 698, 11633, 11639, 11640, 589, 2]
2026-07-29 08:29:29 +00:00
// Exports: enableProvisionalPushNotification, requestPushNotificationPermission, useCanSeePushNotificationNudge, useShouldShowPushNotificationNudgeByPromptType, useShowReactivationPrompt
2026-07-20 16:05:17 +00:00
2026-08-24 06:08:38 +00:00
// Module 11632 (_requestPushNotificationPermission)
import initialize from "initialize" /* 589 */;
import set from "set" /* 11640 */;
import closure_3 from "_slicedToArray" /* 32 */;
import closure_4 from "asyncGeneratorStep" /* 5 */;
import closure_5 from "noop" /* 19 */;
import { NativeModules } from "get ActivityIndicator" /* 17 */;
import closure_7 from "set" /* 11627 */;
import { EventActionType } from "EventActionType" /* 11631 */;
import { AnalyticEvents } from "ME" /* 676 */;
import { NotificationAuthorizationStatus as closure_10 } from "NativePermissionStatus" /* 4844 */;
2026-07-23 10:11:24 +00:00
2026-08-24 06:08:38 +00:00
require = arg1;
2026-07-20 16:05:17 +00:00
function _requestPushNotificationPermission() {
2026-07-29 08:29:29 +00:00
const self = this;
const tmp = callback2((arg0, arg1, arg2) => {
2026-08-24 06:08:38 +00:00
closure_0 = arg0;
closure_1 = arg1;
closure_2 = arg2;
c5 = 0;
c6 = 0;
2026-07-29 08:29:29 +00:00
return (function*(arg0, arg1, arg2) {
if (obj === 2) {
obj = 3;
HermesBuiltin.throwTypeError();
} else if (tmp4 === 3) {
if (arg0 === 1) {
throw arg1;
} else if (arg0 === 2) {
obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
2026-08-24 06:08:38 +00:00
return { value: "HermesInternal", done: null };
2026-07-29 08:29:29 +00:00
}
} else {
try {
obj = 2;
if (0 === c5) {
if (arg0 === 1) {
obj = 3;
throw arg1;
} else if (arg0 === 2) {
obj = 3;
obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
2026-08-24 06:08:38 +00:00
closure_4 = tmp5;
closure_3 = tmp2;
closure_3 = undefined;
2026-07-29 08:29:29 +00:00
const NativePermissionManager = obj.NativePermissionManager;
c5 = 1;
obj = 1;
2026-08-24 06:08:38 +00:00
obj1 = { value: null, done: false };
2026-07-29 08:29:29 +00:00
obj1[0] = NativePermissionManager.getNotificationAuthorizationStatus();
return obj1;
}
} else if (arg0 === 1) {
obj = 3;
throw arg1;
} else if (arg0 === 2) {
obj = 3;
let obj2 = { value: null, done: true };
obj2[0] = arg1;
return obj2;
} else {
2026-08-24 06:08:38 +00:00
closure_3 = arg1;
if (closure_3 === constants3.DENIED) {
callback2(11630)();
2026-07-29 08:29:29 +00:00
obj2 = callback2(698);
const obj3 = { action_type: null, action_location: null };
obj3[0] = constants.TO_SETTINGS;
obj3[1] = callback2;
obj2.track(constants2.NOTIFICATION_PERMISSION_PREPROMPT_ACKED, obj3);
dependencyMap();
obj = 3;
2026-08-24 06:08:38 +00:00
} else if (closure_3 !== constants3.AUTHORIZED) {
obj = callback2(11639);
2026-07-29 08:29:29 +00:00
const permission = obj.requestPermission((permission_granted) => {
let obj = callback(698);
obj = { action_type: closure_0, action_location: callback, permission_granted };
2026-08-24 06:08:38 +00:00
obj.track(closure_1_9.NOTIFICATION_PERMISSION_PREPROMPT_ACKED, obj);
2026-07-29 08:29:29 +00:00
dependencyMap();
});
}
2026-08-24 06:08:38 +00:00
obj1 = callback(11633);
const result = obj1.updateNotificationAuthorizationStatus(closure_3);
2026-07-29 08:29:29 +00:00
dependencyMap();
}
} catch (tmp36) {
obj = tmp;
throw tmp36;
}
}
})();
});
2026-08-24 06:08:38 +00:00
closure_11 = tmp;
2026-07-29 08:29:29 +00:00
const apply = tmp.apply;
if (typeof apply === "unknown") {
let applyArgumentsResult = HermesBuiltin.applyArguments(self);
} else {
applyArgumentsResult = apply(self, arguments);
}
return applyArgumentsResult;
2026-07-20 16:05:17 +00:00
}
function _enableProvisionalPushNotification() {
2026-07-29 08:29:29 +00:00
const self = this;
const tmp = callback2(function*() {
if (c3 === 2) {
c3 = 3;
HermesBuiltin.throwTypeError();
} else if (tmp3 === 3) {
if (arg0 === 1) {
throw arg1;
} else if (arg0 === 2) {
let obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
2026-08-24 06:08:38 +00:00
return { value: "HermesInternal", done: null };
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
} else {
try {
c3 = 2;
if (0 === c2) {
if (arg0 === 1) {
c3 = 3;
throw arg1;
} else if (arg0 === 2) {
c3 = 3;
obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
2026-08-24 06:08:38 +00:00
closure_1 = tmp4;
closure_0 = tmp4;
let NativePermissionManager = closure_1_6.NativePermissionManager;
2026-07-29 08:29:29 +00:00
c2 = 1;
c3 = 1;
2026-08-24 06:08:38 +00:00
obj1 = { value: null, done: false };
2026-07-29 08:29:29 +00:00
obj1[0] = NativePermissionManager.getNotificationAuthorizationStatus();
return obj1;
}
} else if (arg0 === 1) {
c3 = 3;
throw arg1;
} else if (arg0 === 2) {
c3 = 3;
obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
if (arg1 === constants.UNDETERMINED) {
const DCDProvisionalNotificationUtils = obj.DCDProvisionalNotificationUtils;
let result = DCDProvisionalNotificationUtils.registerProvisionalNotification((arg0) => {
2026-08-24 06:08:38 +00:00
let obj = callback(table[9]);
2026-07-29 08:29:29 +00:00
let str = "denied";
if (arg0) {
str = "accepted";
}
obj.track(constants.PERMISSIONS_ACKED, { type: "provisional_notification", action: str });
const NativePermissionManager = obj.NativePermissionManager;
const notificationAuthorizationStatus = NativePermissionManager.getNotificationAuthorizationStatus();
notificationAuthorizationStatus.then((closure_0) => {
if (null != closure_0) {
const result = callback(table[10]).updateNotificationAuthorizationStatus(closure_0);
const obj = callback(table[10]);
}
});
});
}
c3 = 3;
2026-08-24 06:08:38 +00:00
return { value: "HermesInternal", done: null };
2026-07-29 08:29:29 +00:00
}
} catch (tmp12) {
c3 = tmp;
throw tmp12;
}
}
});
2026-08-24 06:08:38 +00:00
closure_12 = tmp;
2026-07-29 08:29:29 +00:00
const apply = tmp.apply;
if (typeof apply === "unknown") {
let applyArgumentsResult = HermesBuiltin.applyArguments(self);
} else {
applyArgumentsResult = apply(self, arguments);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return applyArgumentsResult;
2026-07-20 16:05:17 +00:00
}
2026-08-24 06:08:38 +00:00
let result = require("set").fileFinishedImporting("modules/nuf/native/NotificationPermissionUtil.tsx");
2026-07-20 16:05:17 +00:00
export const requestPushNotificationPermission = function requestPushNotificationPermission(ALLOW_TO_REQUEST, ALERT, callback) {
2026-07-29 08:29:29 +00:00
const self = this;
const apply = _requestPushNotificationPermission.apply;
if (typeof apply === "unknown") {
let applyArgumentsResult = HermesBuiltin.applyArguments(self);
} else {
applyArgumentsResult = apply(self, arguments);
}
return applyArgumentsResult;
2026-07-20 16:05:17 +00:00
};
export const useShowReactivationPrompt = function useShowReactivationPrompt() {
2026-07-29 08:29:29 +00:00
[tmp2, require] = callback(React.useState(false), 2);
2026-07-20 16:05:17 +00:00
const effect = React.useEffect(() => {
function _shouldShowReactivationPrompts() {
2026-07-29 08:29:29 +00:00
const self = this;
2026-08-24 06:08:38 +00:00
const tmp = closure_2_4(function*() {
2026-07-29 08:29:29 +00:00
if (c2 === 2) {
c2 = 3;
HermesBuiltin.throwTypeError();
} else if (tmp3 === 3) {
if (arg0 === 1) {
throw arg1;
} else if (arg0 === 2) {
let obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
2026-08-24 06:08:38 +00:00
return { value: "HermesInternal", done: null };
2026-07-29 08:29:29 +00:00
}
} else {
try {
c2 = 2;
if (0 === c1) {
if (arg0 === 1) {
c2 = 3;
throw arg1;
} else if (arg0 === 2) {
c2 = 3;
obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
2026-08-24 06:08:38 +00:00
closure_0 = tmp4;
const NativePermissionManager = closure_2_6.NativePermissionManager;
2026-07-29 08:29:29 +00:00
c1 = 1;
c2 = 1;
2026-08-24 06:08:38 +00:00
obj1 = { value: null, done: false };
2026-07-29 08:29:29 +00:00
obj1[0] = NativePermissionManager.getNotificationAuthorizationStatus();
return obj1;
}
} else if (arg0 === 1) {
c2 = 3;
throw arg1;
} else if (arg0 === 2) {
c2 = 3;
obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
2026-08-24 06:08:38 +00:00
if (arg1 !== closure_2_10.AUTHORIZED) {
closure_1_0(true);
2026-07-29 08:29:29 +00:00
}
c2 = 3;
2026-08-24 06:08:38 +00:00
return { value: "HermesInternal", done: null };
2026-07-29 08:29:29 +00:00
}
} catch (tmp11) {
c2 = tmp;
throw tmp11;
}
}
});
2026-08-24 06:08:38 +00:00
closure_0 = tmp;
2026-07-29 08:29:29 +00:00
const apply = tmp.apply;
if (typeof apply === "unknown") {
let applyArgumentsResult = HermesBuiltin.applyArguments(self);
} else {
applyArgumentsResult = apply(self, arguments);
}
return applyArgumentsResult;
2026-07-20 16:05:17 +00:00
}
2026-07-23 10:11:24 +00:00
!(function shouldShowReactivationPrompts() {
2026-07-29 08:29:29 +00:00
const self = this;
const apply = _shouldShowReactivationPrompts.apply;
if (typeof apply === "unknown") {
let applyArgumentsResult = HermesBuiltin.applyArguments(self);
} else {
applyArgumentsResult = apply(self, arguments);
}
return applyArgumentsResult;
2026-07-23 10:11:24 +00:00
})();
2026-07-20 16:05:17 +00:00
}, []);
2026-07-29 08:29:29 +00:00
return tmp2;
2026-07-20 16:05:17 +00:00
};
export const enableProvisionalPushNotification = function enableProvisionalPushNotification() {
2026-07-29 08:29:29 +00:00
const self = this;
const apply = _enableProvisionalPushNotification.apply;
if (typeof apply === "unknown") {
let applyArgumentsResult = HermesBuiltin.applyArguments(self);
} else {
applyArgumentsResult = apply(self, arguments);
}
return applyArgumentsResult;
};
export const useCanSeePushNotificationNudge = function useCanSeePushNotificationNudge() {
2026-08-24 06:08:38 +00:00
const isTeenInStrictCountry = set.useIsTeenInStrictCountry();
const obj = set;
const items = [closure_7];
const stateFromStores = initialize.useStateFromStores(items, () => state.authorizationStatus);
const obj2 = initialize;
2026-07-29 08:29:29 +00:00
[tmp4, require] = callback(React.useState(false), 2);
const effect = React.useEffect(() => {
2026-08-24 06:08:38 +00:00
const NativePermissionManager = closure_1_6.NativePermissionManager;
2026-07-29 08:29:29 +00:00
const notificationAuthorizationStatus = NativePermissionManager.getNotificationAuthorizationStatus();
notificationAuthorizationStatus.then((closure_0) => {
if (null != closure_0) {
2026-08-24 06:08:38 +00:00
const result = closure_1_0(closure_1_2[10]).updateNotificationAuthorizationStatus(closure_0);
const obj = closure_1_0(closure_1_2[10]);
2026-07-29 08:29:29 +00:00
}
callback(true);
});
}, []);
if (hasItem) {
hasItem = !isTeenInStrictCountry;
}
if (hasItem) {
hasItem = null != stateFromStores;
}
if (hasItem) {
const items1 = [, , ];
({ DENIED: arr2[0], PROVISIONAL: arr2[1], UNDETERMINED: arr2[2] } = closure_10);
hasItem = items1.includes(stateFromStores);
}
return hasItem;
2026-07-20 16:05:17 +00:00
};
export const useShouldShowPushNotificationNudgeByPromptType = function useShouldShowPushNotificationNudgeByPromptType(CHANNEL_BANNER) {
2026-08-24 06:08:38 +00:00
const isTeenInStrictCountry = set.useIsTeenInStrictCountry();
let obj = set;
2026-07-29 08:29:29 +00:00
const tmp = require;
2026-08-24 06:08:38 +00:00
const items = [closure_7];
const stateFromStores = initialize.useStateFromStores(items, () => state.authorizationStatus);
const obj2 = initialize;
const tmp4 = closure_7;
2026-07-29 08:29:29 +00:00
[tmp7, require] = callback(React.useState(false), 2);
const effect = React.useEffect(() => {
2026-08-24 06:08:38 +00:00
const NativePermissionManager = closure_1_6.NativePermissionManager;
2026-07-29 08:29:29 +00:00
const notificationAuthorizationStatus = NativePermissionManager.getNotificationAuthorizationStatus();
notificationAuthorizationStatus.then((closure_0) => {
if (null != closure_0) {
2026-08-24 06:08:38 +00:00
const result = closure_1_0(closure_1_2[10]).updateNotificationAuthorizationStatus(closure_0);
const obj = closure_1_0(closure_1_2[10]);
2026-07-29 08:29:29 +00:00
}
callback(true);
});
}, []);
if (hasItem) {
hasItem = !isTeenInStrictCountry;
}
if (hasItem) {
hasItem = null != stateFromStores;
}
if (hasItem) {
const items1 = [, , ];
({ DENIED: arr2[0], PROVISIONAL: arr2[1], UNDETERMINED: arr2[2] } = closure_10);
hasItem = items1.includes(stateFromStores);
}
const tmp6 = callback(React.useState(false), 2);
const items2 = [tmp4];
2026-08-24 06:08:38 +00:00
const stateFromStores1 = initialize.useStateFromStores(items2, () => state.getState().eligiblePromptTypes);
2026-07-20 16:05:17 +00:00
if (hasItem) {
2026-07-29 08:29:29 +00:00
hasItem = stateFromStores1.has(CHANNEL_BANNER);
2026-07-20 16:05:17 +00:00
}
return hasItem;
};