Files
discord-decomp/modules/calls/ChannelRTCStore.tsx
T
2026-11-01 12:12:55 +02:00

1024 lines
32 KiB
TypeScript

// Metro module 4202 (f4203).
import _slicedToArray from "../../_bundle/_slicedToArray";
import EmbeddedActivitiesStore from "../activities/EmbeddedActivitiesStore";
import GameConsoleStore from "../game_console/GameConsoleStore";
import ApplicationStreamingStore from "../../stores/ApplicationStreamingStore";
import AuthenticationStore from "../../stores/AuthenticationStore";
import CallStore from "../../stores/CallStore";
import ChannelStore from "../../stores/ChannelStore";
import PresenceStore from "../../stores/PresenceStore";
import SelectedChannelStore from "../../stores/SelectedChannelStore";
import SpeakingStore from "../../stores/SpeakingStore";
import UserStore from "../../stores/UserStore";
import VideoStreamStore from "../../stores/VideoStreamStore";
import VoiceStateStore from "../../stores/VoiceStateStore";
import { ParticipantSelectionTypes, isStreamParticipant, ParticipantTypes } from "./CallConstants";
import { ChannelModes, AppContext, ChannelLayouts, ChannelTypes } from "../../Constants";
import Logger from "../debug/Logger";
import ChannelRTCParticipants, { ChannelRTCParticipantsIndexes } from "./ChannelRTCParticipants";
import Module12 from "../../_bundle/Module12";
import GuildVoiceRingingExperiment from "../voice_calls/GuildVoiceRingingExperiment";
import { decodeStreamKey, isStreamKey } from "../go_live/utils/StreamKeyUtils";
import Module589 from "../../_bundle/Module589";
import Dispatcher from "../../Dispatcher";
function $mk73790($env) {
return (a0, a1) => {
let r28, r66, r68, VOICE, id2;
const r7 = $env.$parent;
const r11 = r7[27];
let r10 = r11[a1];
if (r10 == null) {
const r26 = new ((0, r7[1])(r7[2][16]))(a1);
r11[a1] = r26;
r10 = r26;
}
L50: {
const r27 = $env;
r28 = a0;
if ((0, r27[0])(r10)) {
let r32 = r11[a1];
if (r32 == null) {
const r40 = new ((0, r7[1])(r7[2][16]))(a1);
r11[a1] = r40;
r32 = r40;
}
const r42 = r32.size();
const r43 = r32;
if (r42 !== 0) {
const r45 = Boolean;
const channel = r7[9].getChannel(a1);
if (!r45(channel == null ? void 0 : channel.isGuildVocalOrThread())) {
const r51 = r7[0];
const r52 = r7[2];
if (!(r43.size(r51(r52[16]).ChannelRTCParticipantsIndexes.STREAM) > 0 || r43.size(r51(r52[16]).ChannelRTCParticipantsIndexes.VIDEO) > 0 || r43.hasEmbeddedActivity())) {
r66 = r7[20];
VOICE = r66.VOICE;
} else {
r68 = r7[20];
VOICE = r68.VIDEO;
r66 = r68;
}
} else {
r68 = r7[20];
VOICE = r68.VIDEO;
r66 = r68;
}
if (VOICE === r66.VOICE) {
const r71 = r7[31];
const r72 = r71[a1];
const r74 = r72 == null ? void 0 : r72[r7[22].APP];
delete r7[30][a1];
if (r74 !== r7[19].HAVEN) {
delete r71[a1];
}
} else {
r7[30][a1] = VOICE;
}
}
let env24969 = {
$parent: r7
};
const id = r7[7].getId();
env24969[0] = id;
let r85 = r11[a1];
if (r85 == null) {
const r94 = new ((0, r7[1])(r7[2][16]))(a1);
r11[a1] = r94;
r85 = r94;
}
const r96 = r85.size();
const r97 = r85;
if (r96 !== 0 && r7[11].getVoiceChannelId() === a1) {
const r101 = r7[17];
r101.NONE;
const r16 = r7[0];
const r104 = r7[2];
const r111 = r97.toArray(r16(r104[16]).ChannelRTCParticipantsIndexes.STREAM).find($mk114472(r7));
if (r111 != null) {
(0, r7[1])(r104[18])(r111.type === r7[16].STREAM, "Impossible condition");
id2 = r111.id;
} else {
const r113 = r97.size();
id2 = id;
if (r113 !== 1) {
if (r97.size(r16(r104[16]).ChannelRTCParticipantsIndexes.VIDEO) === 1) {
id2 = (0, r7[3])(r97.toArray(r16(r104[16]).ChannelRTCParticipantsIndexes.VIDEO), 1)[0].id;
} else {
let r126 = r97.toArray().find((item) => item.type === env24969.$parent[16].USER && item.id !== env24969[0] && !item.ringing)?.id;
if (r126 == null) {
r126 = id;
}
id2 = r126;
}
}
}
const channel2 = r7[9].getChannel(a1);
if (channel2 != null) {
channel2.isDM();
}
const NONE = r101.NONE;
let r152 = r7[28][a1];
if (r152 == null) {
r152 = [NONE, r101.NONE];
}
const r158 = (0, r7[3])(r152, 1)[0];
const AUTO = r101.AUTO;
let r160 = r158;
if (r160 !== AUTO) {
const NONE2 = r101.NONE;
r160 = r158;
if (r158 !== NONE2) {
const participant = r97.getParticipant(r158);
r160 = participant == null || participant.type === r7[16].STREAM && r7[6].getActiveStreamForStreamKey(participant.id) == null ? r101.NONE : r158;
}
}
(0, r7[40])(a1, [r160, id2]);
r28 = true;
break L50;
}
(0, r7[40])(a1, null);
r28 = true;
}
}
return r28;
};
}
function $mk73791($env) {
return (a0) => a0.updateParticipant($env[0]);
}
function $mk114472($env) {
return (a0) => {
const r3 = $env;
return a0.type === r3[16].STREAM && r3[6].getActiveStreamForStreamKey(a0.id) != null;
};
}
let updateParticipant, getSelectedParticipantId2, setSelectedParticipantId, hasVideo, clearChannel, handleRebuildActiveChannels, handleEmbeddedActivityChange, c2422_23, c2422_24, c2422_26, c2422_27, c2422_28, c2422_29, c2422_30, c2422_31, c2422_32, c2422_33, c2422_34, c2422_35, c2422_36, c2422_45;
let env2422 = {};
const getParticipants2 = function getParticipants(a0) {
let r1 = c2422_27[a0];
if (r1 == null) {
const channelRTCParticipants = new ChannelRTCParticipants(a0);
c2422_27[a0] = channelRTCParticipants;
r1 = channelRTCParticipants;
}
return r1;
};
updateParticipant = function updateParticipant(a0) {
let env13935;
let env13936;
const r2 = env13935 = {};
env13935[0] = a0;
const r4 = env13936 = {
$parent: env2422
};
env13936[0] = $mk73791(r2);
return arguments[1].reduce($mk73790(r4), false);
};
getSelectedParticipantId2 = function getSelectedParticipantId(a0) {
const channel = ChannelStore.getChannel(a0);
if (channel != null) {
channel.isDM();
}
const NONE = ParticipantSelectionTypes.NONE;
let r11 = c2422_28[a0];
if (r11 == null) {
r11 = [NONE, ParticipantSelectionTypes.NONE];
}
return r11;
};
setSelectedParticipantId = function setSelectedParticipantId(a0, a1) {
if (c2422_29[a0] == null) {
c2422_29[a0] = {
gridDurationMs: 0,
focusDurationMs: 0,
toggleCount: 0,
lastUpdate: 0
};
}
const r9 = c2422_29[a0];
const lastUpdate = performance.now();
const r1 = c2422_28[a0] != null && _slicedToArray(c2422_28[a0], 1)[0] !== ParticipantSelectionTypes.NONE;
if (r9.lastUpdate > 0) {
const r12 = lastUpdate - r9.lastUpdate;
const r26 = r1 ? "focusDurationMs" : "gridDurationMs";
r9[r26] = r9[r26] + r12;
}
r9.lastUpdate = lastUpdate;
const r30 = c2422_28[a0] != null && _slicedToArray(c2422_28[a0], 1)[0] !== ParticipantSelectionTypes.NONE;
if (a1 == null) {
delete c2422_28[a0];
} else {
c2422_28[a0] = a1;
}
if (r30 !== (c2422_28[a0] != null && _slicedToArray(c2422_28[a0], 1)[0] !== ParticipantSelectionTypes.NONE)) {
const r51 = c2422_29[a0];
r51.toggleCount = r51.toggleCount + 1;
}
};
hasVideo = function hasVideo(a0) {
return a0.size.call(a0, ChannelRTCParticipantsIndexes.STREAM) > 0 || a0.size(ChannelRTCParticipantsIndexes.VIDEO) > 0 || a0.hasEmbeddedActivity();
};
clearChannel = function clearChannel(a0) {
delete c2422_27[a0];
delete c2422_28[a0];
delete c2422_30[a0];
delete c2422_31[a0];
};
handleRebuildActiveChannels = function handleRebuildActiveChannels() {
const r4 = [];
const channelId = SelectedChannelStore.getChannelId();
if (channelId != null) {
r4.push(channelId);
}
const voiceChannelId = SelectedChannelStore.getVoiceChannelId();
if (!(voiceChannelId == null || r4.includes(voiceChannelId))) {
r4.push(voiceChannelId);
}
const remoteSessionId = GameConsoleStore.getRemoteSessionId();
const voiceStateForSession = VoiceStateStore.getVoiceStateForSession(AuthenticationStore.getId(), remoteSessionId);
if (voiceStateForSession?.channelId != null) {
r4.push(voiceStateForSession?.channelId);
}
let env13937;
const r31 = (a0) => a0.rebuild();
Module12.difference(env2422[25], r4).forEach(clearChannel);
let r45 = Module12.difference(r4, env2422[25]);
env2422[25] = r4;
const r46 = env13937 = {
$parent: env2422
};
env13937[0] = r31;
if (r45 === void 0) {
r45 = r4;
}
return r45.reduce($mk73790(r46), false);
};
handleEmbeddedActivityChange = function handleEmbeddedActivityChange() {
let env13938;
const r1 = env13938 = {
$parent: env2422
};
env13938[0] = (a0) => a0.updateEmbeddedActivities();
return env2422[25].reduce($mk73790(r1), false);
};
const handleSpeaking = function handleSpeaking({ userId }) {
let env13940;
const r5 = env13940 = {
$parent: env2422
};
env13940[0] = (a0) => a0.updateParticipantSpeaking(userId);
return env2422[25].reduce($mk73790(r5), false);
};
const handleUserUpdate = function handleUserUpdate(a0) {
let env13941;
let env13942;
const id = a0.user.id;
const r2 = env13941 = {};
env13941[0] = id;
const r3 = env2422[25];
const r7 = env13942 = {
$parent: env2422
};
env13942[0] = $mk73791(r2);
if (r3 !== void 0) {
return r3.reduce($mk73790(r7), false);
}
};
const handleCallUpdate = function handleCallUpdate(a0) {
let env13943;
const r3 = [a0.channelId];
const r5 = env13943 = {
$parent: env2422
};
env13943[0] = (a0) => a0.rebuild();
return r3.reduce($mk73790(r5), false);
};
const handleChannelDelete = function handleChannelDelete(a0) {
const id = a0.channel.id;
delete c2422_34[id];
c2422_26.delete(id);
delete c2422_35[id];
delete c2422_27[id];
delete c2422_28[id];
delete c2422_30[id];
delete c2422_31[id];
};
const handleStreamClose = function handleStreamClose(a0) {
let env13944;
let env13945;
const r9 = decodeStreamKey(a0.streamKey);
const { channelId, ownerId } = r9;
const r12 = [channelId];
const r13 = env13944 = {};
env13944[0] = ownerId;
const r14 = env13945 = {
$parent: env2422
};
env13945[0] = $mk73791(r13);
return r12.reduce($mk73790(r14), false);
};
const logger = new Logger("ChannelRTCStore");
c2422_23 = logger;
logger.enableNativeLogger(true);
c2422_24 = Object.freeze([]);
env2422[25] = [];
c2422_26 = new Set();
c2422_27 = {};
c2422_28 = {};
c2422_29 = {};
c2422_30 = {};
c2422_31 = {};
c2422_32 = {};
c2422_33 = {};
c2422_34 = {};
c2422_35 = {};
c2422_36 = {};
class ChannelRTCStore extends Module589.PersistedStore {
static displayName = "ChannelRTCStore";
static persistKey = "ChannelRTCStore";
constructor() {
super(...arguments);
}
initialize(a0) {
this.waitFor(ApplicationStreamingStore, AuthenticationStore, CallStore, ChannelStore, EmbeddedActivitiesStore, GameConsoleStore, PresenceStore, SelectedChannelStore, SpeakingStore, UserStore, VideoStreamStore, VoiceStateStore);
this.syncWith([EmbeddedActivitiesStore], handleEmbeddedActivityChange);
this.syncWith([GameConsoleStore], handleRebuildActiveChannels);
if (a0?.voiceParticipantsHidden !== void 0) {
Object.assign(c2422_33, a0?.voiceParticipantsHidden);
}
}
getState() {
return {
voiceParticipantsHidden: c2422_33
};
}
getParticipantsVersion(a0) {
let r1 = c2422_27[a0];
if (r1 == null) {
const channelRTCParticipants = new ChannelRTCParticipants(a0);
c2422_27[a0] = channelRTCParticipants;
r1 = channelRTCParticipants;
}
return r1.version;
}
getParticipants(a0) {
let r4 = c2422_27[a0];
if (r4 == null) {
const channelRTCParticipants = new ChannelRTCParticipants(a0);
c2422_27[a0] = channelRTCParticipants;
r4 = channelRTCParticipants;
}
let r16 = r4.toArray();
if (r16 == null) {
r16 = c2422_24;
}
return r16;
}
getSpeakingParticipants(a0) {
let r5 = c2422_27[a0];
if (r5 == null) {
const channelRTCParticipants = new ChannelRTCParticipants(a0);
c2422_27[a0] = channelRTCParticipants;
r5 = channelRTCParticipants;
}
let r23 = r5.toArray(ChannelRTCParticipantsIndexes.SPEAKING);
if (r23 == null) {
r23 = c2422_24;
}
return r23;
}
getFilteredParticipants(a0) {
let r5 = c2422_27[a0];
if (r5 == null) {
const channelRTCParticipants = new ChannelRTCParticipants(a0);
c2422_27[a0] = channelRTCParticipants;
r5 = channelRTCParticipants;
}
const r16 = c2422_33[a0];
return r16 != null && r16 ? r5.toArray(ChannelRTCParticipantsIndexes.FILTERED) : r5.toArray(ChannelRTCParticipantsIndexes.NOT_POPPED_OUT);
}
getVideoParticipants(a0) {
let r5 = c2422_27[a0];
if (r5 == null) {
const channelRTCParticipants = new ChannelRTCParticipants(a0);
c2422_27[a0] = channelRTCParticipants;
r5 = channelRTCParticipants;
}
let r23 = r5.toArray(ChannelRTCParticipantsIndexes.VIDEO);
if (r23 == null) {
r23 = c2422_24;
}
return r23;
}
getStreamParticipants(a0) {
let r5 = c2422_27[a0];
if (r5 == null) {
const channelRTCParticipants = new ChannelRTCParticipants(a0);
c2422_27[a0] = channelRTCParticipants;
r5 = channelRTCParticipants;
}
let r23 = r5.toArray(ChannelRTCParticipantsIndexes.STREAM);
if (r23 == null) {
r23 = c2422_24;
}
return r23;
}
getActivityParticipants(a0) {
let r5 = c2422_27[a0];
if (r5 == null) {
const channelRTCParticipants = new ChannelRTCParticipants(a0);
c2422_27[a0] = channelRTCParticipants;
r5 = channelRTCParticipants;
}
let r23 = r5.toArray(ChannelRTCParticipantsIndexes.ACTIVITY);
if (r23 == null) {
r23 = c2422_24;
}
return r23;
}
getParticipant(a0, a1) {
let r3 = c2422_27[a0];
if (r3 == null) {
const channelRTCParticipants = new ChannelRTCParticipants(a0);
c2422_27[a0] = channelRTCParticipants;
r3 = channelRTCParticipants;
}
return r3.getParticipant(a1);
}
getUserParticipantCount(a0) {
let r4 = c2422_27[a0];
if (r4 == null) {
const channelRTCParticipants = new ChannelRTCParticipants(a0);
c2422_27[a0] = channelRTCParticipants;
r4 = channelRTCParticipants;
}
return r4.size() - r4.size.call(r4, ChannelRTCParticipantsIndexes.STREAM) - r4.size(ChannelRTCParticipantsIndexes.ACTIVITY);
}
getParticipantsOpen(a0) {
let r4 = c2422_32[a0];
if (r4 == null) {
r4 = true;
}
return r4;
}
getVoiceParticipantsHidden(a0) {
let r4 = c2422_33[a0];
if (r4 == null) {
r4 = false;
}
return r4;
}
getSelectedParticipantId(a0) {
const channel = ChannelStore.getChannel(a0);
if (channel != null) {
channel.isDM();
}
const NONE = ParticipantSelectionTypes.NONE;
let r14 = c2422_28[a0];
if (r14 == null) {
r14 = [NONE, ParticipantSelectionTypes.NONE];
}
let [r19, r20] = r14;
const NONE2 = ParticipantSelectionTypes.NONE;
let r22 = null;
if (r19 !== NONE2) {
if (r19 === ParticipantSelectionTypes.AUTO) {
r19 = r20 !== ParticipantSelectionTypes.NONE ? r20 !== ParticipantSelectionTypes.AUTO ? r20 : null : null;
}
r22 = r19;
}
return r22;
}
getSelectedParticipant(a0) {
const selectedParticipantId = this.getSelectedParticipantId(a0);
const r1 = selectedParticipantId == null;
let r11 = null;
if (!r1) {
let r4 = c2422_27[a0];
if (r4 == null) {
const channelRTCParticipants = new ChannelRTCParticipants(a0);
c2422_27[a0] = channelRTCParticipants;
r4 = channelRTCParticipants;
}
r11 = r4.getParticipant(selectedParticipantId);
}
return r11;
}
getSelectedParticipantStats(a0) {
const r8 = c2422_29[a0];
return r8 == null ? {} : {
view_mode_grid_duration_ms: Math.floor(r8.gridDurationMs),
view_mode_focus_duration_ms: Math.floor(r8.focusDurationMs),
view_mode_toggle_count: r8.toggleCount
};
}
getGuildRingingUsers(a0) {
let r1 = c2422_27[a0];
if (r1 == null) {
const channelRTCParticipants = new ChannelRTCParticipants(a0);
c2422_27[a0] = channelRTCParticipants;
r1 = channelRTCParticipants;
}
return r1.guildRingingUsers;
}
getMode(a0) {
let r8 = c2422_30[a0];
if (r8 == null) {
const r5 = Boolean;
const channel = ChannelStore.getChannel(a0);
r8 = r5(channel == null ? void 0 : channel.isGuildVocalOrThread()) ? ChannelModes.VIDEO : ChannelModes.VOICE;
}
return r8;
}
getLayout(a0) {
if (arguments[1] === void 0) {
AppContext.APP;
}
return ChannelLayouts.NORMAL;
}
getChatOpen(a0) {
let r4 = c2422_34[a0];
if (r4 == null) {
r4 = false;
}
return r4;
}
getAllChatOpen() {
return c2422_34;
}
getOpenChatChannelIds() {
return c2422_26;
}
isFullscreenInContext(r3 = AppContext.APP) {
const APP = r3;
return Object.values(c2422_31).some((item) => item[APP] === ChannelLayouts.FULL_SCREEN);
}
getStageStreamSize(a0) {
return c2422_35[a0];
}
getStageVideoLimitBoostUpsellDismissed(a0) {
return c2422_36[a0];
}
isParticipantPoppedOut(a0, a1) {
const participant = this.getParticipant(a0, a1);
return participant != null && ("isPoppedOut" in participant && participant.isPoppedOut);
}
}
c2422_45 = ChannelRTCStore;
const r182 = new ChannelRTCStore(Dispatcher, {
CONNECTION_OPEN: function handleConnectionOpen() {
for (const item of env2422[25]) {
clearChannel(item);
}
handleRebuildActiveChannels();
},
CONNECTION_OPEN_SUPPLEMENTAL: handleRebuildActiveChannels,
THREAD_LIST_SYNC: handleRebuildActiveChannels,
OVERLAY_INITIALIZE: handleRebuildActiveChannels,
VOICE_CHANNEL_SELECT: function handleVoiceChannelSelect({ channelId, currentVoiceChannelId }) {
let c13947_0;
c13947_0 = void 0;
if (channelId != null) {
delete c2422_29[channelId];
} else if (currentVoiceChannelId != null) {
delete c2422_34[currentVoiceChannelId];
c2422_26.delete(currentVoiceChannelId);
delete c2422_35[currentVoiceChannelId];
if (c2422_29[currentVoiceChannelId] == null) {
c2422_29[currentVoiceChannelId] = {
gridDurationMs: 0,
focusDurationMs: 0,
toggleCount: 0,
lastUpdate: 0
};
}
const r25 = c2422_29[currentVoiceChannelId];
const lastUpdate = performance.now();
const r30 = c2422_28[currentVoiceChannelId] != null && _slicedToArray(c2422_28[currentVoiceChannelId], 1)[0] !== ParticipantSelectionTypes.NONE;
if (r25.lastUpdate > 0) {
const r13 = lastUpdate - r25.lastUpdate;
const r40 = r30 ? "focusDurationMs" : "gridDurationMs";
r25[r40] = r25[r40] + r13;
}
r25.lastUpdate = lastUpdate;
}
let r46 = false;
if (channelId !== currentVoiceChannelId) {
const r4 = currentVoiceChannelId != null;
r46 = false;
if (r4) {
let r48 = c2422_27[currentVoiceChannelId];
if (r48 == null) {
const channelRTCParticipants = new ChannelRTCParticipants(currentVoiceChannelId);
c2422_27[currentVoiceChannelId] = channelRTCParticipants;
r48 = channelRTCParticipants;
}
let env13948;
c13947_0 = r48;
r48.guildRingingUsers.forEach((guildRingingUser) => c13947_0.updateGuildRingingUsers(guildRingingUser, false));
const r60 = [currentVoiceChannelId];
const r61 = env13948 = {
$parent: env2422
};
env13948[0] = (a0) => a0.rebuild();
r46 = r60.reduce($mk73790(r61), false);
}
}
const r66 = handleRebuildActiveChannels();
if (!r46) {
r46 = r66;
}
return r46;
},
CHANNEL_SELECT: function handleChannelSelect({ channelId, messageId }) {
const r9 = handleRebuildActiveChannels();
if (channelId == null) {
return r9;
}
if (messageId == null) {
return r9;
}
if (c2422_34[channelId]) {
return r9;
}
const channel = ChannelStore.getChannel(channelId);
let r13 = r9;
if (channel != null) {
const isGuildVocal = channel.isGuildVocal();
let r16 = r9;
if (isGuildVocal) {
c2422_34[channelId] = true;
c2422_26.add(channelId);
r16 = true;
}
r13 = r16;
}
return r13;
},
CHANNEL_RTC_ACTIVE_CHANNELS: handleRebuildActiveChannels,
VOICE_STATE_UPDATES: function handleVoiceStateUpdates({ voiceStates, initial }) {
return voiceStates.reduce((acc, { userId: userId2, channelId, guildId }) => {
let r38;
if (guildId != null && channelId != null) {
if (GuildVoiceRingingExperiment.getCurrentConfig({
guildId,
location: "voice_status_update"
}, {
autoTrackExposure: false
}).enabled) {
let r22 = c2422_27[channelId];
if (r22 == null) {
const channelRTCParticipants = new ChannelRTCParticipants(channelId);
c2422_27[channelId] = channelRTCParticipants;
r22 = channelRTCParticipants;
}
r22.updateGuildRingingUsers(userId2, false);
}
}
L15: {
if (initial && channelId != null) {
const r37 = env2422[25].includes(channelId);
r38 = acc;
if (!r37) {
break L15;
}
}
let env24970;
let env24971;
const r39 = env2422;
const r40 = env24970 = {};
env24970[0] = userId2;
let r41 = env2422[25];
const r42 = env24971 = {
$parent: r39
};
env24971[0] = $mk73791(r40);
if (r41 === void 0) {
r41 = env2422[25];
}
r38 = r41.reduce($mk73790(r42), false) || acc;
}
return r38;
}, false);
},
CHANNEL_CREATE: function handleChannelCreate({ channel }) {
if (channel.type === ChannelTypes.GROUP_DM) {
const originChannelId = channel.originChannelId;
if (originChannelId != null) {
const id = channel.id;
const APP2 = AppContext.APP;
const r8 = c2422_31[originChannelId];
let r15 = r8 == null ? void 0 : r8[AppContext.APP];
if (r15 == null) {
r15 = ChannelLayouts.NORMAL;
}
const r18 = {};
r18[APP2] = r15;
c2422_31[id] = r18;
return true;
}
}
return false;
},
CHANNEL_DELETE: handleChannelDelete,
THREAD_DELETE: handleChannelDelete,
CALL_CREATE: handleCallUpdate,
CALL_UPDATE: handleCallUpdate,
CALL_DELETE: function handleCallDelete({ channelId }) {
delete c2422_27[channelId];
delete c2422_28[channelId];
delete c2422_30[channelId];
delete c2422_31[channelId];
},
CHANNEL_RTC_SELECT_PARTICIPANT: function handleSelectParticipant({ channelId, id }) {
const participants2 = getParticipants2(channelId);
let c13950_0 = participants2;
if (id == null) {
participants2.toArray(ChannelRTCParticipantsIndexes.STREAM).forEach((item) => {
if ((0, isStreamParticipant)(item)) {
c13950_0.updateParticipant(item.user.id);
}
});
}
const [, r27] = getSelectedParticipantId2(channelId);
let r29 = id;
if (r29 == null) {
r29 = ParticipantSelectionTypes.NONE;
}
setSelectedParticipantId(channelId, [r29, r27]);
if (isStreamKey(id)) {
try {
const ownerId = decodeStreamKey(id).ownerId;
if (ownerId === AuthenticationStore.getId()) {
updateParticipant(ownerId, [channelId]);
}
} catch ($e) {
c2422_23.warn(`INVALID STREAM KEY FORMAT ${id}`, $e);
}
if (!hasVideo(participants2)) {
c2422_32[channelId] = false;
}
}
},
CHANNEL_RTC_POPOUT_PARTICIPANT: function handlePopOutParticipant({ channelId, participantId }) {
const channel = ChannelStore.getChannel(channelId);
if (channel != null) {
channel.isDM();
}
const NONE = ParticipantSelectionTypes.NONE;
let r19 = c2422_28[channelId];
if (r19 == null) {
r19 = [NONE, ParticipantSelectionTypes.NONE];
}
if (_slicedToArray(r19, 1)[0] === participantId) {
setSelectedParticipantId(channelId, null);
}
let r28 = c2422_27[channelId];
if (r28 == null) {
const channelRTCParticipants = new ChannelRTCParticipants(channelId);
c2422_27[channelId] = channelRTCParticipants;
r28 = channelRTCParticipants;
}
const participant = r28.getParticipant(participantId);
if (participant != null && participant.type !== ParticipantTypes.ACTIVITY) {
let env13951;
let env13952;
r28.updateParticipantPoppedOut(participantId, true);
const id = participant.user.id;
const r47 = [channelId];
const r48 = env13951 = {};
env13951[0] = id;
const r49 = env13952 = {
$parent: env2422
};
env13952[0] = $mk73791(r48);
r47.reduce($mk73790(r49), false);
}
},
CHANNEL_RTC_RETURN_PARTICIPANT: function handleReturnParticipant({ channelId, participantId }) {
let r6 = c2422_27[channelId];
if (r6 == null) {
const channelRTCParticipants = new ChannelRTCParticipants(channelId);
c2422_27[channelId] = channelRTCParticipants;
r6 = channelRTCParticipants;
}
r6.updateParticipantPoppedOut(participantId, false);
const participant = r6.getParticipant(participantId);
if (participant != null && participant.type !== ParticipantTypes.ACTIVITY) {
let env13953;
let env13954;
const id = participant.user.id;
const r30 = [channelId];
const r31 = env13953 = {};
env13953[0] = id;
const r32 = env13954 = {
$parent: env2422
};
env13954[0] = $mk73791(r31);
r30.reduce($mk73790(r32), false);
}
},
CHANNEL_RTC_UPDATE_LAYOUT: function handleCallLayout({ channelId, layout, appContext }) {
const r10 = {
...c2422_31[channelId]
};
r10[appContext] = layout;
c2422_31[channelId] = r10;
},
CHANNEL_RTC_UPDATE_PARTICIPANTS_OPEN: function handleUpdateParticipantsOpen(a0) {
c2422_32[a0.channelId] = a0.participantsOpen;
},
CHANNEL_RTC_UPDATE_VOICE_PARTICIPANTS_HIDDEN: function handleUpdateVoiceParticipantsHidden(a0) {
c2422_33[a0.channelId] = a0.voiceParticipantsHidden;
},
CHANNEL_RTC_UPDATE_STAGE_STREAM_SIZE: function handleUpdateStageStreamSize(a0) {
c2422_35[a0.channelId] = a0.large;
},
CHANNEL_RTC_UPDATE_STAGE_VIDEO_LIMIT_BOOST_UPSELL_DISMISSED: function handleUpdateStageVideoLimitBoostUpsellDismissed(a0) {
c2422_36[a0.channelId] = a0.dismissed;
},
STREAM_UPDATE_SELF_HIDDEN: function handleUpdateSelfStreamHidden({ channelId, selfStreamHidden }) {
const id = AuthenticationStore.getId();
if (selfStreamHidden) {
const channel = ChannelStore.getChannel(channelId);
if (channel != null) {
channel.isDM();
}
const NONE = ParticipantSelectionTypes.NONE;
let r18 = c2422_28[channelId];
if (r18 == null) {
r18 = [NONE, ParticipantSelectionTypes.NONE];
}
const [r23] = r18;
if (isStreamKey(r23) && r23.includes(id)) {
setSelectedParticipantId(channelId, null);
}
}
let env13955;
let env13956;
const r34 = [channelId];
const r35 = env13955 = {};
env13955[0] = id;
const r36 = env13956 = {
$parent: env2422
};
env13956[0] = $mk73791(r35);
r34.reduce($mk73790(r36), false);
},
CHANNEL_RTC_UPDATE_CHAT_OPEN: function handleUpdateChatOpen({ channelId, chatOpen }) {
c2422_34[channelId] = chatOpen;
if (chatOpen) {
c2422_26.add(channelId);
} else {
c2422_26.delete(channelId);
}
},
RTC_CONNECTION_VIDEO: function handleRTCConnectionVideo({ channelId, userId: userId2 }) {
let env13957;
let env13958;
const r3 = [channelId];
const r5 = env13957 = {};
env13957[0] = userId2;
const r6 = env13958 = {
$parent: env2422
};
env13958[0] = $mk73791(r5);
return r3.reduce($mk73790(r6), false);
},
RTC_CONNECTION_PLATFORM: function handleRTCConnectionPlatform({ channelId, userId: userId2 }) {
let env13959;
let env13960;
const r3 = [channelId];
const r5 = env13959 = {};
env13959[0] = userId2;
const r6 = env13960 = {
$parent: env2422
};
env13960[0] = $mk73791(r5);
return r3.reduce($mk73790(r6), false);
},
AUDIO_SET_LOCAL_VIDEO_DISABLED: function handleMediaEngineSetLocalVideoDisabled({ userId: userId2 }) {
let env13961;
let env13962;
const r2 = env13961 = {};
env13961[0] = userId2;
const r3 = env2422[25];
const r6 = env13962 = {
$parent: env2422
};
env13962[0] = $mk73791(r2);
if (r3 !== void 0) {
return r3.reduce($mk73790(r6), false);
}
},
MEDIA_ENGINE_VIDEO_SOURCE_QUALITY_CHANGED: function handleVideoSourceQuality({ channelId, senderUserId, maxResolution, maxFrameRate }) {
let env13964;
const r7 = [channelId];
const r8 = env13964 = {
$parent: env2422
};
env13964[0] = (a0) => a0.updateParticipantQuality(senderUserId, maxResolution, maxFrameRate);
return r7.reduce($mk73790(r8), false);
},
STREAM_CLOSE: handleStreamClose,
STREAM_DELETE: handleStreamClose,
STREAM_WATCH: function handleStreamWatch(a0) {
let env13965;
let env13966;
const r9 = decodeStreamKey(a0.streamKey);
const { channelId, ownerId } = r9;
const r12 = [channelId];
const r13 = env13965 = {};
env13965[0] = ownerId;
const r14 = env13966 = {
$parent: env2422
};
env13966[0] = $mk73791(r13);
return r12.reduce($mk73790(r14), false);
},
SPEAKING: handleSpeaking,
GUILD_SOUNDBOARD_SOUND_PLAY_START: handleSpeaking,
GUILD_SOUNDBOARD_SOUND_PLAY_END: handleSpeaking,
PUSH_TO_TALK_STATE_CHANGE: function handlePushToTalkStateChange() {
let env13967;
const r1 = env13967 = {
$parent: env2422
};
env13967[0] = (a0) => a0.updateParticipantSpeaking(AuthenticationStore.getId());
return env2422[25].reduce($mk73790(r1), false);
},
GUILD_RING_START: function handleGuildRingStart({ channelId, guildId, ongoingRings }) {
let c13968_0;
c13968_0 = void 0;
if (GuildVoiceRingingExperiment.getCurrentConfig({
guildId,
location: "guild_ring_start"
}).enabled) {
let r20 = c2422_27[channelId];
if (r20 == null) {
const channelRTCParticipants = new ChannelRTCParticipants(channelId);
c2422_27[channelId] = channelRTCParticipants;
r20 = channelRTCParticipants;
}
let env13969;
c13968_0 = r20;
Object.keys(ongoingRings).forEach((item) => c13968_0.updateGuildRingingUsers(item, true));
const r34 = [channelId];
const r35 = env13969 = {
$parent: env2422
};
env13969[0] = (a0) => a0.rebuild();
return r34.reduce($mk73790(r35), false);
}
return false;
},
GUILD_RING_STOP: function handleGuildRingStop({ channelId, guildId, ringing }) {
let c13970_0;
c13970_0 = void 0;
if (GuildVoiceRingingExperiment.getCurrentConfig({
guildId,
location: "guild_ring_start"
}).enabled) {
let r20 = c2422_27[channelId];
if (r20 == null) {
const channelRTCParticipants = new ChannelRTCParticipants(channelId);
c2422_27[channelId] = channelRTCParticipants;
r20 = channelRTCParticipants;
}
let env13971;
c13970_0 = r20;
ringing.forEach((item) => c13970_0.updateGuildRingingUsers(item, false));
const r30 = [channelId];
const r31 = env13971 = {
$parent: env2422
};
env13971[0] = (a0) => a0.rebuild();
return r30.reduce($mk73790(r31), false);
}
return false;
},
USER_UPDATE: handleUserUpdate,
GUILD_MEMBER_UPDATE: handleUserUpdate,
GUILD_DELETE: function handleGuildDelete({ guild }) {
const r5 = [];
let c13972_1 = r5;
Module12.forEach(env2422[25], (a0) => {
const channel = ChannelStore.getChannel(a0);
if (!(channel != null && channel.getGuildId() !== guild.id)) {
c13972_1.push(a0);
}
});
if (r5.length === 0) {
return false;
}
Module12.forEach(r5, (a0) => {
delete c2422_27[a0];
delete c2422_28[a0];
delete c2422_30[a0];
delete c2422_31[a0];
});
}
});
export default r182;
export { c2422_24 as NO_PARTICIPANTS };