// Metro module 5121 (f5122). import ChannelStore from "../../stores/ChannelStore"; import GuildChannelStore from "../../stores/GuildChannelStore"; import GuildMemberStore from "../../stores/GuildMemberStore"; import GuildRoleStore from "../../stores/GuildRoleStore"; import PermissionStore from "../../stores/PermissionStore"; import SelectedChannelStore from "../../stores/SelectedChannelStore"; import UserGuildSettingsStore from "../../stores/UserGuildSettingsStore"; import ImpersonateStore from "./ImpersonateStore"; import { AnalyticEvents, Permissions, Routes } from "../../Constants"; import { isStaticChannelRoute } from "../channel/ChannelConstants"; import AnalyticsUtils from "../../utils/AnalyticsUtils"; import { collectGuildAnalyticsMetadata } from "../app_analytics/AppAnalyticsUtils"; import { ImpersonateType } from "./ImpersonateTypes"; import Dispatcher from "../../Dispatcher"; import { transitionTo } from "../routing/router_utils"; function $mk75472($env) { return (a0) => $env[0].add(a0); } function $mk75473($env) { return (a0) => $env[0].delete(a0); } const updateImpersonating = function updateImpersonating(a0, a1) { const data = ImpersonateStore.getData(a0); const r0 = data != null && data.type === a1.type; L8: { if (r0) { AnalyticsUtils.track(AnalyticEvents.VIEW_AS_ROLES_SELECTED, { num_roles: Object.keys(data.roles).length, ...collectGuildAnalyticsMetadata(a0), is_viewing_as_member: data.type === ImpersonateType.NEW_MEMBER }); Dispatcher.dispatch({ type: "IMPERSONATE_UPDATE", guildId: a0, data: { ...data, ...a1 } }); const channelId = SelectedChannelStore.getChannelId(a0); const channel = ChannelStore.getChannel(channelId); if (channelId != null && isStaticChannelRoute(channelId)) { break L8; } if (!PermissionStore.can(Permissions.VIEW_CHANNEL, channel)) { const defaultChannel = GuildChannelStore.getDefaultChannel(a0); if (defaultChannel != null) { transitionTo(Routes.CHANNEL(a0, defaultChannel.id)); } } } } }; export function startImpersonating(a0, a1) { AnalyticsUtils.track(AnalyticEvents.VIEW_AS_ROLES_SELECTED, { num_roles: Object.keys(a1.roles).length, ...collectGuildAnalyticsMetadata(a0), is_viewing_as_member: a1.type === ImpersonateType.NEW_MEMBER }); Dispatcher.dispatch({ type: "IMPERSONATE_UPDATE", guildId: a0, data: a1 }); const channelId = SelectedChannelStore.getChannelId(a0); const channel = ChannelStore.getChannel(channelId); if (!(channelId != null && isStaticChannelRoute(channelId)) && !PermissionStore.can(Permissions.VIEW_CHANNEL, channel)) { const defaultChannel = GuildChannelStore.getDefaultChannel(a0); if (defaultChannel != null) { transitionTo(Routes.CHANNEL(a0, defaultChannel.id)); } } } export { updateImpersonating }; export function stopImpersonating(a0) { Dispatcher.dispatch({ type: "IMPERSONATE_STOP", guildId: a0 }); } export function updateImpersonatedChannels(a0, a1, a2) { let env14661; const r2 = env14661 = {}; const set = new Set(UserGuildSettingsStore.getOptedInChannels(a0)); env14661[0] = set; a1.forEach($mk75472(r2)); a2.forEach($mk75473(r2)); updateImpersonating(a0, { type: ImpersonateType.NEW_MEMBER, optInChannels: set }); } export function updateImpersonatedRoles(a0, a1) { (function optIntoPrivateChannelsForGrantedRolesForPreview(a0, a1) { let c25354_1 = [...GuildChannelStore.getSelectableChannelIds(a0), ...GuildChannelStore.getVocalChannelIds(a0)]; let c25354_2 = Array.from(a1); GuildChannelStore.addConditionalChangeListener(() => { const selfMember = GuildMemberStore.getSelfMember(a0); if (selfMember == null) { return false; } if (c25354_2.some((item) => !selfMember.roles.includes(item))) { return true; } const r10 = [...GuildChannelStore.getSelectableChannelIds(a0), ...GuildChannelStore.getVocalChannelIds(a0)].filter((item) => !c25354_1.includes(item)); if (r10.length > 0) { let env29464; const r30 = []; const r31 = env29464 = {}; const set = new Set(UserGuildSettingsStore.getOptedInChannels(a0)); env29464[0] = set; r10.forEach($mk75472(r31)); r30.forEach($mk75473(r31)); updateImpersonating(a0, { type: ImpersonateType.NEW_MEMBER, optInChannels: set }); } return false; }); })(a0, a1); const roles = {}; for (const item of GuildRoleStore.getManyRoles(a0, a1)) { roles[item.id] = item; } updateImpersonating(a0, { type: ImpersonateType.NEW_MEMBER, roles }); } export function updateImpersonatedData(a0, a1) { updateImpersonating(a0, { type: ImpersonateType.NEW_MEMBER, ...a1 }); }