64 lines
1.7 KiB
TypeScript
64 lines
1.7 KiB
TypeScript
// Metro module 14935 (f14936).
|
|
import { useState, useEffect } from "react";
|
|
import { useNavigation } from "../../../_bundle/Module1481";
|
|
import { coerceGuildsRoute } from "../../main_tabs_v2/helpers/NavigationRouteUtils.native";
|
|
export function useDrawerOpen(r8 = true) {
|
|
let setState;
|
|
let c21466_0 = r8;
|
|
setState = void 0;
|
|
const navigation = useNavigation();
|
|
let state;
|
|
[state, setState] = useState(() => {
|
|
if (c21466_0) {
|
|
const state = navigation.getState();
|
|
const r3 = state == null;
|
|
let r18 = void 0;
|
|
if (!r3) {
|
|
const routes = state.routes;
|
|
const r19 = routes == null;
|
|
r18 = void 0;
|
|
if (!r19) {
|
|
let r7 = state?.index;
|
|
if (r7 == null) {
|
|
r7 = 0;
|
|
}
|
|
r18 = routes[r7];
|
|
}
|
|
}
|
|
const r21 = coerceGuildsRoute(r18);
|
|
return (r21 == null ? void 0 : r21.params?.drawerOpen) === true;
|
|
}
|
|
return false;
|
|
});
|
|
useEffect(() => {
|
|
const handleStateChange2 = function handleStateChange(a0) {
|
|
const state = a0.data.state;
|
|
const r3 = state == null;
|
|
let r15 = void 0;
|
|
if (!r3) {
|
|
const routes = state.routes;
|
|
const r16 = routes == null;
|
|
r15 = void 0;
|
|
if (!r16) {
|
|
let r7 = state?.index;
|
|
if (r7 == null) {
|
|
r7 = 0;
|
|
}
|
|
r15 = routes[r7];
|
|
}
|
|
}
|
|
const r18 = coerceGuildsRoute(r15);
|
|
if (r18 != null) {
|
|
setState(r18.params?.drawerOpen === true);
|
|
}
|
|
};
|
|
if (c21466_0) {
|
|
navigation.addListener("state", handleStateChange2);
|
|
return () => {
|
|
navigation.removeListener("state", handleStateChange2);
|
|
};
|
|
}
|
|
}, [navigation, r8]);
|
|
return state;
|
|
}
|