decord/alpha/source/modules/notifications/NotificationSettingsUtils.tsx

131 lines
5.4 KiB
TypeScript
Raw Normal View History

// Module ID: 14736
// Function ID: 14737
// Name: notifications/NotificationSettingsUtils
// Dependencies: [32, 19, 14730, 14737, 14738, 504, 1434, 2]
2026-09-03 10:05:34 +00:00
// Exports: getAssignedNotifSettingsAndMappings, useIsDeclarativeSettingsUIAvailable, useNotifCategoryVisibility, useNotifSettingVisibility
2026-07-20 16:05:17 +00:00
// Module 14736 (notifications/NotificationSettingsUtils)
import NotificationSettingsExperiments from "NotificationSettingsExperiments" /* 14737 */;
import DeclarativeNotificationSettingsRedesignExperiment from "DeclarativeNotificationSettingsRedesignExperiment" /* 14738 */;
import _slicedToArray from "module_32" /* 32 */;
import noop from "module_19" /* 19 */;
2026-07-23 10:11:24 +00:00
const require = globalThis.__r;
require = fn;
2026-09-02 09:53:35 +00:00
function getNamedExperiment(experiment) {
const tmp = NotificationSettingsExperiments.knownExperimentConfigs[experiment];
2026-09-02 09:53:35 +00:00
if (tmp.definition.name !== experiment) {
const _Error = Error;
const _HermesInternal = HermesInternal;
const error = new Error("Experiment called " + tmp.definition.name + " assigned to name " + experiment);
2026-09-02 09:53:35 +00:00
throw error;
} else {
return tmp;
}
}
const NotificationSettingsConstants = fn(14730);
({ NOTIF_SETTING_MAPPING: closure_4, NOTIF_SETTINGS: hasOwnProperty } = NotificationSettingsConstants);
const size = fn(2);
let result = size.fileFinishedImporting("modules/notifications/NotificationSettingsUtils.tsx");
2026-07-20 16:05:17 +00:00
export const getAssignedNotifSettingsAndMappings = function getAssignedNotifSettingsAndMappings() {
const settings = [];
const mappings = [];
const result = DeclarativeNotificationSettingsRedesignExperiment.isDeclarativeNotificationSettingsRedesignEnabled("getAssignedNotifSettingsAndMappings");
2026-07-20 16:05:17 +00:00
const set = new Set();
2026-07-29 08:29:29 +00:00
const iter = dependencyMap[Symbol.iterator]();
const nextResult = iter.next();
while (iter !== undefined) {
let tmp4 = nextResult;
let redesignState = nextResult.redesignState;
if (null == redesignState) {
if (null != tmp4.experiment) {
let obj3 = getNamedExperiment(tmp4.experiment);
let variations = tmp4.variations;
continue;
}
let arr = settings.push(tmp4);
let addResult = set.add(tmp4.id);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
continue;
2026-07-20 16:05:17 +00:00
}
const entries = Object.entries(React4);
while (tmp14 !== undefined) {
let tmp17 = _slicedToArray(tmp15, 2);
let tmp18 = tmp17[1];
2026-07-20 16:05:17 +00:00
let _parseInt = parseInt;
let parsed = parseInt(tmp17[0]);
for (const item10071 of tmp18) {
let tmp22 = item10071;
if (set.has(item10071)) {
let obj2 = { notifType: null, notifSetting: null };
obj2.notifType = parsed;
obj2.notifSetting = tmp22;
let arr2 = mappings.push(obj2);
obj4.return();
2026-07-29 08:29:29 +00:00
break;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
continue;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
continue;
2026-07-20 16:05:17 +00:00
}
return { settings, mappings };
};
export const useIsDeclarativeSettingsUIAvailable = function useIsDeclarativeSettingsUIAvailable(AndroidMessageNotificationsSetting) {
return DeclarativeNotificationSettingsRedesignExperiment.useIsDeclarativeNotificationSettingsRedesignEnabled("useIsDeclarativeSettingsUIAvailable:" + AndroidMessageNotificationsSetting);
};
export const useNotifCategoryVisibility = function useNotifCategoryVisibility(CATEGORY_OTHER) {
return DeclarativeNotificationSettingsRedesignExperiment.useIsDeclarativeNotificationSettingsRedesignEnabled("useIsDeclarativeSettingsUIAvailable:" + CATEGORY_OTHER);
};
2026-09-02 09:53:35 +00:00
export const useNotifSettingVisibility = function useNotifSettingVisibility(GAMING_DEFAULT) {
_require = GAMING_DEFAULT;
2026-09-02 09:53:35 +00:00
const items = [GAMING_DEFAULT];
const memo = noop.useMemo(() => (function getExperimentAndConfigBySettingId(arg0) {
2026-09-02 09:53:35 +00:00
const iter = dependencyMap[Symbol.iterator]();
const nextResult = iter.next();
while (iter !== undefined) {
let tmp3 = nextResult;
if (nextResult.id === arg0) {
let redesignState = tmp3.redesignState;
2026-09-02 09:53:35 +00:00
if (null != tmp3.experiment) {
let obj2 = { redesignState, experiment: null, variations: null };
obj2.experiment = closure_1_6(nextResult.experiment);
obj2.variations = nextResult.variations;
iter.return();
return obj2;
} else if (null != redesignState) {
let obj = { redesignState: null };
obj.redesignState = redesignState;
2026-09-02 09:53:35 +00:00
iter.return();
return obj;
}
}
continue;
}
return {};
})(closure_0), items);
const experiment = memo.experiment;
const variations = memo.variations;
const items1 = [require("ApexExperiment").ApexExperimentStore];
2026-09-02 09:53:35 +00:00
const items2 = [experiment];
const stateFromStores = require("initialize").useStateFromStores(items1, () => {
2026-09-02 09:53:35 +00:00
let config;
if (experiment != null) {
config = experiment.getConfig({ location: "useNotifSettingVisibility" });
}
return config;
}, items2);
let obj = require("initialize");
let isDeclarativeNotificationSettingsRedesignEnabled = require("DeclarativeNotificationSettingsRedesignExperiment").useIsDeclarativeNotificationSettingsRedesignEnabled("useIsDeclarativeSettingsUIAvailable:" + "useNotifSettingVisibility");
if (isDeclarativeNotificationSettingsRedesignEnabled) {
let tmp4 = false !== memo.redesignState;
if (tmp4) {
tmp4 = null == stateFromStores || null == variations || variations.includes(stateFromStores.variation);
let tmp6 = null == stateFromStores || null == variations || variations.includes(stateFromStores.variation);
}
isDeclarativeNotificationSettingsRedesignEnabled = tmp4;
}
return isDeclarativeNotificationSettingsRedesignEnabled;
2026-09-02 09:53:35 +00:00
};