Files
discord-decomp/modules/age_assurance/hooks/useAgeVerificationMethodsV2.tsx
T
2026-11-01 12:12:55 +02:00

134 lines
3.7 KiB
TypeScript

// Metro module 6778 (f6779).
import _slicedToArray from "../../../_bundle/_slicedToArray";
import { useState, useRef, useCallback, useEffect } from "react";
import AgeVerificationStore from "../AgeVerificationStore";
import { fetchAgeVerificationMethodsV2 } from "../AgeVerificationMethodsV2";
import Dispatcher from "../../../Dispatcher";
let env4357 = {};
export function useAgeVerificationMethodsV2() {
let c15909_0;
let env15908 = {
$parent: env4357
};
const r13 = _slicedToArray(useState(() => {
let methodsV2 = AgeVerificationStore.methodsV2;
if (methodsV2 == null) {
methodsV2 = [];
}
return methodsV2;
}), 2);
const methods = r13[0];
env15908[0] = r13[1];
const r18 = _slicedToArray(useState(() => AgeVerificationStore.methodsV2 == null), 2);
const loading = r18[0];
env15908[1] = r18[1];
const r23 = _slicedToArray(useState(false), 2);
const error = r23[0];
env15908[2] = r23[1];
env15908[3] = useRef(true);
c15909_0 = void 0;
c15909_0 = async (c29841_0) => {
let c29841_3;
let c29841_4 = 0;
let c31438_0;
L18: {
L10: {
try {
c31438_0 = void 0;
if (!c29841_0 && AgeVerificationStore.methodsV2 != null) {
(0, env15908[0])(AgeVerificationStore.methodsV2);
(0, env15908[1])(false);
(0, env15908[2])(false);
break L10;
}
(0, env15908[1])(true);
(0, env15908[2])(false);
c29841_4 = 2;
c31438_0 = await fetchAgeVerificationMethodsV2();
Dispatcher.dispatch({
type: "AGE_VERIFICATION_METHODS_V2_LOAD_SUCCESS",
methods: c31438_0
});
if (env15908[3].current) {
(0, env15908[0])(c31438_0);
}
c29841_4 = 1;
c29841_4 = 0;
if (!env15908[3].current) {
break L18;
}
(0, env15908[1])(false);
break L18;
} catch ($e) {
const r27 = $e;
let r7 = r27;
c29841_3 = r27;
let r28 = c29841_4;
if (r28 !== 0) {
while (true) {
if (r28 === 1) {
try {
const r122 = c29841_3;
c29841_4 = 0;
if (env15908[3].current) {
(0, env15908[1])(false);
}
throw r122;
} catch (r120) {
r7 = r120;
c29841_3 = r120;
r28 = c29841_4;
if (r28 === 0) {
break;
}
}
} else {
try {
c29841_4 = 1;
if (env15908[3].current) {
(0, env15908[2])(true);
}
c29841_4 = 0;
if (!env15908[3].current) {
break L18;
}
(0, env15908[1])(false);
break L18;
} catch (r100) {
r7 = r100;
c29841_3 = r100;
r28 = c29841_4;
if (r28 === 0) {
break;
}
}
}
}
}
throw r7;
}
}
return void 0;
}
};
const callback = useCallback(function() {
return c15909_0.apply(this, arguments);
}, []);
env15908[4] = callback;
useEffect(() => {
env15908[3].current = true;
(0, env15908[4])(false);
return () => {
env15908[3].current = false;
};
}, [callback]);
return {
loading,
error,
methods,
refetch: useCallback(() => {
(0, env15908[4])(true);
}, [callback])
};
}