100 lines
4.4 KiB
TypeScript
100 lines
4.4 KiB
TypeScript
// Metro module 10691 (f10692).
|
|
import { useCallback, useRef, useEffect, useMemo } from "react";
|
|
import * as _Module17 from "react-native";
|
|
import { StyleSheet, TouchableWithoutFeedback, View } from "react-native";
|
|
import ActionSheetStore from "../../../action_sheet/native/ActionSheetStore";
|
|
import ChannelRTCStore from "../../../calls/ChannelRTCStore";
|
|
import NativeMenuStore from "../../../native_menu/native/NativeMenuStore";
|
|
import ChannelStore from "../../../../stores/ChannelStore";
|
|
import RTCConnectionStore from "../../../../stores/RTCConnectionStore";
|
|
import useVoiceStateForRemoteSession from "../../../game_console/hooks/useVoiceStateForRemoteSession";
|
|
import { useStateFromStores } from "../../../../_bundle/Module589";
|
|
import { useVoiceChatNavigationContext } from "../../../voice_chat/native/VoiceChatModalContext";
|
|
import { navigateToVoiceChannel } from "../../../../utils/native/PrivateChannelCallUtils";
|
|
import { intl, t } from "../../../../intl/index.native";
|
|
import GlobalStatusContent from "./GlobalStatusContent";
|
|
import { useSharedValue } from "../../../reanimated/ReanimatedRexport";
|
|
import { useGlobalStatusIndicatorState } from "../useGlobalStatusIndicatorState";
|
|
const { NativeEventEmitter, NativeModules } = _Module17;
|
|
let c7185_15 = new NativeEventEmitter(NativeModules.DCDStatusBarOverlayViewManager);
|
|
const GlobalStatusIndicatorWrapper = (props) => {
|
|
let stateFromStores2, openVoice, callback, ref;
|
|
const onPress = props.onPress;
|
|
stateFromStores2 = void 0;
|
|
openVoice = void 0;
|
|
callback = void 0;
|
|
ref = void 0;
|
|
const voiceStateForRemoteSession = useVoiceStateForRemoteSession();
|
|
let c18196_1 = voiceStateForRemoteSession;
|
|
const stateFromStores = useStateFromStores([RTCConnectionStore], () => {
|
|
let r5 = c18196_1?.channelId;
|
|
if (r5 == null) {
|
|
r5 = RTCConnectionStore.getChannelId();
|
|
}
|
|
return r5;
|
|
}, [voiceStateForRemoteSession]);
|
|
stateFromStores2 = useStateFromStores([ChannelStore], () => ChannelStore.getChannel(stateFromStores), [stateFromStores]);
|
|
openVoice = useVoiceChatNavigationContext()?.openVoice;
|
|
callback = useCallback(() => {
|
|
if (stateFromStores2 != null) {
|
|
if (openVoice != null && ChannelRTCStore.getChatOpen(stateFromStores2.id)) {
|
|
openVoice();
|
|
} else {
|
|
navigateToVoiceChannel(stateFromStores2, "RTC Panel");
|
|
}
|
|
if (onPress != null) {
|
|
onPress();
|
|
}
|
|
}
|
|
}, [stateFromStores2, onPress, openVoice]);
|
|
ref = useRef(callback);
|
|
useEffect(() => {
|
|
ref.current = callback;
|
|
});
|
|
useEffect(() => {
|
|
let c26795_0 = c7185_15.addListener("StatusBarTapped", () => {
|
|
ref.current();
|
|
});
|
|
return () => {
|
|
if (c26795_0 != null) {
|
|
c26795_0.remove();
|
|
}
|
|
};
|
|
}, [stateFromStores]);
|
|
return <TouchableWithoutFeedback accessibilityRole={stateFromStores2 != null ? "button" : "text"} accessibilityHint={stateFromStores2 != null ? intl.string(t.GaCMgX) : void 0} onPress={callback}>
|
|
<View>
|
|
<GlobalStatusContent />
|
|
</View>
|
|
</TouchableWithoutFeedback>;
|
|
};
|
|
export default function GlobalStatusIndicator(a0) {
|
|
let height, c18197_4, stateFromStores3;
|
|
const { children, showWhenParticipantOnScreen = false, forceHide = false } = a0;
|
|
let c18197_1 = forceHide;
|
|
const onPress2 = a0.onPress;
|
|
height = void 0;
|
|
c18197_4 = void 0;
|
|
stateFromStores3 = void 0;
|
|
const globalStatusIndicatorState = useGlobalStatusIndicatorState(showWhenParticipantOnScreen);
|
|
const stateFromStores4 = useStateFromStores([ActionSheetStore], () => ActionSheetStore.getContent() != null);
|
|
const stateFromStores5 = useStateFromStores([NativeMenuStore], () => NativeMenuStore.isOpen());
|
|
height = globalStatusIndicatorState.height;
|
|
const r30 = globalStatusIndicatorState.isVisible && !forceHide;
|
|
c18197_4 = r30;
|
|
stateFromStores3 = stateFromStores4 || stateFromStores5;
|
|
return useMemo(() => <>
|
|
<View importantForAccessibility={stateFromStores3 ? "no-hide-descendants" : void 0} accessibilityElementsHidden={stateFromStores3} style={[StyleSheet.absoluteFill, {
|
|
marginTop: c18197_1 ? 0 : height,
|
|
overflow: "hidden"
|
|
}]}>{children}</View>
|
|
{c18197_4 ? <GlobalStatusIndicatorWrapper onPress={onPress2} /> : null}
|
|
</>, [children, stateFromStores3, r30, onPress2, height, forceHide]);
|
|
};
|
|
export function useGlobalStatusIndicatorHeightSharedValue(a0) {
|
|
const sharedValue = useSharedValue(a0.height);
|
|
useEffect(() => {
|
|
sharedValue.set(a0.height);
|
|
}, [a0.height, sharedValue]);
|
|
return sharedValue;
|
|
}
|