// Metro module 16192 (f16193). import AuthenticationStore from "../../stores/AuthenticationStore"; import ChannelStore from "../../stores/ChannelStore"; import GuildRoomStore from "./GuildRoomStore"; import AutomaticLifecycleManager from "../../lib/AutomaticLifecycleManager"; import GuildRoomsExperiment from "./GuildRoomsExperiment"; import { guildRoomDisconnect, guildRoomConnect, guildRoomLocalDisconnect, guildRoomToggleLayout } from "./GuildRoomActionCreators.native"; let c11610_7 = null; let c11610_8 = null; class GuildRoomManager extends AutomaticLifecycleManager { actions = { VOICE_STATE_UPDATES: (a0) => this.handleVoiceStateUpdates(a0), EMBEDDED_ACTIVITY_LAUNCH_SUCCESS: (a0) => this.handleEmbeddedActivityLaunchSuccess(a0) }; isExperimentEnabled(a0, a1) { return GuildRoomsExperiment.getCurrentConfig({ guildId: a0, location: a1 }).enabled; } async handleVoiceStateUpdates({ voiceStates }) { let r32; const _this = this; let c28271_0, voiceStates2, c28271_4; let c28271_5 = 0; let c30986_0, c30986_1, c30986_2, c30986_3, c30986_4, c30986_5, c30986_6; L52: { L51: { try { c30986_0 = void 0; c30986_1 = void 0; c30986_2 = void 0; c30986_3 = void 0; c30986_4 = void 0; c30986_5 = void 0; c30986_6 = void 0; voiceStates2 = voiceStates; const r44 = voiceStates[Symbol.iterator](); voiceStates2 = r44.next; c28271_0 = r44; while (true) { const r46 = voiceStates2; let r47 = c28271_0; const r17 = r47 === void 0 ? void 0 : (r32 = r46.call(r47)).done ? r47 = void 0 : r32.value; c28271_0 = r47; if (r47 === void 0) { break L52; } c28271_5 = 1; c30986_0 = r17; c30986_1 = c30986_0.userId; c30986_2 = c30986_0.guildId; c30986_3 = c30986_0.channelId; c30986_4 = c30986_0.sessionId; c30986_5 = c30986_0.oldChannelId; if (c30986_1 === AuthenticationStore.getId()) { if (c30986_4 === AuthenticationStore.getSessionId()) { if (c30986_3 !== c11610_7) { if (c11610_7 != null && c11610_8 != null && _this.isExperimentEnabled(c11610_8, "VOICE_STATE_UPDATE")) { await guildRoomDisconnect(c11610_8, c11610_7); loop29: while (true) { if (c30986_3 != null && c30986_2 != null) { c30986_6 = GuildRoomStore.getPendingPosition(); if (_this.isExperimentEnabled(c30986_2, "VOICE_STATE_UPDATE")) { guildRoomConnect(c30986_2, c30986_3, c30986_6); } } c11610_7 = c30986_3; c11610_8 = c30986_2; while (true) { c28271_5 = 0; const r192 = voiceStates2; let r193 = c28271_0; const r194 = r193 === void 0 ? void 0 : (r32 = r192.call(r193)).done ? r193 = void 0 : r32.value; c28271_0 = r193; if (r193 === void 0) { break L51; } c28271_5 = 1; c30986_0 = r194; c30986_1 = c30986_0.userId; c30986_2 = c30986_0.guildId; c30986_3 = c30986_0.channelId; c30986_4 = c30986_0.sessionId; c30986_5 = c30986_0.oldChannelId; if (c30986_1 === AuthenticationStore.getId()) { if (c30986_4 === AuthenticationStore.getSessionId()) { if (c30986_3 !== c11610_7) { if (c11610_7 != null && c11610_8 != null && _this.isExperimentEnabled(c11610_8, "VOICE_STATE_UPDATE")) { await guildRoomDisconnect(c11610_8, c11610_7); continue loop29; } continue loop29; } } } else if (c30986_5 != null && c30986_5 !== c30986_3) { guildRoomLocalDisconnect(c30986_1, c30986_5); } } } } else { if (c30986_3 != null && c30986_2 != null) { c30986_6 = GuildRoomStore.getPendingPosition(); if (_this.isExperimentEnabled(c30986_2, "VOICE_STATE_UPDATE")) { guildRoomConnect(c30986_2, c30986_3, c30986_6); } } c11610_7 = c30986_3; c11610_8 = c30986_2; } } } } else if (c30986_5 != null && c30986_5 !== c30986_3) { guildRoomLocalDisconnect(c30986_1, c30986_5); } c28271_5 = 0; } } catch ($e) { const r40 = $e; let r8 = r40; c28271_4 = r40; if (c28271_5 !== 0) { while (true) { try { const r284 = c28271_4; c28271_5 = 0; const r286 = c28271_0; if (r286 !== void 0 && typeof r286.return === "function") { try { r286.return(); } catch {} } throw r284; } catch (r282) { r8 = r282; c28271_4 = r282; if (c28271_5 === 0) { break; } } } } throw r8; } } return void 0; } } handleEmbeddedActivityLaunchSuccess(a0) { if (a0.channelId != null) { const channel = ChannelStore.getChannel(a0.channelId); if (channel != null && this.isExperimentEnabled(channel.guild_id, "EMBEDDED_ACTIVITY_LAUNCH_SUCCESS") && GuildRoomStore.isVisible(a0.channelId)) { guildRoomToggleLayout(a0.channelId, true); } } } } const guildRoomManager = new GuildRoomManager(); export default guildRoomManager;