// Metro module 16148 (f16149). import SoundpackStore from "../soundpacks/SoundpackStore"; import CallStore from "../../stores/CallStore"; import ChannelStore from "../../stores/ChannelStore"; import NotificationSettingsStore from "../../stores/NotificationSettingsStore"; import SelectedChannelStore from "../../stores/SelectedChannelStore"; import StreamerModeStore from "../../stores/StreamerModeStore"; import VoiceStateStore from "../../stores/VoiceStateStore"; import SortedVoiceStateStore from "../../stores/views/SortedVoiceStateStore"; import ChannelRTCStore from "./ChannelRTCStore"; import { createSoundForPack } from "../sound_playback/SoundUtils"; import AutomaticLifecycleManager from "../../lib/AutomaticLifecycleManager"; import { HermesBuiltin } from "../../_hermes/prelude"; let soundForPack = createSoundForPack("call_calling", SoundpackStore.getSoundpack()); let c11569_12 = Symbol("#n"); class ChannelCallManager extends AutomaticLifecycleManager { constructor() { super(...arguments); const set = new Set(); if (Object.prototype.hasOwnProperty.call(this, c11569_12)) { HermesBuiltin.throwTypeError("Cannot initialize private field twice."); throw new Error("unreachable"); } this[c11569_12] = set; this.actions = { GUILD_LOCAL_RING_START: (a0) => this.handleGuildRingStart(a0), GUILD_RING_STOP: (a0) => this.handleGuildRingStop(a0) }; this._handleRing = (a0, a1) => { const currentClientVoiceChannelId = VoiceStateStore.getCurrentClientVoiceChannelId(a1); const r1 = currentClientVoiceChannelId != null && SortedVoiceStateStore.countVoiceStatesForChannel(currentClientVoiceChannelId) >= 2; if (currentClientVoiceChannelId != null && (!r1 && (a0 && (!NotificationSettingsStore.isSoundDisabled("call_calling") && !StreamerModeStore.disableSounds)))) { soundForPack.loop(); } else { soundForPack.stop(); } }; this.handleSoundpackUpdate = () => { soundForPack.stop(); soundForPack = createSoundForPack("call_calling", SoundpackStore.getSoundpack()); }; this.handleRingUpdate = () => { let r7 = ChannelStore.getChannel(SelectedChannelStore.getVoiceChannelId())?.guild_id; if (r7 == null) { r7 = null; } let r18 = CallStore.getCalls().some((item) => item.ringing.length > 0 && VoiceStateStore.getCurrentClientVoiceChannelId(null) === item.channelId); if (!r18) { r18 = this[c11569_12].size > 0; } this._handleRing(r18, r7); }; this.handleGuildRingStart = ({ ringing, guildId }) => { ringing.forEach((item) => { this[c11569_12].add(item); }); this._handleRing(this[c11569_12].size > 0, guildId); }; this.handleGuildRingStop = ({ ringing, guildId }) => { ringing.forEach((item) => { this[c11569_12].delete(item); }); this._handleRing(this[c11569_12].size > 0, guildId); }; this.handleChannelRTCStoreChange = () => { const voiceChannelId = SelectedChannelStore.getVoiceChannelId(); if (this[c11569_12].size > 0) { if (voiceChannelId == null) { this[c11569_12] = new Set(); this._handleRing(this[c11569_12].size > 0, null); return void 0; } if (voiceChannelId != null) { const guildRingingUsers = ChannelRTCStore.getGuildRingingUsers(voiceChannelId); const set = new Set([...this[c11569_12]].filter((item) => !guildRingingUsers.has(item))); if (set.size > 0) { set.forEach((item) => { this[c11569_12].delete(item); }); this._handleRing(this[c11569_12].size > 0, null); } } } }; } _initialize() { this.stores = new Map().set(CallStore, this.handleRingUpdate).set(NotificationSettingsStore, this.handleRingUpdate).set(StreamerModeStore, this.handleRingUpdate).set(VoiceStateStore, this.handleRingUpdate).set(ChannelRTCStore, this.handleChannelRTCStoreChange).set(SoundpackStore, this.handleSoundpackUpdate); } } const channelCallManager = new ChannelCallManager(); export default channelCallManager;