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

116 lines
3.0 KiB
JavaScript

// Metro module 3966 (f3967).
import { useRef, useEffect, useCallback } from "react";
import { AppState } from "react-native";
export function useRivePlayback(a0, a1) {
let callback, callback2, callback3, callback4;
let c13759_0 = a0;
const { isReady, appStatePlaybackEnabled, shouldShortLoopForReducedMotion } = a1;
callback = void 0;
callback2 = void 0;
callback3 = void 0;
callback4 = void 0;
const ref = useRef(false);
const ref2 = useRef(AppState.currentState === "background");
const ref3 = useRef(false);
const ref4 = useRef(null);
const ref5 = useRef(false);
const ref6 = useRef(true);
useEffect(() => {
ref6.current = true;
return () => {
ref6.current = false;
};
}, []);
callback = useCallback(() => {
if (ref4.current != null) {
clearTimeout(ref4.current);
ref4.current = null;
}
}, []);
callback2 = useCallback(() => {
callback();
if (c13759_0 != null) {
c13759_0.pause();
}
ref.current = false;
}, [callback, a0]);
callback3 = useCallback(() => {
callback();
if (shouldShortLoopForReducedMotion) {
ref4.current = setTimeout(() => callback2(), 5000);
}
}, [callback, shouldShortLoopForReducedMotion, callback2]);
callback4 = useCallback(() => {
if (c13759_0 != null) {
c13759_0.play();
}
ref.current = true;
callback3();
}, [a0, callback3]);
const callback5 = useCallback(() => {
if (!ref5.current) {
ref5.current = true;
queueMicrotask(() => {
L7: {
ref5.current = false;
if (ref6.current) {
if (appStatePlaybackEnabled && ref2.current) {
ref3.current = true;
break L7;
}
if (c13759_0 != null) {
c13759_0.playIfNeeded();
}
ref.current = true;
callback3();
}
}
});
}
}, [appStatePlaybackEnabled, a0, callback3]);
useEffect(() => {
if (isReady) {
ref.current = true;
}
}, [isReady]);
useEffect(() => {
if (isReady) {
callback3();
return callback;
}
}, [isReady, callback3, callback]);
useEffect(() => {
if (appStatePlaybackEnabled) {
let c24902_0 = AppState.addEventListener("change", (a0) => {
if (a0 === "background") {
ref2.current = true;
let r14 = isReady;
if (isReady) {
r14 = ref.current;
}
if (r14) {
ref3.current = true;
callback2();
}
} else if (a0 === "active") {
ref2.current = false;
let r6 = isReady;
if (isReady) {
r6 = ref3.current;
}
if (r6) {
ref3.current = false;
callback4();
}
}
});
return () => c24902_0.remove();
}
}, [appStatePlaybackEnabled, isReady, callback4, callback2]);
return {
play: callback4,
pause: callback2,
playIfNeeded: callback5
};
}