Files
discord-decomp/modules/user_settings/family_center/ParentalControlledUserSettingsDefinitions.tsx
T
2026-11-01 12:12:55 +02:00

82 lines
2.9 KiB
TypeScript

// Metro module 13857 (f13858).
import FamilyCenterControlledSettingsStore from "../../parent_tools/FamilyCenterControlledSettingsStore";
import FamilyCenterActionCreators from "../../parent_tools/FamilyCenterActionCreators";
import { useStateFromStores } from "../../../_bundle/Module589";
export function defineParentalControlledSetting(c20760_0, c20760_1, c20760_2, c20760_3, r7 = {}) {
let c20760_4, getControlledSetting2, c20760_6;
let comparator = r7.comparator;
if (comparator === void 0) {
comparator = (a0, a1) => a0 === a1;
}
c20760_4 = comparator;
getControlledSetting2 = (a0) => {
const settings = FamilyCenterControlledSettingsStore.getSettings(a0);
const r2 = settings == null;
let r10 = void 0;
if (!r2) {
const r12 = settings[c20760_0];
r10 = r12 == null ? void 0 : r12[c20760_1];
}
return c20760_2(r10);
};
c20760_6 = (a0, a1) => {};
return {
getControlledSetting: getControlledSetting2,
updateControlledSetting: function(a0, a1) {
let r5 = a1;
if (typeof a1 === "function") {
const settings = FamilyCenterControlledSettingsStore.getSettings(a0);
const r2 = settings == null;
let r12 = void 0;
if (!r2) {
const r14 = settings[c20760_0];
r12 = r14 == null ? void 0 : r14[c20760_1];
}
r5 = a1(c20760_2(r12));
}
let c27581_0 = r5;
return a0 == null ? Promise.resolve() : FamilyCenterActionCreators.updateTeenSettings(a0, c20760_0, (a0) => {
a0[c20760_1] = c20760_3(c27581_0, a0[c20760_1]);
});
},
useControlledSetting: (a0) => {
return useStateFromStores([FamilyCenterControlledSettingsStore], () => {
const settings = FamilyCenterControlledSettingsStore.getSettings(a0);
const r2 = settings == null;
let r11 = void 0;
if (!r2) {
const r13 = settings[c20760_0];
r11 = r13 == null ? void 0 : r13[c20760_1];
}
return c20760_2(r11);
}, [a0], c20760_4);
}
};
}
export function wrapParentalControlledSettingWithExperimentDefaults({ baseSetting, isEligible, useIsEligible, eligibleDefault, ineligibleDefault, onUseDefault }) {
return {
getControlledSetting: (a0) => {
let r5 = baseSetting.getControlledSetting(a0);
if (r5 == null) {
if (onUseDefault != null) {
onUseDefault();
}
r5 = isEligible() ? eligibleDefault() : ineligibleDefault;
}
return r5;
},
useControlledSetting: (a0) => {
let r6 = baseSetting.useControlledSetting(a0);
const isEligible2 = useIsEligible();
if (r6 == null) {
if (onUseDefault != null) {
onUseDefault();
}
r6 = isEligible2 ? eligibleDefault() : ineligibleDefault;
}
return r6;
},
updateControlledSetting: (a0, a1) => baseSetting.updateControlledSetting(a0, a1)
};
}