// Module ID: 12377 // Function ID: 12378 // Name: isChannelFocused // Dependencies: [32, 19, 4806, 7604, 4998, 4650, 4648, 4649, 4651, 558, 568, 2] // Exports: isChannelFocused, isChannelFocusedForReadStateAck // Module 12377 (isChannelFocused) import RootNavigationRef from "RootNavigationRef" /* 4649 */; import getInitialNavigationStateDefault from "getInitialNavigationState" /* 4650 */; import useChatLayout from "useChatLayout" /* 4651 */; import _slicedToArray from "module_32" /* 32 */; import noop from "module_19" /* 19 */; import ChannelRTCStore from "ChannelRTCStore" /* 4806 */; import NavigationHistoryStore from "NavigationHistoryStore" /* 7604 */; import VoicePanelStore from "VoicePanelStore" /* 4998 */; const require = globalThis.__r; const useChatLayoutDefault = useChatLayout; const NavigationRouteUtils = params(4648); require = fn; function getFocusedChannelId() { let params = require; let paramsResult3 = dependencyMap; const rootNavigationRef = RootNavigationRef.getRootNavigationRef(); const isChatLockedOpen = useChatLayout.getChatLayout().isChatLockedOpen; let tmp2 = null; if (null != rootNavigationRef) { if (rootNavigationRef.isReady()) { const currentRoute = rootNavigationRef.getCurrentRoute(); const coerceChannelRouteResult = NavigationRouteUtils.coerceChannelRoute(currentRoute); if (tmp2 != coerceChannelRouteResult) { return coerceChannelRouteResult.params.channelId; } else if (isChatLockedOpen) { const coerceGuildsRouteResult = NavigationRouteUtils.coerceGuildsRoute(currentRoute); let tmp6; if (tmp2 != coerceGuildsRouteResult) { const params2 = coerceGuildsRouteResult.params; let channelId; if (params2 != tmp2) { channelId = params2.channelId; } tmp6 = channelId; } return tmp6; } const paramsResult = NavigationRouteUtils; } } if (tmp2 !== c9) { return c9; } else { const tmp19 = getInitialNavigationStateDefault(); let routes2 = NavigationRouteUtils; let tmp8; if (tmp19 != tmp2) { const routes = tmp19.routes; if (routes != tmp2) { let num; if (tmp19 != tmp2) { num = tmp19.index; } if (num == tmp2) { num = 0; } tmp8 = routes[num]; } } let num2 = routes2.coerceMainRoute(tmp8); if (tmp2 == num2) { c9 = tmp9; } else { routes2 = NavigationRouteUtils; if (!isChatLockedOpen) { state = num2.state; let tmp10; if (state != tmp2) { const routes3 = state.routes; if (routes3 != tmp2) { const state2 = num2.state; let num3; if (state2 != tmp2) { num3 = state2.index; } if (num3 == tmp2) { num3 = 0; } tmp10 = routes3[num3]; } } const coerceChannelRouteResult1 = routes2.coerceChannelRoute(tmp10); if (tmp2 != coerceChannelRouteResult1) { const params3 = coerceChannelRouteResult1.params; let channelId1; if (params3 != tmp2) { channelId1 = params3.channelId; } tmp9 = channelId1; } } } const state3 = num2.state; let tmp13; if (state3 != tmp2) { const routes4 = state3.routes; if (routes4 != tmp2) { const state4 = num2.state; num2 = undefined; if (state4 != tmp2) { num2 = state4.index; } if (num2 == tmp2) { num2 = 0; } tmp13 = routes4[num2]; } } const coerceTabsRouteResult = routes2.coerceTabsRoute(tmp13); if (tmp2 != coerceTabsRouteResult) { params = NavigationRouteUtils.coerceGuildsRoute; routes2 = coerceTabsRouteResult.state; let tmp16; if (routes2 != tmp2) { routes2 = routes2.routes; if (routes2 != tmp2) { num2 = coerceTabsRouteResult.state; let num4; if (num2 != tmp2) { num4 = num2.index; } if (num4 == tmp2) { num4 = 0; } tmp16 = routes2[num4]; } } paramsResult3 = params(tmp16); if (tmp2 != paramsResult3) { params = paramsResult3.params; tmp2 = params == tmp2; paramsResult3 = undefined; if (!tmp2) { paramsResult3 = params.channelId; } tmp9 = paramsResult3; } const paramsResult2 = NavigationRouteUtils; } } } const CHANNEL_PREFIX = fn(7604).CHANNEL_PREFIX; let c9 = null; const ReactCompilerGating = fn(558); function isChannelFocused() { return null != getFocusedChannelId(); } const size = fn(2); const result = size.fileFinishedImporting("modules/panels/isChannelFocused.native.tsx"); export { getFocusedChannelId }; export { isChannelFocused }; export const useIsChannelFocused = ReactCompilerGating.isReactCompilerEnabled() ? (() => { const cResult = require("c").c(6); if (cResult[0] === Symbol.for("react.memo_cache_sentinel")) { const fn = function u() { return null != getFocusedChannelId(); }; cResult[0] = fn; let first = fn; } else { first = cResult[0]; } const tmp4 = _slicedToArray(noop.useState(first), 2); _require = tmp4[1]; const tmp5 = useChatLayoutDefault(); if (cResult[1] === Symbol.for("react.memo_cache_sentinel")) { const fn2 = function o() { closure_0(null != getFocusedChannelId()); }; cResult[1] = fn2; let tmp6 = fn2; } else { tmp6 = cResult[1]; } if (cResult[2] !== tmp5) { const items = [tmp5]; cResult[2] = tmp5; cResult[3] = items; let tmp7 = items; } else { tmp7 = cResult[3]; } const effect = obj2.useEffect(tmp6, tmp7); if (cResult[4] === Symbol.for("react.memo_cache_sentinel")) { const fn3 = function c() { const rootNavigationRef = closure_0(dependencyMap[7]).getRootNavigationRef(); if (null != rootNavigationRef) { function handleStateChange() { rootNavigationRef(null != getFocusedChannelId()); } rootNavigationRef.addListener("state", handleStateChange); return () => { rootNavigationRef.removeListener("state", handleStateChange); }; } const obj = closure_0(dependencyMap[7]); }; const items1 = []; cResult[4] = fn3; cResult[5] = items1; let tmp10 = items1; let tmp9 = fn3; } else { tmp9 = cResult[4]; tmp10 = cResult[5]; } const effect1 = obj2.useEffect(tmp9, tmp10); return tmp4[0]; }) : (() => { const tmp = _slicedToArray(noop.useState(() => null != getFocusedChannelId()), 2); closure_0 = tmp[1]; const items = [useChatLayoutDefault()]; const effect = noop.useEffect(() => { closure_0(null != getFocusedChannelId()); }, items); const effect1 = noop.useEffect(() => { function handleStateChange() { rootNavigationRef(null != getFocusedChannelId()); } const rootNavigationRef = closure_0(dependencyMap[7]).getRootNavigationRef(); if (null != rootNavigationRef) { rootNavigationRef.addListener("state", handleStateChange); return () => { rootNavigationRef.removeListener("state", handleStateChange); }; } const obj = closure_0(dependencyMap[7]); }, []); return tmp[0]; }); export const isChannelFocusedForReadStateAck = function isChannelFocusedForReadStateAck(channelId, arg1) { if (ChannelRTCStore.getChatOpen(channelId)) { return true; } else { state = VoicePanelStore.getState(); if (state.isVoicePanelFullscreen()) { return false; } else if (getFocusedChannelId() === channelId) { return true; } else { if (null != arg1) { const lastFocusedTimestampForHistoryItem = NavigationHistoryStore.getLastFocusedTimestampForHistoryItem(CHANNEL_PREFIX + channelId); if (null != lastFocusedTimestampForHistoryItem) { if (lastFocusedTimestampForHistoryItem >= arg1) { return true; } } } return false; } } };