// Metro module 5874 (f5875). import ExperimentStore from "../modules/experiments/ExperimentStore"; import SearchMessageStore from "../modules/search/SearchMessageStore"; import ChannelStore from "./ChannelStore"; import GuildStore from "./GuildStore"; import PermissionStore from "./PermissionStore"; import SelectedChannelStore from "./SelectedChannelStore"; import SelectedGuildStore from "./SelectedGuildStore"; import UserStore from "./UserStore"; import { ChannelSections, ComponentActions } from "../Constants"; import { buildGuildStaticChannelId, isStaticChannelRoute } from "../modules/channel/ChannelConstants"; import { Permissions } from "../_bundle/Module505"; import { SidebarType } from "../modules/sidebar/SidebarActionTypes"; import { ComponentDispatch } from "../utils/ComponentDispatchUtils"; import SnowflakeUtils from "../utils/SnowflakeUtils"; import { isMobile } from "../_bundle/Module4426"; import Module589 from "../_bundle/Module589"; import Dispatcher from "../Dispatcher"; let isMembersOpen, isSummariesOpen, c3676_18, isProfileOpen, sidebars, guildSidebars, hasSearchState, searchContextId, setIsSearchSidebarOpen; const handlePermissionsChange = function handlePermissionsChange() { let r3; let r2 = false; let r5 = false; for (const key in sidebars) { r3 = r2; r5 = r3; const r18 = sidebars[key]; if (r18.type !== SidebarType.VIEW_THREAD) { const type = r18.type; const VIEW_CHANNEL = SidebarType.VIEW_CHANNEL; r2 = r3; if (type !== VIEW_CHANNEL) { continue; } } const channel = ChannelStore.getChannel(r18.channelId); const r31 = channel != null && PermissionStore.can(Permissions.VIEW_CHANNEL, channel); r2 = r3; if (!r31) { delete sidebars[key]; r2 = true; } } r3 = r2; r5 = r3; return r5; }; setIsSearchSidebarOpen = function setIsSearchSidebarOpen() { const r6 = searchContextId != null && SearchMessageStore.hasSearchState(searchContextId); if (r6 === hasSearchState) { return false; } hasSearchState = r6; }; isMembersOpen = false; isSummariesOpen = false; c3676_18 = false; isProfileOpen = true; sidebars = {}; guildSidebars = {}; hasSearchState = false; searchContextId = null; class ChannelSectionStore extends Module589.PersistedStore { static displayName = "ChannelSectionStore"; static persistKey = "ChannelSectionStore2"; initialize(a0) { if (a0 != null) { let isMembersOpen2 = a0.isMembersOpen; if (isMembersOpen2 == null) { isMembersOpen2 = false; } isMembersOpen = isMembersOpen2; let isSummariesOpen2 = a0.isSummariesOpen; if (isSummariesOpen2 == null) { isSummariesOpen2 = false; } isSummariesOpen = isSummariesOpen2; let isProfileOpen2 = a0.isProfileOpen; if (isProfileOpen2 == null) { isProfileOpen2 = true; } isProfileOpen = isProfileOpen2; let sidebars2 = a0.sidebars; if (sidebars2 == null) { sidebars2 = {}; } sidebars = sidebars2; let guildSidebars2 = a0.guildSidebars; if (guildSidebars2 == null) { guildSidebars2 = {}; } guildSidebars = guildSidebars2; } this.syncWith([SearchMessageStore], setIsSearchSidebarOpen); this.syncWith([PermissionStore], handlePermissionsChange); this.waitFor(ChannelStore, ExperimentStore, GuildStore, PermissionStore, SearchMessageStore, SelectedChannelStore, SelectedGuildStore, UserStore); } getState() { return { isMembersOpen, isSummariesOpen, isProfileOpen, sidebars, guildSidebars }; } getSection(a0, a1) { if (hasSearchState) { return ChannelSections.SEARCH; } const r1 = a0 == null; let r5 = null; if (!r1) { const isStaticChannelRoute2 = isStaticChannelRoute(a0); r5 = a0; if (isStaticChannelRoute2) { const guildId = SelectedGuildStore.getGuildId(); r5 = guildId == null ? null : buildGuildStaticChannelId(a0, guildId); } } return r5 != null && sidebars[r5] != null ? ChannelSections.SIDEBAR_CHAT : a1 && isProfileOpen ? ChannelSections.PROFILE : isSummariesOpen ? ChannelSections.SUMMARIES : isMembersOpen ? ChannelSections.MEMBERS : c3676_18 ? ChannelSections.CONVERSATIONS : ChannelSections.NONE; } getSidebarState(a0) { const r1 = a0 == null; let r5 = null; if (!r1) { const isStaticChannelRoute2 = isStaticChannelRoute(a0); r5 = a0; if (isStaticChannelRoute2) { const guildId = SelectedGuildStore.getGuildId(); r5 = guildId == null ? null : buildGuildStaticChannelId(a0, guildId); } } return r5 == null ? void 0 : sidebars[r5]; } getGuildSidebarState(a0) { return a0 == null ? void 0 : guildSidebars[a0]; } getCurrentSidebarChannelId(a0) { const r0 = a0 == null; let r5 = null; if (!r0) { const isStaticChannelRoute2 = isStaticChannelRoute(a0); r5 = a0; if (isStaticChannelRoute2) { const guildId = SelectedGuildStore.getGuildId(); r5 = guildId == null ? null : buildGuildStaticChannelId(a0, guildId); } } if (r5 == null) { return null; } if (hasSearchState) { return null; } const r16 = sidebars[r5]; return r16 == null ? null : r16.type !== SidebarType.VIEW_THREAD && r16.type !== SidebarType.VIEW_CHANNEL ? r16.type === SidebarType.VIEW_MOD_REPORT ? r16.channelId : null : r16.channelId; } getCurrentSidebarMessageId(a0) { let r37, details; const r2 = a0 == null; let r5 = null; if (!r2) { const isStaticChannelRoute2 = isStaticChannelRoute(a0); r5 = a0; if (isStaticChannelRoute2) { const guildId = SelectedGuildStore.getGuildId(); r5 = guildId == null ? null : buildGuildStaticChannelId(a0, guildId); } } if (r5 == null) { return null; } if (hasSearchState) { return null; } const r16 = sidebars[r5]; const r17 = r16 == null; let r18 = null; if (!r17) { if (r16.type !== SidebarType.VIEW_THREAD && r16.type !== SidebarType.VIEW_CHANNEL) { const type = r16.type; const VIEW_MOD_REPORT = SidebarType.VIEW_MOD_REPORT; r37 = null; if (type === VIEW_MOD_REPORT) { details = r16.details; r37 = details?.initialMessageId; } } else { details = r16.details; r37 = details?.initialMessageId; } r18 = r37; } return r18; } getCurrentSearchContextId() { return searchContextId; } } const channelSectionStore = new ChannelSectionStore(Dispatcher, { SIDEBAR_SET_SELECTED_SEARCH_CONTEXT: function handleSetSelectedSearchContext({ searchContextId: searchContextId2 }) { searchContextId = searchContextId2; const r8 = searchContextId2 != null && SearchMessageStore.hasSearchState(searchContextId); const r9 = hasSearchState; let r10 = false; if (r8 !== r9) { hasSearchState = r8; r10 = void 0; } return r10; }, CHANNEL_TOGGLE_MEMBERS_SECTION: function handleChannelToggleMembersSection() { if (hasSearchState) { ComponentDispatch.dispatch(ComponentActions.SEARCH_RESULTS_CLOSE); } const r19 = isSummariesOpen; if (r19) { const r20 = hasSearchState; let r21 = false; if (r20) { hasSearchState = false; r21 = true; } const channelId = SelectedChannelStore.getChannelId(); const r2 = channelId == null; let r25 = null; if (!r2) { const isStaticChannelRoute2 = isStaticChannelRoute(channelId); r25 = channelId; if (isStaticChannelRoute2) { const guildId = SelectedGuildStore.getGuildId(); r25 = guildId == null ? null : buildGuildStaticChannelId(channelId, guildId); } } if (r25 != null && r25 in sidebars) { delete sidebars[r25]; r21 = true; } isSummariesOpen = r21 ? r19 || !r19 : !r19; } const r37 = c3676_18; if (r37) { const r38 = hasSearchState; let r40 = false; if (r38) { hasSearchState = false; r40 = true; } const channelId2 = SelectedChannelStore.getChannelId(); const r45 = channelId2 == null; let r46 = null; if (!r45) { const isStaticChannelRoute3 = isStaticChannelRoute(channelId2); r46 = channelId2; if (isStaticChannelRoute3) { const guildId2 = SelectedGuildStore.getGuildId(); r46 = guildId2 == null ? null : buildGuildStaticChannelId(channelId2, guildId2); } } if (r46 != null && r46 in sidebars) { delete sidebars[r46]; r40 = true; } c3676_18 = r40 ? r37 || !r37 : !r37; } const r60 = isMembersOpen; const r61 = hasSearchState; let r63 = false; if (r61) { hasSearchState = false; r63 = true; } const channelId3 = SelectedChannelStore.getChannelId(); const r68 = channelId3 == null; let r69 = null; if (!r68) { const isStaticChannelRoute4 = isStaticChannelRoute(channelId3); r69 = channelId3; if (isStaticChannelRoute4) { const guildId3 = SelectedGuildStore.getGuildId(); r69 = guildId3 == null ? null : buildGuildStaticChannelId(channelId3, guildId3); } } if (r69 != null && r69 in sidebars) { delete sidebars[r69]; r63 = true; } isMembersOpen = r63 ? r60 || !r60 : !r60; }, USER_PROFILE_SIDEBAR_TOGGLE_SECTION: function handleUserProfileSidebarToggleSection() { if (!isProfileOpen) { ComponentDispatch.dispatch(ComponentActions.SEARCH_RESULTS_CLOSE); } const r18 = isProfileOpen; const r19 = hasSearchState; let r20 = false; if (r19) { hasSearchState = false; r20 = true; } const channelId = SelectedChannelStore.getChannelId(); const r2 = channelId == null; let r24 = null; if (!r2) { const isStaticChannelRoute2 = isStaticChannelRoute(channelId); r24 = channelId; if (isStaticChannelRoute2) { const guildId = SelectedGuildStore.getGuildId(); r24 = guildId == null ? null : buildGuildStaticChannelId(channelId, guildId); } } if (r24 != null && r24 in sidebars) { delete sidebars[r24]; r20 = true; } isProfileOpen = r20 ? r18 || !r18 : !r18; }, CHANNEL_TOGGLE_SUMMARIES_SECTION: function handleChannelToggleSummariesSection() { const r7 = isMembersOpen; if (r7) { const r5 = hasSearchState; let r0 = false; if (r5) { hasSearchState = false; r0 = true; } const channelId = SelectedChannelStore.getChannelId(); const r2 = channelId == null; let r14 = null; if (!r2) { const isStaticChannelRoute2 = isStaticChannelRoute(channelId); r14 = channelId; if (isStaticChannelRoute2) { const guildId = SelectedGuildStore.getGuildId(); r14 = guildId == null ? null : buildGuildStaticChannelId(channelId, guildId); } } if (r14 != null && r14 in sidebars) { delete sidebars[r14]; r0 = true; } isMembersOpen = r0 ? r7 || !r7 : !r7; } const r26 = c3676_18; if (r26) { const r27 = hasSearchState; let r29 = false; if (r27) { hasSearchState = false; r29 = true; } const channelId2 = SelectedChannelStore.getChannelId(); const r34 = channelId2 == null; let r35 = null; if (!r34) { const isStaticChannelRoute3 = isStaticChannelRoute(channelId2); r35 = channelId2; if (isStaticChannelRoute3) { const guildId2 = SelectedGuildStore.getGuildId(); r35 = guildId2 == null ? null : buildGuildStaticChannelId(channelId2, guildId2); } } if (r35 != null && r35 in sidebars) { delete sidebars[r35]; r29 = true; } c3676_18 = r29 ? r26 || !r26 : !r26; } const r49 = isSummariesOpen; const r50 = hasSearchState; let r52 = false; if (r50) { hasSearchState = false; r52 = true; } const channelId3 = SelectedChannelStore.getChannelId(); const r57 = channelId3 == null; let r58 = null; if (!r57) { const isStaticChannelRoute4 = isStaticChannelRoute(channelId3); r58 = channelId3; if (isStaticChannelRoute4) { const guildId3 = SelectedGuildStore.getGuildId(); r58 = guildId3 == null ? null : buildGuildStaticChannelId(channelId3, guildId3); } } if (r58 != null && r58 in sidebars) { delete sidebars[r58]; r52 = true; } isSummariesOpen = r52 ? r49 || !r49 : !r49; }, CHANNEL_TOGGLE_CONVERSATIONS_SECTION: function handleChannelToggleConversationsSection() { if (hasSearchState) { ComponentDispatch.dispatch(ComponentActions.SEARCH_RESULTS_CLOSE); } isMembersOpen = false; isSummariesOpen = false; const r3 = c3676_18; const r18 = hasSearchState; let r19 = false; if (r18) { hasSearchState = false; r19 = true; } const channelId = SelectedChannelStore.getChannelId(); const r2 = channelId == null; let r23 = null; if (!r2) { const isStaticChannelRoute2 = isStaticChannelRoute(channelId); r23 = channelId; if (isStaticChannelRoute2) { const guildId = SelectedGuildStore.getGuildId(); r23 = guildId == null ? null : buildGuildStaticChannelId(channelId, guildId); } } if (r23 != null && r23 in sidebars) { delete sidebars[r23]; r19 = true; } c3676_18 = r19 ? r3 || !r3 : !r3; }, CHANNEL_OPEN_CONVERSATIONS_SECTION: function handleChannelOpenConversationsSection() { const r1 = c3676_18; let r0 = !r1; if (!r1) { if (hasSearchState) { ComponentDispatch.dispatch(ComponentActions.SEARCH_RESULTS_CLOSE); } isMembersOpen = false; isSummariesOpen = false; c3676_18 = true; r0 = true; } return r0; }, SIDEBAR_VIEW_CHANNEL: function handleSidebarViewChannel({ sidebarType, baseChannelId, channelId, details }) { hasSearchState = false; const r1 = baseChannelId == null; let r6 = null; if (!r1) { const isStaticChannelRoute2 = isStaticChannelRoute(baseChannelId); r6 = baseChannelId; if (isStaticChannelRoute2) { const guildId = SelectedGuildStore.getGuildId(); r6 = guildId == null ? null : buildGuildStaticChannelId(baseChannelId, guildId); } } if (r6 == null) { return false; } const r21 = { type: sidebarType, channelId, details }; sidebars[r6] = sidebarType === SidebarType.VIEW_MOD_REPORT ? { ...r21, baseChannelId } : r21; return true; }, SIDEBAR_VIEW_GUILD: function handleSidebarViewGuild({ sidebarType, guildId, baseChannelId, details }) { hasSearchState = false; const r1 = baseChannelId == null; let baseChannelId2 = null; if (!r1) { const isStaticChannelRoute2 = isStaticChannelRoute(baseChannelId); baseChannelId2 = baseChannelId; if (isStaticChannelRoute2) { const guildId2 = SelectedGuildStore.getGuildId(); baseChannelId2 = guildId2 == null ? null : buildGuildStaticChannelId(baseChannelId, guildId2); } } let r19 = baseChannelId2 != null; if (r19) { guildSidebars[guildId] = { type: sidebarType, baseChannelId: baseChannelId2, guildId, details }; r19 = true; } return r19; }, SIDEBAR_CREATE_THREAD: function handleCreateThread({ parentChannelId, parentMessageId, location: location2 }) { hasSearchState = false; const r1 = parentChannelId == null; let r5 = null; if (!r1) { const isStaticChannelRoute2 = isStaticChannelRoute(parentChannelId); r5 = parentChannelId; if (isStaticChannelRoute2) { const guildId = SelectedGuildStore.getGuildId(); r5 = guildId == null ? null : buildGuildStaticChannelId(parentChannelId, guildId); } } if (r5 != null) { sidebars[r5] = { type: SidebarType.CREATE_THREAD, parentChannelId, parentMessageId, location: location2 }; } }, SIDEBAR_CLOSE: function handleCloseSidebar({ baseChannelId }) { const r1 = baseChannelId == null; let r9 = null; if (!r1) { const isStaticChannelRoute2 = isStaticChannelRoute(baseChannelId); r9 = baseChannelId; if (isStaticChannelRoute2) { const guildId = SelectedGuildStore.getGuildId(); r9 = guildId == null ? null : buildGuildStaticChannelId(baseChannelId, guildId); } } if (r9 != null) { delete sidebars[r9]; } }, SIDEBAR_CLOSE_GUILD: function handleGuildCloseSidebar({ guildId }) { let r7 = guildSidebars[guildId] != null; if (r7) { delete guildSidebars[guildId]; r7 = true; } return r7; }, CHANNEL_DELETE: function handleChannelDelete({ channel }) { let r4; const r5 = channel.id in sidebars; if (r5) { delete sidebars[channel.id]; return true; } let r3 = false; let r23 = false; for (const key in sidebars) { r4 = r3; r23 = r4; const r25 = sidebars[key]; const r2 = r25 != null && r25.type === SidebarType.VIEW_CHANNEL && r25.channelId === channel.id; r3 = r4; if (r2) { delete sidebars[key]; r3 = true; } } r4 = r3; r23 = r4; return r23; }, CHANNEL_SELECT: function handleChannelSelect() { if (isMobile && isMembersOpen) { isMembersOpen = false; isSummariesOpen = false; c3676_18 = false; } }, THREAD_CREATE: function handleThreadCreate({ channel }) { if (channel.ownerId === UserStore.getCurrentUser()?.id) { return false; } const r14 = sidebars[channel.parent_id]; if (r14 != null && r14.type === SidebarType.CREATE_THREAD && r14.parentMessageId === SnowflakeUtils.castChannelIdAsMessageId(channel.id)) { sidebars[channel.parent_id] = { type: SidebarType.VIEW_THREAD, channelId: channel.id }; } }, THREAD_DELETE: function handleThreadDelete({ channel }) { const r9 = sidebars[channel.parent_id]; if (r9 != null && r9.type === SidebarType.VIEW_THREAD && r9.channelId === channel.id) { delete sidebars[channel.parent_id]; return void 0; } return false; } }); export default channelSectionStore; export const MESSAGE_REQUESTS_BASE_CHANNEL_ID = "message_requests"; export function isViewChannelSidebar(a0) { return [SidebarType.VIEW_CHANNEL, SidebarType.VIEW_THREAD, SidebarType.VIEW_MESSAGE_REQUEST, SidebarType.VIEW_MOD_REPORT].includes(a0.type); }