349 lines
15 KiB
TypeScript
349 lines
15 KiB
TypeScript
// Metro module 10507 (f10508).
|
|
import * as Module19 from "react";
|
|
import { useState, useEffect, useRef, useCallback, useLayoutEffect, useMemo } from "react";
|
|
import ChannelRTCStore from "../../../calls/ChannelRTCStore";
|
|
import ChannelStore from "../../../../stores/ChannelStore";
|
|
import { resetChannelCallStore, setVoiceChatDrawerState, useChannelCallOrientationHandlers, useChannelCallStore, useIsVoiceChatFocused } from "../ChannelCallStore";
|
|
import { VoiceChatDrawerState } from "../ChannelCallConstants";
|
|
import { PAN_GESTURE_FAIL_OFFSET_Y, SWIPE_TO_CHAT_ACTIVE_OFFSET } from "./Constants";
|
|
import { ModalAnimation } from "../../../../Constants";
|
|
import { useIsConnectedToVoiceChannel } from "../../../voice_chat/VoiceChatHooks";
|
|
import { useRevealProviderValue, RevealContext } from "./RevealProvider";
|
|
import * as _NavigationRouteUtils_native from "../../../main_tabs_v2/helpers/NavigationRouteUtils.native";
|
|
import CameraPreview from "./CameraPreview";
|
|
import ChannelCallModalManager from "./ChannelCallModalManager";
|
|
import StatusBar_android from "../../../status_bar/native/components/StatusBar.android";
|
|
import ChannelCallNavigator from "./ChannelCallNavigator";
|
|
import * as _ReanimatedRexport from "../../../reanimated/ReanimatedRexport";
|
|
import ReanimatedRexport, { useSharedValue, useDerivedValue, runOnUI, useAnimatedReaction, useAnimatedStyle } from "../../../reanimated/ReanimatedRexport";
|
|
import * as _ChatInputUtils from "../../../../utils/native/ChatInputUtils";
|
|
import * as _PanGestureAnimations from "../../../action_sheet/native/PanGestureAnimations";
|
|
import PanGestureAnimations from "../../../action_sheet/native/PanGestureAnimations";
|
|
import { useStateFromStores } from "../../../../_bundle/Module589";
|
|
import useWindowDimensions_native from "../../../screen/useWindowDimensions.native";
|
|
import useIsActivityFocused from "../../../activities/useIsActivityFocused";
|
|
import * as _RouteManagerUtils from "../../../routing/native/RouteManagerUtils";
|
|
import useAnalyticsLocations, { AnalyticsLocationProvider } from "../../../app_analytics/useAnalyticsLocations";
|
|
import AnalyticsLocation from "../../../app_analytics/AnalyticsLocation";
|
|
import useModalPanGesture from "./useModalPanGesture";
|
|
import { maybeShowAgeGateModal } from "../../../../utils/native/PrivateChannelCallUtils";
|
|
import { GestureDetector, Gesture } from "../../../../_bundle/Module5273";
|
|
import { VoiceChatNavigationContext } from "../../../voice_chat/native/VoiceChatModalContext";
|
|
let Component2, __initData, __initData2, __initData3, __initData4, __initData5, __initData6, __initData7, __initData8, __initData9, __initData10, __initData11, Component, ChannelCallModal;
|
|
const ChannelCallCameraPreview = function ChannelCallCameraPreview(props) {
|
|
const channel = props.channel;
|
|
const isVoiceChatFocused = useIsVoiceChatFocused();
|
|
const isConnectedToVoiceChannel = useIsConnectedToVoiceChannel(channel);
|
|
const revealProviderValue = useRevealProviderValue(useChannelCallStore((a0) => a0.focus), channel);
|
|
const isModalOpen = _NavigationRouteUtils_native.isModalOpen(ChannelCallModal);
|
|
return isConnectedToVoiceChannel ? <RevealContext.Provider value={revealProviderValue}>
|
|
<CameraPreview channel={channel} participantScreenIsFocused={!isVoiceChatFocused} isChannelCallModalOpen={isModalOpen} />
|
|
</RevealContext.Provider> : null;
|
|
};
|
|
ChannelCallModal = function ChannelCallModal(props) {
|
|
const channel = props.channel;
|
|
return <Component channelId={channel.id} guildId={channel.guild_id} />;
|
|
};
|
|
Component2 = Module19.memo(function({ channelId: channelId2 }) {
|
|
const [state] = useState(ChannelStore.getChannel(channelId2));
|
|
useChannelCallOrientationHandlers(state);
|
|
useEffect(() => {
|
|
if (state != null) {
|
|
ChannelCallModalManager.initialize(state);
|
|
return () => {
|
|
ChannelCallModalManager.terminate();
|
|
StatusBar_android.setHidden(false);
|
|
if (!_NavigationRouteUtils_native.isModalOpen(ChannelCallModal)) {
|
|
resetChannelCallStore();
|
|
}
|
|
};
|
|
}
|
|
}, [state]);
|
|
return state != null ? <ChannelCallNavigator channel={state} /> : null;
|
|
});
|
|
__initData = {
|
|
code: "function ChannelCallModalTsx1(){const{width}=this.__closure;return[0,-width];}"
|
|
};
|
|
__initData2 = {
|
|
code: "function ChannelCallModalTsx2(){const{runOnJS,dismissKeyboard}=this.__closure;runOnJS(dismissKeyboard)();}"
|
|
};
|
|
__initData3 = {
|
|
code: "function ChannelCallModalTsx3(){const{voiceChatDrawerStoreState}=this.__closure;return voiceChatDrawerStoreState;}"
|
|
};
|
|
__initData4 = {
|
|
code: "function ChannelCallModalTsx4(){const{translateX,width}=this.__closure;translateX.set(-width);}"
|
|
};
|
|
__initData5 = {
|
|
code: "function ChannelCallModalTsx5(){const{isSwipeToChatInProgress,translateX,width,voiceChatDrawerState,VoiceChatDrawerState}=this.__closure;const chatGestureFinished=!isSwipeToChatInProgress.get();const drawerIsInSettledPosition=translateX.get()===-width||translateX.get()===0;const chatOpen=voiceChatDrawerState.get()===VoiceChatDrawerState.OPEN;const chatClosed=voiceChatDrawerState.get()===VoiceChatDrawerState.CLOSED;if(chatGestureFinished&&drawerIsInSettledPosition){return translateX.get()===-width?VoiceChatDrawerState.OPEN:VoiceChatDrawerState.CLOSED;}else if(chatOpen&&translateX.get()>-width){return VoiceChatDrawerState.CLOSING;}else if(chatClosed&&translateX.get()<0){return VoiceChatDrawerState.OPENING;}else{return null;}}"
|
|
};
|
|
__initData6 = {
|
|
code: "function ChannelCallModalTsx6(state,previousState){const{runOnJS,setVoiceChatDrawerState,channelId,VoiceChatDrawerState,transitionToVoiceRoute,guildId}=this.__closure;if(state===previousState)return;if(state!=null&&state!==previousState){runOnJS(setVoiceChatDrawerState)(channelId,state);if(state===VoiceChatDrawerState.OPEN){runOnJS(transitionToVoiceRoute)(guildId,channelId);}}}"
|
|
};
|
|
__initData7 = {
|
|
code: "function ChannelCallModalTsx7(){const{voiceChatDrawerState}=this.__closure;return voiceChatDrawerState.get();}"
|
|
};
|
|
__initData8 = {
|
|
code: "function ChannelCallModalTsx8(drawerState,drawerStatePrev){const{VoiceChatDrawerState,translateX,withPanGestureTiming}=this.__closure;if(drawerState===VoiceChatDrawerState.CLOSED&&drawerStatePrev===VoiceChatDrawerState.OPEN){translateX.set(withPanGestureTiming(0));}}"
|
|
};
|
|
__initData9 = {
|
|
code: "function ChannelCallModalTsx9(){const{interpolate,translateY,maxVerticalTranslate}=this.__closure;return{flex:1,transform:[{translateY:interpolate(translateY.get(),[0,maxVerticalTranslate],[0,maxVerticalTranslate])}]};}"
|
|
};
|
|
__initData10 = {
|
|
code: "function ChannelCallModalTsx10(){const{immediate,translateX,width,withPanGestureTiming}=this.__closure;if(immediate===true){translateX.set(-width);}else{translateX.set(withPanGestureTiming(-width));}}"
|
|
};
|
|
__initData11 = {
|
|
code: "function ChannelCallModalTsx11(){const{translateX,withPanGestureTiming}=this.__closure;translateX.set(withPanGestureTiming(0));}"
|
|
};
|
|
Component = Module19.memo(function({ channelId, guildId }) {
|
|
let ref, ref2, ref3, ref4, sharedValue, sharedValue2, voiceChatDrawerState, derivedValue, width, sharedValue3, c18087_12, setState, current, ref5;
|
|
ref = void 0;
|
|
ref2 = void 0;
|
|
ref3 = void 0;
|
|
ref4 = void 0;
|
|
sharedValue = void 0;
|
|
sharedValue2 = void 0;
|
|
voiceChatDrawerState = void 0;
|
|
derivedValue = void 0;
|
|
width = void 0;
|
|
sharedValue3 = void 0;
|
|
c18087_12 = void 0;
|
|
setState = void 0;
|
|
current = void 0;
|
|
ref5 = void 0;
|
|
const stateFromStores = useStateFromStores([ChannelStore], () => ChannelStore.getChannel(channelId), [channelId]);
|
|
ref = useRef(void 0);
|
|
ref2 = useRef(void 0);
|
|
ref3 = useRef(void 0);
|
|
ref4 = useRef(void 0);
|
|
sharedValue = useSharedValue(0);
|
|
sharedValue2 = useSharedValue(0);
|
|
voiceChatDrawerState = useChannelCallStore().voiceChatDrawerState;
|
|
const r54 = () => voiceChatDrawerState;
|
|
r54.__closure = {
|
|
voiceChatDrawerStoreState: voiceChatDrawerState
|
|
};
|
|
r54.__workletHash = 4903837231689;
|
|
r54.__initData = __initData3;
|
|
derivedValue = useDerivedValue(r54);
|
|
const windowDimensions_native = useWindowDimensions_native();
|
|
width = windowDimensions_native.width;
|
|
const height = windowDimensions_native.height;
|
|
sharedValue3 = useSharedValue(false);
|
|
const maxTranslate = 0.8 * height;
|
|
c18087_12 = maxTranslate;
|
|
const isActivityFocused = useIsActivityFocused(channelId);
|
|
let state;
|
|
[state, setState] = useState(false);
|
|
const gestureEnabled = isActivityFocused ? !isActivityFocused : !(stateFromStores == null ? void 0 : stateFromStores.isGuildStageVoice());
|
|
current = {
|
|
channelId,
|
|
guildId
|
|
};
|
|
ref5 = useRef(current);
|
|
useEffect(() => {
|
|
ref5.current = current;
|
|
});
|
|
useEffect(() => {
|
|
const current2 = ref5.current;
|
|
const { channelId: channelId2, guildId: guildId2 } = current2;
|
|
if (useChannelCallStore.getState().voiceChatDrawerState === VoiceChatDrawerState.OPEN || ChannelRTCStore.getChatOpen(channelId2)) {
|
|
const r24 = function t() {
|
|
sharedValue.set(-width);
|
|
};
|
|
r24.__closure = {
|
|
translateX: sharedValue,
|
|
width
|
|
};
|
|
r24.__workletHash = 15726690166344;
|
|
r24.__initData = __initData4;
|
|
runOnUI(r24)();
|
|
_ReanimatedRexport.runOnJS(_RouteManagerUtils.transitionToVoiceRoute)(guildId2, channelId2);
|
|
}
|
|
}, [width, sharedValue]);
|
|
const analyticsLocations = useAnalyticsLocations(AnalyticsLocation.CHANNEL_CALL).analyticsLocations;
|
|
const ae = function ae() {
|
|
let OPEN2;
|
|
const r12 = sharedValue3.get();
|
|
const r15 = sharedValue.get() === -width || sharedValue.get() === 0;
|
|
L16: {
|
|
const r10 = derivedValue.get();
|
|
const OPEN = VoiceChatDrawerState.OPEN;
|
|
const r23 = derivedValue.get();
|
|
const CLOSED = VoiceChatDrawerState.CLOSED;
|
|
if (!r12 && r15) {
|
|
if (sharedValue.get() === -width) {
|
|
OPEN2 = VoiceChatDrawerState.OPEN;
|
|
break L16;
|
|
}
|
|
OPEN2 = VoiceChatDrawerState.CLOSED;
|
|
} else {
|
|
OPEN2 = r10 === OPEN && sharedValue.get() > -width ? VoiceChatDrawerState.CLOSING : r23 === CLOSED ? sharedValue.get() < 0 ? VoiceChatDrawerState.OPENING : null : null;
|
|
}
|
|
}
|
|
return OPEN2;
|
|
};
|
|
ae.__closure = {
|
|
isSwipeToChatInProgress: sharedValue3,
|
|
translateX: sharedValue,
|
|
width,
|
|
voiceChatDrawerState: derivedValue,
|
|
VoiceChatDrawerState
|
|
};
|
|
ae.__workletHash = 16786813095205;
|
|
ae.__initData = __initData5;
|
|
const te = function te(a0, a1) {
|
|
const r1 = a0 !== a1;
|
|
if ((r1 ? a0 != null : r1) && r1) {
|
|
_ReanimatedRexport.runOnJS(setVoiceChatDrawerState)(channelId, a0);
|
|
if (a0 === VoiceChatDrawerState.OPEN) {
|
|
_ReanimatedRexport.runOnJS(_RouteManagerUtils.transitionToVoiceRoute)(guildId, channelId);
|
|
}
|
|
}
|
|
};
|
|
te.__closure = {
|
|
runOnJS: _ReanimatedRexport.runOnJS,
|
|
setVoiceChatDrawerState,
|
|
channelId,
|
|
VoiceChatDrawerState,
|
|
transitionToVoiceRoute: _RouteManagerUtils.transitionToVoiceRoute,
|
|
guildId
|
|
};
|
|
te.__workletHash = 14188334620807;
|
|
te.__initData = __initData6;
|
|
useAnimatedReaction(ae, te);
|
|
const re = function re() {
|
|
return derivedValue.get();
|
|
};
|
|
re.__closure = {
|
|
voiceChatDrawerState: derivedValue
|
|
};
|
|
re.__workletHash = 14044794538420;
|
|
re.__initData = __initData7;
|
|
const ne = function ne(a0, a1) {
|
|
if (a0 === VoiceChatDrawerState.CLOSED && a1 === VoiceChatDrawerState.OPEN) {
|
|
sharedValue.set(_PanGestureAnimations.withPanGestureTiming(0));
|
|
}
|
|
};
|
|
ne.__closure = {
|
|
VoiceChatDrawerState,
|
|
translateX: sharedValue,
|
|
withPanGestureTiming: _PanGestureAnimations.withPanGestureTiming
|
|
};
|
|
ne.__workletHash = 260500087614;
|
|
ne.__initData = __initData8;
|
|
useAnimatedReaction(re, ne);
|
|
const r126 = state ? !state : !isActivityFocused;
|
|
const width2 = width;
|
|
const u = () => [0, -width2];
|
|
u.__closure = {
|
|
width
|
|
};
|
|
u.__workletHash = 15383459308604;
|
|
u.__initData = __initData;
|
|
const derivedValue2 = useDerivedValue(u);
|
|
const r137 = function c() {
|
|
_ReanimatedRexport.runOnJS(_ChatInputUtils.dismissKeyboard)();
|
|
};
|
|
r137.__closure = {
|
|
runOnJS: _ReanimatedRexport.runOnJS,
|
|
dismissKeyboard: _ChatInputUtils.dismissKeyboard
|
|
};
|
|
r137.__workletHash = 4086900686382;
|
|
r137.__initData = __initData2;
|
|
const r167 = PanGestureAnimations({
|
|
lowerBounds: -width,
|
|
upperBounds: 0,
|
|
translate: sharedValue,
|
|
vertical: false,
|
|
snapPositions: derivedValue2,
|
|
onStart: useCallback(r137, []),
|
|
isGestureInProgress: sharedValue3
|
|
}).enabled(r126).failOffsetY([-PAN_GESTURE_FAIL_OFFSET_Y, PAN_GESTURE_FAIL_OFFSET_Y]).activeOffsetX([-SWIPE_TO_CHAT_ACTIVE_OFFSET, SWIPE_TO_CHAT_ACTIVE_OFFSET]).withRef(ref);
|
|
const r177 = useModalPanGesture({
|
|
gestureEnabled,
|
|
height,
|
|
maxTranslate,
|
|
thresholdTranslate: 0.5 * height,
|
|
translateY: sharedValue2
|
|
}).withRef(ref4).requireExternalGestureToFail(ref3, ref2);
|
|
useLayoutEffect(() => {
|
|
maybeShowAgeGateModal(channelId);
|
|
}, [channelId]);
|
|
const oe = () => {
|
|
const r12 = sharedValue2.get();
|
|
return {
|
|
flex: 1,
|
|
transform: [{
|
|
translateY: _ReanimatedRexport.interpolate(r12, [0, c18087_12], [0, c18087_12])
|
|
}]
|
|
};
|
|
};
|
|
oe.__closure = {
|
|
interpolate: _ReanimatedRexport.interpolate,
|
|
translateY: sharedValue2,
|
|
maxVerticalTranslate: maxTranslate
|
|
};
|
|
oe.__workletHash = 8643926178558;
|
|
oe.__initData = __initData9;
|
|
const animatedStyle = useAnimatedStyle(oe);
|
|
const memo = useMemo(() => ({
|
|
memberListRef: ref3,
|
|
translateX: sharedValue,
|
|
swipeDismissRef: ref4,
|
|
swipeToChatRef: ref,
|
|
videoGridRef: ref2,
|
|
openChat: (a0) => {
|
|
_ChatInputUtils.dismissKeyboard();
|
|
_ReanimatedRexport.runOnJS(setVoiceChatDrawerState)(channelId, VoiceChatDrawerState.OPENING);
|
|
const n = function n() {
|
|
if (a0 === true) {
|
|
sharedValue.set(-width);
|
|
} else {
|
|
sharedValue.set(_PanGestureAnimations.withPanGestureTiming(-width));
|
|
}
|
|
};
|
|
n.__closure = {
|
|
immediate: a0,
|
|
translateX: sharedValue,
|
|
width,
|
|
withPanGestureTiming: _PanGestureAnimations.withPanGestureTiming
|
|
};
|
|
n.__workletHash = 16904415853957;
|
|
n.__initData = __initData10;
|
|
runOnUI(n)();
|
|
},
|
|
openVoice: () => {
|
|
_ReanimatedRexport.runOnJS(setVoiceChatDrawerState)(channelId, VoiceChatDrawerState.CLOSING);
|
|
_ChatInputUtils.dismissKeyboard();
|
|
const r23 = function t() {
|
|
sharedValue.set(_PanGestureAnimations.withPanGestureTiming(0));
|
|
};
|
|
r23.__closure = {
|
|
translateX: sharedValue,
|
|
withPanGestureTiming: _PanGestureAnimations.withPanGestureTiming
|
|
};
|
|
r23.__workletHash = 15753790715008;
|
|
r23.__initData = __initData11;
|
|
runOnUI(r23)();
|
|
},
|
|
setIsSwipeToChatDisabled: setState
|
|
}), [ref3, ref4, ref, ref2, sharedValue, width, channelId]);
|
|
return stateFromStores != null ? <AnalyticsLocationProvider value={analyticsLocations}>
|
|
<GestureDetector gesture={Gesture.Exclusive(r167, r177)}>
|
|
<ReanimatedRexport.View style={animatedStyle}>
|
|
<VoiceChatNavigationContext.Provider value={memo}>
|
|
<Component2 channelId={channelId} />
|
|
<ChannelCallCameraPreview channel={stateFromStores} />
|
|
</VoiceChatNavigationContext.Provider>
|
|
</ReanimatedRexport.View>
|
|
</GestureDetector>
|
|
</AnalyticsLocationProvider> : null;
|
|
});
|
|
ChannelCallModal.modalConfig = {
|
|
animation: ModalAnimation.SLIDE_UP,
|
|
shouldPersistUnderModals: true
|
|
};
|
|
export default ChannelCallModal;
|
|
export { ChannelCallCameraPreview };
|
|
export { ChannelCallModal };
|