Files
discord-decomp/stores/PermissionSpeakStore.tsx
T
2026-11-01 12:12:55 +02:00

72 lines
2.1 KiB
TypeScript

// Metro module 12804 (f12805).
import ChannelStore from "./ChannelStore";
import GuildStore from "./GuildStore";
import { Storage } from "../_bundle/Module595";
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
let sessionId, channelId;
let c8831_6 = "hideSuppressWarning";
const suppress = false;
let c8831_8 = true;
let c8831_9 = false;
class PermissionSpeakStore extends Module589.Store {
static displayName = "PermissionSpeakStore";
initialize() {
this.waitFor(ChannelStore, GuildStore);
c8831_9 = Storage.get(c8831_6) || c8831_9;
}
isAFKChannel() {
const channel = ChannelStore.getChannel(channelId);
if (channel == null) {
return false;
}
const guild = GuildStore.getGuild(channel.getGuildId());
return guild != null && channel.id === guild.afkChannelId;
}
shouldShowWarning() {
const channel = ChannelStore.getChannel(channelId);
const r8 = channel == null ? void 0 : channel.isGuildStageVoice();
return r8 ? !r8 : !c8831_8;
}
}
const permissionSpeakStore = new PermissionSpeakStore(Dispatcher, {
CONNECTION_OPEN: function handleConnectionOpen(a0) {
sessionId = a0.sessionId;
suppress = false;
},
CONNECTION_CLOSED: function handleConnectionClosed() {
sessionId = null;
channelId = null;
c8831_8 = true;
},
VOICE_STATE_UPDATES: function handleVoiceStateUpdates(a0) {
return a0.voiceStates.reduce((r1, voiceState) => {
if (sessionId === voiceState.sessionId) {
if (suppress !== voiceState.suppress) {
suppress = voiceState.suppress;
c8831_8 = !suppress;
}
if (channelId !== voiceState.channelId) {
channelId = voiceState.channelId;
c8831_8 = !suppress;
}
const r14 = c8831_9 || voiceState.channelId == null;
r1 = true;
if (r14) {
c8831_8 = true;
r1 = true;
}
}
return r1;
}, false);
},
PERMISSION_CLEAR_SUPPRESS_WARNING: function handleClearWarning({ forever }) {
c8831_8 = true;
if (forever) {
c8831_9 = true;
Storage.set(c8831_6, c8831_9);
}
}
});
export default permissionSpeakStore;