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

78 lines
2.5 KiB
TypeScript
Raw Normal View History

2026-08-24 06:08:38 +00:00
// Module ID: 16763
// Function ID: 16764
2026-07-20 16:05:17 +00:00
// Name: useConnectGuardianGate
2026-08-24 06:08:38 +00:00
// Dependencies: [32, 19, 5301, 589, 5303, 4766, 2]
2026-07-20 16:05:17 +00:00
// Exports: useConnectGuardianGate
2026-08-24 06:08:38 +00:00
// Module 16763 (useConnectGuardianGate)
import initialize from "initialize" /* 589 */;
import useMountLayoutEffectDefault from "useMountLayoutEffect" /* 4766 */;
import closure_3 from "_slicedToArray" /* 32 */;
import closure_4 from "noop" /* 19 */;
import closure_5 from "freshTeenActivityWithMap" /* 5301 */;
2026-07-21 22:01:30 +00:00
2026-08-24 06:08:38 +00:00
require = arg1;
const result = require("set").fileFinishedImporting("modules/parent_tools/hooks/useConnectGuardianGate.tsx");
2026-07-20 16:05:17 +00:00
export const useConnectGuardianGate = function useConnectGuardianGate() {
2026-08-24 06:08:38 +00:00
let obj = initialize;
const items = [closure_5];
2026-07-29 08:29:29 +00:00
const stateFromStoresObject = obj.useStateFromStoresObject(items, () => ({ linkCode: store.getLinkCode(), expiresAt: store.getLinkCodeExpiresAt() }));
2026-07-20 16:05:17 +00:00
({ linkCode, expiresAt } = stateFromStoresObject);
2026-07-23 10:11:24 +00:00
[tmp3, require] = callback(React.useState(false), 2);
2026-07-29 08:29:29 +00:00
const tmp4 = callback(React.useState(() => {
const linkCodeExpiresAt = store.getLinkCodeExpiresAt();
let tmp2 = null != store.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 = React.useRef(0);
2026-07-23 10:11:24 +00:00
callback = React.useCallback(() => {
2026-07-20 16:05:17 +00:00
const sum = ref.current + 1;
ref.current = sum;
2026-07-23 10:11:24 +00:00
const callback = sum;
callback(false);
2026-08-24 06:08:38 +00:00
const linkCodeForCurrentUser = closure_1_0(ref[4]).getLinkCodeForCurrentUser();
const obj = closure_1_0(ref[4]);
2026-07-20 16:05:17 +00:00
linkCodeForCurrentUser.then(() => {
2026-08-24 06:08:38 +00:00
if (closure_0 === closure_1_2.current) {
2026-07-20 16:05:17 +00:00
sum(false);
2026-08-24 06:08:38 +00:00
closure_1_1(true);
2026-07-20 16:05:17 +00:00
}
}).catch(() => {
2026-08-24 06:08:38 +00:00
if (closure_0 === closure_1_2.current) {
const linkCodeExpiresAt = closure_2_5.getLinkCodeExpiresAt();
if (null != closure_2_5.getLinkCode()) {
2026-07-20 16:05:17 +00:00
if (null != linkCodeExpiresAt) {
const _Date = Date;
if (linkCodeExpiresAt > Date.now()) {
2026-08-24 06:08:38 +00:00
closure_1_1(true);
2026-07-20 16:05:17 +00:00
}
}
}
sum(true);
}
});
}, []);
2026-08-24 06:08:38 +00:00
useMountLayoutEffectDefault(callback);
2026-07-20 16:05:17 +00:00
if (tmp3) {
obj = { 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) {
obj = { state: "error" };
}
2026-08-24 06:08:38 +00:00
obj1 = { state: "gate", linkCode: null, expiresAt: null, refresh: null };
2026-07-29 08:29:29 +00:00
obj1[1] = linkCode;
obj1[2] = expiresAt;
obj1[3] = callback;
2026-07-20 16:05:17 +00:00
obj = obj1;
} else {
2026-07-29 08:29:29 +00:00
obj = { state: "loading" };
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return obj;
2026-07-20 16:05:17 +00:00
};