decord/source/modules/parent_tools/hooks/useConnectGuardianGate.tsx

76 lines
2.5 KiB
TypeScript
Raw Normal View History

// Module ID: 17548
// Function ID: 17549
2026-07-20 16:05:17 +00:00
// Name: useConnectGuardianGate
// Dependencies: [32, 19, 7589, 504, 7591, 5042, 2]
2026-07-20 16:05:17 +00:00
// Exports: useConnectGuardianGate
// Module 17548 (useConnectGuardianGate)
import initialize from "initialize" /* 504 */;
import useMountEffectDefault from "useMountEffect" /* 5042 */;
import _slicedToArray from "module_32" /* 32 */;
import noop from "module_19" /* 19 */;
import FamilyCenterStore from "FamilyCenterStore" /* 7589 */;
2026-07-21 22:01:30 +00:00
const require = globalThis.__r;
require = fn;
const size = fn(2);
const result = size.fileFinishedImporting("modules/parent_tools/hooks/useConnectGuardianGate.tsx");
2026-07-20 16:05:17 +00:00
export const useConnectGuardianGate = function useConnectGuardianGate() {
const items = [FamilyCenterStore];
const stateFromStoresObject = initialize.useStateFromStoresObject(items, () => ({ linkCode: FamilyCenterStore.getLinkCode(), expiresAt: FamilyCenterStore.getLinkCodeExpiresAt() }));
2026-07-20 16:05:17 +00:00
({ linkCode, expiresAt } = stateFromStoresObject);
[tmp3, require] = noop.useState(false);
const tmp4 = _slicedToArray(noop.useState(() => {
const linkCodeExpiresAt = FamilyCenterStore.getLinkCodeExpiresAt();
let tmp2 = null != FamilyCenterStore.getLinkCode() && null != linkCodeExpiresAt;
2026-07-20 16:05:17 +00:00
if (tmp2) {
const _Date = Date;
tmp2 = linkCodeExpiresAt > Date.now();
}
return tmp2;
}), 2);
2026-08-24 06:08:38 +00:00
importDefault = tmp4[1];
dependencyMap = noop.useRef(0);
const callback = noop.useCallback(() => {
2026-07-20 16:05:17 +00:00
const sum = ref.current + 1;
ref.current = sum;
closure_0 = sum;
closure_0(false);
const linkCodeForCurrentUser = require("FamilyCenterActionCreators").getLinkCodeForCurrentUser();
const obj = require("FamilyCenterActionCreators");
2026-07-20 16:05:17 +00:00
linkCodeForCurrentUser.then(() => {
if (sum === ref.current) {
require(false);
closure_1(true);
2026-07-20 16:05:17 +00:00
}
}).catch(() => {
if (sum === ref.current) {
const linkCodeExpiresAt = FamilyCenterStore.getLinkCodeExpiresAt();
if (null != FamilyCenterStore.getLinkCode()) {
2026-07-20 16:05:17 +00:00
if (null != linkCodeExpiresAt) {
const _Date = Date;
if (linkCodeExpiresAt > Date.now()) {
closure_1(true);
2026-07-20 16:05:17 +00:00
}
}
}
require(true);
2026-07-20 16:05:17 +00:00
}
});
}, []);
useMountEffectDefault(callback);
2026-07-20 16:05:17 +00:00
if (tmp3) {
let obj2 = { state: "error" };
2026-07-29 08:29:29 +00:00
} else if (tmp4[0]) {
2026-07-20 16:05:17 +00:00
if (null == linkCode) {
const obj3 = { state: "error" };
2026-07-20 16:05:17 +00:00
}
const obj4 = { state: "gate", linkCode, expiresAt, refresh: callback };
2026-07-20 16:05:17 +00:00
} else {
obj2 = { state: "loading" };
2026-07-20 16:05:17 +00:00
}
return obj2;
2026-07-20 16:05:17 +00:00
};