Files
discord-decomp/_bundle/Module3951.js
T
2026-11-01 12:12:55 +02:00

69 lines
1.7 KiB
JavaScript

// Metro module 3951 (f3952).
import { useRef, useState, useCallback } from "react";
import { c } from "./Module3940";
useCallback;
export function useRive() {
let r28, r38, setHybridRef;
const r16 = c(4);
const ref = useRef(null);
const [riveViewRef, setState] = useState(null);
const ref2 = useRef(null);
if (r16[0] === Symbol.for("react.memo_cache_sentinel")) {
const t = (a0) => {
if (ref.current !== a0) {
ref.current = a0;
if (ref2.current) {
clearTimeout(ref2.current);
}
const promise = new Promise((resolve, c29248_0) => {
ref2.current = setTimeout(() => {
c29248_0(new Error("Rive view ready timeout"));
}, 5000);
});
Promise.race([a0 == null ? void 0 : a0.awaitViewReady(), promise]).then((result) => {
if (result === true) {
setState(a0);
} else {
console.warn("Rive view ready check returned false");
setState(null);
}
}).catch((error) => {
console.warn("Failed to initialize Rive view:", error);
setState(null);
}).finally(() => {
if (ref2.current) {
clearTimeout(ref2.current);
ref2.current = null;
}
});
}
};
r16[0] = t;
r28 = t;
} else {
r28 = r16[0];
}
if (r16[1] === Symbol.for("react.memo_cache_sentinel")) {
const r35 = {
f: r28
};
r16[1] = r35;
setHybridRef = r35;
} else {
setHybridRef = r16[1];
}
if (r16[2] !== riveViewRef) {
const r39 = {
riveRef: ref,
riveViewRef,
setHybridRef
};
r16[2] = riveViewRef;
r16[3] = r39;
r38 = r39;
} else {
r38 = r16[3];
}
return r38;
}