/* Metro module 10915; source: modules/panels/isChannelFocused.native.tsx; dependencies: [57, 31, 4606, 6936, 7710, 4009, 4007, 4008, 4010, 2] */ import Module00057 from '../../by-id/module-00057.js'; /* Metro dependency 57 */ import UseChatLayout from '../chat/native/useChatLayout.tsx'; /* Metro dependency 4010 */ import ChannelRTCStore from '../calls/ChannelRTCStore.tsx'; /* Metro dependency 4606 */ import NavigationHistoryStore from '../main_tabs_v2/native/NavigationHistoryStore.tsx'; /* Metro dependency 6936 */ import VoicePanelStore from '../voice_panel/VoicePanelStore.tsx'; /* Metro dependency 7710 */ import * as FileImportTrackerModule from '../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */ import * as ReactModule from '../../by-id/module-00031-React.js'; /* Metro dependency 31 */ import * as RootNavigationRefNativeModule from '../main_tabs_v2/RootNavigationRef.native.tsx'; /* Metro dependency 4008 */ import * as UseChatLayoutModule from '../chat/native/useChatLayout.tsx'; /* Metro dependency 4010 */ import * as NavigationHistoryStoreModule from '../main_tabs_v2/native/NavigationHistoryStore.tsx'; /* Metro dependency 6936 */ function _fun83644(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#83644, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11101:6, offset: 0x01f22268, size: 257 bytes, params: 8, frame: 21 const env0_0 = require; const getFocusedChannelId2 = getFocusedChannelId; const isChannelFocused2 = isChannelFocused; const Object = global.Object; Object.defineProperty(exports, '__esModule', {value: true}); (FileImportTrackerModule).fileFinishedImporting('modules/panels/isChannelFocused.native.tsx'); exports.getFocusedChannelId = getFocusedChannelId2; exports.isChannelFocused = isChannelFocused2; exports.useIsChannelFocused = useIsChannelFocused; exports.isChannelFocusedForReadStateAck = isChannelFocusedForReadStateAck; function getFocusedChannelId() { // fn#83645, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11101:178, offset: 0x01f22369, size: 686 bytes, params: 1, frame: 21 var r1; var r3; var currentRoute; var coerceChannelRoute; var value5; var coerceGuildsRoute; var params; var value6; var moduleValue4; var coerceMainRoute; var routes; var value8; var moduleValue5; var state; var value10; var coerceTabsRoute; var value12; var moduleValue6; var value14; var value; const value2 = undefined; const rootNavigationRef = (RootNavigationRefNativeModule).getRootNavigationRef(); const getChatLayout = UseChatLayoutModule.getChatLayout; const isChatLockedOpen = Reflect.apply(getChatLayout, UseChatLayoutModule, []).isChatLockedOpen; if (rootNavigationRef != null) { if (rootNavigationRef.isReady()) { currentRoute = rootNavigationRef.getCurrentRoute(); value5 = (require(4007) /* metro dependency 4007: NavigationRouteUtilsNative */).coerceChannelRoute(currentRoute); if (value5 != null) { return value5.params.channelId; } if (isChatLockedOpen) { value = require(4007) /* metro dependency 4007: NavigationRouteUtilsNative */; value = value.coerceGuildsRoute(currentRoute); if (value != null) { params = value.params; return params == null ? value2 : params.channelId; } return value2; } return value2; } } if (env0_9 === null) { value6 = (importDefault(4009) /* metro dependency 4009: getInitialNavigationState */)(); moduleValue4 = require(4007) /* metro dependency 4007: NavigationRouteUtilsNative */; coerceMainRoute = moduleValue4.coerceMainRoute; if (value6 == null) { r1 = value2; } else { routes = value6.routes; r1 = routes == null ? value2 : routes[(value6 == null ? value2 : value6.index) ?? 0]; } value8 = Reflect.apply(coerceMainRoute, moduleValue4, [r1]); if (value8 != null) { moduleValue5 = require(4007) /* metro dependency 4007: NavigationRouteUtilsNative */; if (isChatLockedOpen) { coerceTabsRoute = moduleValue5.coerceTabsRoute; state = value8.state; if (state == null) { r3 = value2; } else { routes = state.routes; if (routes == null) { r3 = value2; } else { state = value8.state; r3 = routes[(state == null ? value2 : state.index) ?? 0]; } } value12 = Reflect.apply(coerceTabsRoute, moduleValue5, [r3]); if (value12 != null) { moduleValue6 = require(4007) /* metro dependency 4007: NavigationRouteUtilsNative */; coerceGuildsRoute = moduleValue6.coerceGuildsRoute; state = value12.state; value14 = Reflect.apply(coerceGuildsRoute, moduleValue6, [state == null || state.routes == null ? value2 : state.routes[(value12.state == null ? value2 : value12.state.index) ?? 0]]); r1 = value14 != null ? value14.params == null ? value2 : value14.params.channelId : value2; } else { r1 = value2; } } else { coerceChannelRoute = moduleValue5.coerceChannelRoute; state = value8.state; value10 = Reflect.apply(coerceChannelRoute, moduleValue5, [state == null || state.routes == null ? value2 : state.routes[(value8.state == null ? value2 : value8.state.index) ?? 0]]); r1 = value10 == null || value10.params == null ? value2 : value10.params.channelId; } } else { r1 = value2; } env0_9 = r1; } return env0_9; } function isChannelFocused() { // fn#83646, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11101:1251, offset: 0x01f22617, size: 21 bytes, params: 1, frame: 9 return getFocusedChannelId() != null; } function useIsChannelFocused() { // fn#83647, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11101:1490, offset: 0x01f2262c, size: 132 bytes, params: 1, frame: 16 const [property, env0_0] = Module00057(ReactModule.useState(function() { return isChannelFocused(); }), 2); ReactModule.useEffect(_fun83649, [(UseChatLayout)()]); ReactModule.useEffect(_fun83650, []); return property; function _fun83649() { // fn#83649, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11101:1619, offset: 0x01f226bf, size: 27 bytes, params: 1, frame: 11 env0_0(isChannelFocused()); } function _fun83650() { // fn#83650, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11101:1666, offset: 0x01f226da, size: 85 bytes, params: 1, frame: 14 var environment; let value = environment.__proto__; value = require(4008) /* metro dependency 4008: RootNavigationRefNative */; value = value.getRootNavigationRef(); if (value != null) { value.addListener('state', handleStateChange_83651); return _fun83652; } function handleStateChange_83651() { // fn#83651, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11101:1742, offset: 0x01f2272f, size: 27 bytes, params: 1, frame: 11 env1_0(isChannelFocused()); } function _fun83652() { // fn#83652, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11101:1818, offset: 0x01f2274a, size: 31 bytes, params: 1, frame: 13 const binding = env0_0; binding.removeListener('state', handleStateChange_83651); } } } function isChannelFocusedForReadStateAck(a0, a1) { // fn#83653, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11101:1912, offset: 0x01f22769, size: 127 bytes, params: 3, frame: 14 var lastFocusedTimestampForHistoryItem; const channelRTCStoreBinding = ChannelRTCStore; const getChatOpen = channelRTCStoreBinding.getChatOpen; if (Reflect.apply(getChatOpen, channelRTCStoreBinding, [a0])) { return true; } const state = VoicePanelStore.getState(); if (!state.isVoicePanelFullscreen()) { if (getFocusedChannelId() === a0) { return true; } if (a1 == null) { return false; } lastFocusedTimestampForHistoryItem = NavigationHistoryStore.getLastFocusedTimestampForHistoryItem(CHANNEL_PREFIX + a0); if (lastFocusedTimestampForHistoryItem == null) { return false; } if (lastFocusedTimestampForHistoryItem >= a1) { return true; } } return false; } } global.__d(_fun83644, 10915, [57, 31, 4606, 6936, 7710, 4009, 4007, 4008, 4010, 2]) /* metro module 10915, dependencies: [57, 31, 4606, 6936, 7710, 4009, 4007, 4008, 4010, 2] */;