79 lines
3.2 KiB
TypeScript
79 lines
3.2 KiB
TypeScript
// Metro module 16294 (f16295).
|
|
import ActionSheetStore from "../../action_sheet/native/ActionSheetStore";
|
|
import FamilyCenterStore from "../FamilyCenterStore";
|
|
import ParentalConsentWarningStore from "../ParentalConsentWarningStore";
|
|
import { UserLinkStatus, UserLinkType } from "../FamilyCenterConstants";
|
|
import { AppStates } from "../../../Constants";
|
|
import { ParentalConsentWarningSurface } from "../ParentalConsentWarningTypes";
|
|
import ActionSheetActionCreators from "../../action_sheet/native/ActionSheetActionCreators";
|
|
import AutomaticLifecycleManager from "../../../lib/AutomaticLifecycleManager";
|
|
import { maybeFetchWarning, forceFetchWarning, resetFetchState } from "../ParentalConsentWarningActionCreators";
|
|
let c11713_3, $mk99174 = function() {
|
|
return (a0) => a0.link_status === UserLinkStatus.ACTIVE && a0.link_type === UserLinkType.PARENT;
|
|
};
|
|
const maybePresentModal = function maybePresentModal(warning) {
|
|
const daysRemaining = warning?.daysRemaining;
|
|
const r11 = warning == null;
|
|
let r5 = void 0;
|
|
if (!r11) {
|
|
const surfaces = warning.surfaces;
|
|
r5 = surfaces == null ? void 0 : surfaces.includes(ParentalConsentWarningSurface.MODAL);
|
|
}
|
|
if (r5 === true && daysRemaining != null && daysRemaining >= 0 && !ParentalConsentWarningStore.hasShownModalToday() && !Object.values(FamilyCenterStore.getLinkedUsers()).some($mk99174()) && !ActionSheetStore.isOpen()) {
|
|
ActionSheetActionCreators.openLazy(import("./ParentalConsentWarningModal"), "ParentalConsentWarningModal", {
|
|
daysRemaining
|
|
});
|
|
}
|
|
};
|
|
class ParentalConsentWarningManager extends AutomaticLifecycleManager {
|
|
actions = {
|
|
PARENTAL_CONSENT_WARNING_FETCH_SUCCESS: (a0) => {
|
|
maybePresentModal(a0.warning);
|
|
},
|
|
POST_CONNECTION_OPEN: () => {
|
|
c11713_3 = Object.values(FamilyCenterStore.getLinkedUsers()).some($mk99174());
|
|
maybeFetchWarning();
|
|
if (!ParentalConsentWarningStore.shouldFetchToday()) {
|
|
maybePresentModal(ParentalConsentWarningStore.getWarning());
|
|
}
|
|
},
|
|
APP_STATE_UPDATE: (a0) => {
|
|
if (a0.state === AppStates.ACTIVE) {
|
|
maybeFetchWarning();
|
|
if (!ParentalConsentWarningStore.shouldFetchToday()) {
|
|
maybePresentModal(ParentalConsentWarningStore.getWarning());
|
|
}
|
|
}
|
|
},
|
|
CURRENT_USER_UPDATE: ({ user }) => {
|
|
if (user.linked_users !== void 0) {
|
|
const r12 = user.linked_users.some($mk99174());
|
|
const r13 = c11713_3;
|
|
c11713_3 = r12;
|
|
if (r13 !== void 0 && r13 !== r12) {
|
|
if (r12) {
|
|
const warning = ParentalConsentWarningStore.getWarning();
|
|
const r2 = warning == null;
|
|
let r24 = void 0;
|
|
if (!r2) {
|
|
const surfaces = warning.surfaces;
|
|
r24 = surfaces == null ? void 0 : surfaces.includes(ParentalConsentWarningSurface.BANNER);
|
|
}
|
|
if (r24 === true) {
|
|
forceFetchWarning();
|
|
}
|
|
} else {
|
|
forceFetchWarning();
|
|
}
|
|
}
|
|
}
|
|
},
|
|
LOGOUT: () => {
|
|
c11713_3 = void 0;
|
|
resetFetchState();
|
|
}
|
|
};
|
|
}
|
|
const parentalConsentWarningManager = new ParentalConsentWarningManager();
|
|
export default parentalConsentWarningManager;
|