From 4e0ac6ecfbcca19ed5a5d96f46c367a02f7d0684 Mon Sep 17 00:00:00 2001 From: MathMan05 Date: Fri, 26 Jun 2026 22:34:29 -0500 Subject: [PATCH] rename channels map --- src/webpage/channel.ts | 12 ++++++------ src/webpage/direct.ts | 6 +++--- src/webpage/guild.ts | 26 ++++++++++++------------- src/webpage/localuser.ts | 42 +++++++++++++++++++--------------------- src/webpage/markdown.ts | 2 +- src/webpage/message.ts | 4 ++-- 6 files changed, 45 insertions(+), 47 deletions(-) diff --git a/src/webpage/channel.ts b/src/webpage/channel.ts index b34adf9..9883d03 100644 --- a/src/webpage/channel.ts +++ b/src/webpage/channel.ts @@ -679,7 +679,7 @@ class Channel extends SnowFlake { if (json === -1) { return; } - this.localuser.channelids.set(this.id, this); + this.localuser.channels.set(this.id, this); this.flags = json.flags || 0; this.memberCount = json.member_count; this.defaultAutoArchiveDuration = json.default_auto_archive_duration; @@ -905,7 +905,7 @@ class Channel extends SnowFlake { resolveparent(_guild: Guild = this.owner) { const parentid = this.parent_id; if (!parentid) return false; - this.parent = this.localuser.channelids.get(parentid); + this.parent = this.localuser.channels.get(parentid); this.parent ??= undefined; if (this.parent !== undefined) { this.parent.children.push(this); @@ -2167,13 +2167,13 @@ class Channel extends SnowFlake { has_more: boolean; }; for (const threadjson of res.threads) { - if (this.localuser.channelids.has(threadjson.id)) continue; + if (this.localuser.channels.has(threadjson.id)) continue; const thread = new Channel(threadjson, this.guild); - this.localuser.channelids.set(threadjson.id, thread); + this.localuser.channels.set(threadjson.id, thread); thread.resolveparent(); } for (const message of res.messages) { - const thread = this.localuser.channelids.get(message.channel_id); + const thread = this.localuser.channels.get(message.channel_id); if (!thread) continue; const m = this.localuser.messages.get(message.id); if (!m) this.localuser.messages.set(message.id, new Message(message, thread)); @@ -3226,7 +3226,7 @@ class Channel extends SnowFlake { const span = this.nameSpan.deref(); if (span) span.textContent = this.name; - const parent = this.localuser.channelids.get(json.parent_id); + const parent = this.localuser.channels.get(json.parent_id); if (parent) { this.parent = parent; this.parent_id = parent.id; diff --git a/src/webpage/direct.ts b/src/webpage/direct.ts index d673af3..bd5325d 100644 --- a/src/webpage/direct.ts +++ b/src/webpage/direct.ts @@ -32,7 +32,7 @@ class Direct extends Guild { for (const thing of json) { const temp = new Group(thing, this); this.channels.push(temp); - this.localuser.channelids.set(temp.id, temp); + this.localuser.channels.set(temp.id, temp); } this.headchannels = this.channels; this.discovery = new Discovery(this); @@ -40,13 +40,13 @@ class Direct extends Guild { createChannelpac(json: any) { const thischannel = new Group(json, this); this.channels.push(thischannel); - this.localuser.channelids.set(thischannel.id, thischannel); + this.localuser.channels.set(thischannel.id, thischannel); this.sortchannels(); this.printServers(); return thischannel; } delChannel(json: channeljson) { - const channel = this.localuser.channelids.get(json.id) as Group; + const channel = this.localuser.channels.get(json.id) as Group; super.delChannel(json); if (channel) { channel.del(); diff --git a/src/webpage/guild.ts b/src/webpage/guild.ts index 6804fc6..a16cea9 100644 --- a/src/webpage/guild.ts +++ b/src/webpage/guild.ts @@ -1544,7 +1544,7 @@ class Guild extends SnowFlake { for (const thing of json.channels) { const temp = new Channel(thing, this); this.channels.push(temp); - this.localuser.channelids.set(temp.id, temp); + this.localuser.channels.set(temp.id, temp); } this.headchannels = []; @@ -1555,12 +1555,12 @@ class Guild extends SnowFlake { } } for (const thread of json.threads) { - if (this.localuser.channelids.has(thread.id)) continue; + if (this.localuser.channels.has(thread.id)) continue; const temp = new Channel(thread, this); - this.localuser.channelids.set(temp.id, temp); + this.localuser.channels.set(temp.id, temp); temp.resolveparent(this); } - this.prevchannel = this.localuser.channelids.get(this.perminfo.prevchannel); + this.prevchannel = this.localuser.channels.get(this.perminfo.prevchannel); this.stickers = json.stickers.map((_) => new Sticker(_, this)) || []; } get perminfo() { @@ -1574,7 +1574,7 @@ class Guild extends SnowFlake { this.mute_config = this.mute_config; this.message_notifications = settings.message_notifications; for (const override of settings.channel_overrides) { - const channel = this.localuser.channelids.get(override.channel_id); + const channel = this.localuser.channels.get(override.channel_id); if (!channel) continue; channel.handleUserOverrides(override); } @@ -1864,7 +1864,7 @@ class Guild extends SnowFlake { } } async goToThread(threadId: string) { - if (!this.localuser.channelids.has(threadId)) { + if (!this.localuser.channels.has(threadId)) { const channelJson = await ( await fetch(this.info.api + "/channels/" + threadId, { headers: this.headers, @@ -1872,9 +1872,9 @@ class Guild extends SnowFlake { ).json(); if (channelJson.code == 200) { const channel = new Channel(channelJson as channeljson, this); - this.localuser.channelids.set(channel.id, channel); + this.localuser.channels.set(channel.id, channel); channel.resolveparent(this); - const par = this.localuser.channelids.get(channel.parent_id as string); + const par = this.localuser.channels.get(channel.parent_id as string); par?.createguildHTML(); } else { this.loadChannel(); @@ -1940,7 +1940,7 @@ class Guild extends SnowFlake { } async loadChannel(ID?: string | undefined | null, addstate = true, message?: string) { if (ID) { - const channel = this.localuser.channelids.get(ID); + const channel = this.localuser.channels.get(ID); if (channel) { await channel.getHTML(addstate, undefined, message); return; @@ -2017,7 +2017,7 @@ class Guild extends SnowFlake { this.localuser.loadGuild(this.id); } updateChannel(json: channeljson) { - const channel = this.localuser.channelids.get(json.id); + const channel = this.localuser.channels.get(json.id); if (channel) { const parent = channel.parent; channel.updateChannel(json); @@ -2040,7 +2040,7 @@ class Guild extends SnowFlake { } createChannelpac(json: channeljson) { const thischannel = new Channel(json, this); - this.localuser.channelids.set(json.id, thischannel); + this.localuser.channels.set(json.id, thischannel); this.channels.push(thischannel); thischannel.resolveparent(this); if (!thischannel.parent) { @@ -2085,8 +2085,8 @@ class Guild extends SnowFlake { channelselect.show(); } delChannel(json: channeljson) { - const channel = this.localuser.channelids.get(json.id); - this.localuser.channelids.delete(json.id); + const channel = this.localuser.channels.get(json.id); + this.localuser.channels.delete(json.id); if (!channel) return; this.channels.splice(this.channels.indexOf(channel), 1); const indexy = this.headchannels.indexOf(channel); diff --git a/src/webpage/localuser.ts b/src/webpage/localuser.ts index 80b1ab0..58861bb 100644 --- a/src/webpage/localuser.ts +++ b/src/webpage/localuser.ts @@ -91,7 +91,7 @@ class Localuser { private ws?: WebSocket; private connectionSucceed = 0; private errorBackoff = 0; - channelids: Map = new Map(); + readonly channels: Map = new Map(); readonly userMap: Map = new Map(); voiceFactory?: VoiceFactory; play?: Play; @@ -363,7 +363,7 @@ class Localuser { async gottenReady(ready: readyjson): Promise { await I18n.done; this.errorBackoff = 0; - this.channelids.clear(); + this.channels.clear(); this.inrelation.clear(); this.userMap.clear(); this.queryBlog(); @@ -432,7 +432,7 @@ class Localuser { } if (ready.d.read_state) { for (const thing of ready.d.read_state.entries) { - const channel = this.channelids.get(thing.channel_id); + const channel = this.channels.get(thing.channel_id); if (!channel) { this.unknownRead.set(thing.channel_id, thing); continue; @@ -460,7 +460,7 @@ class Localuser { this.focusChannel = undefined; } giveMessage(m: messagejson) { - const c = this.channelids.get(m.channel_id); + const c = this.channels.get(m.channel_id); if (!c) return; new Message(m, c); } @@ -752,7 +752,7 @@ class Localuser { if (temp.op == 0) { switch (temp.t) { case "THREAD_MEMBERS_UPDATE": { - const channel = this.channelids.get(temp.d.id); + const channel = this.channels.get(temp.d.id); if (!channel) return; if (temp.d.added_members) { for (const memb of temp.d.added_members) { @@ -809,7 +809,7 @@ class Localuser { } case "MESSAGE_DELETE": { temp.d.guild_id ??= "@me"; - const channel = this.channelids.get(temp.d.channel_id); + const channel = this.channels.get(temp.d.channel_id); if (!channel) break; const message = channel.messages.get(temp.d.id); if (!message) break; @@ -821,7 +821,7 @@ class Localuser { break; case "MESSAGE_UPDATE": { temp.d.guild_id ??= "@me"; - const channel = this.channelids.get(temp.d.channel_id); + const channel = this.channels.get(temp.d.channel_id); if (!channel) break; const message = channel.messages.get(temp.d.id); if (!message) break; @@ -843,7 +843,7 @@ class Localuser { break; case "CHANNEL_PINS_UPDATE": temp.d.guild_id ??= "@me"; - const channel = this.channelids.get(temp.d.channel_id); + const channel = this.channels.get(temp.d.channel_id); if (!channel) break; delete channel.pinnedMessages; channel.lastpin = new Date() + ""; @@ -906,7 +906,7 @@ class Localuser { temp.d.guild_id ??= "@me"; const guild = this.guilds.get(temp.d.guild_id); if (!guild) break; - const channel = this.channelids.get(temp.d.channel_id); + const channel = this.channels.get(temp.d.channel_id); if (!channel) break; const message = channel.messages.get(temp.d.message_id); if (!message) break; @@ -922,7 +922,7 @@ class Localuser { case "MESSAGE_REACTION_REMOVE": { temp.d.guild_id ??= "@me"; - const channel = this.channelids.get(temp.d.channel_id); + const channel = this.channels.get(temp.d.channel_id); if (!channel) break; const message = channel.messages.get(temp.d.message_id); @@ -934,7 +934,7 @@ class Localuser { case "MESSAGE_REACTION_REMOVE_ALL": { temp.d.guild_id ??= "@me"; - const channel = this.channelids.get(temp.d.channel_id); + const channel = this.channels.get(temp.d.channel_id); if (!channel) break; const message = channel.messages.get(temp.d.message_id); if (!message) break; @@ -944,7 +944,7 @@ class Localuser { case "MESSAGE_REACTION_REMOVE_EMOJI": { temp.d.guild_id ??= "@me"; - const channel = this.channelids.get(temp.d.channel_id); + const channel = this.channels.get(temp.d.channel_id); if (!channel) break; const message = channel.messages.get(temp.d.message_id); if (!message) break; @@ -1104,7 +1104,7 @@ class Localuser { break; } case "MESSAGE_ACK": { - const channel = this.channelids.get(temp.d.channel_id); + const channel = this.channels.get(temp.d.channel_id); if (!channel) break; channel.lastreadmessageid = temp.d.message_id; channel.mentions = 0; @@ -1319,9 +1319,7 @@ class Localuser { if (this.voiceFactory) { this.voiceFactory.onJoin = (voice) => { voice.onSatusChange = (status) => { - let channel: Channel | undefined = this.channelids - .values() - .find((_) => _.voice === voice); + let channel: Channel | undefined = this.channels.values().find((_) => _.voice === voice); if (channel) this.changeVCStatus(status, channel); else console.error("Uh, no channel found?"); }; @@ -1340,7 +1338,7 @@ class Localuser { } } createChannel(json: channeljson): undefined | Channel { - const c = this.channelids.get(json.id); + const c = this.channels.get(json.id); if (c) { c.updateChannel(json); return c; @@ -1674,7 +1672,7 @@ class Localuser { gotoid: string | undefined; gotoRes = () => {}; async goToChannel(channelid: string, addstate = true, messageid: undefined | string = undefined) { - const channel = this.channelids.get(channelid); + const channel = this.channels.get(channelid); if (channel) { const guild = channel.guild; guild.loadGuild(); @@ -1706,7 +1704,7 @@ class Localuser { return; } await guild.loadChannel(location[5], true, location[6]); - this.focusChannel = this.channelids.get(location[5]); + this.focusChannel = this.channels.get(location[5]); } } loaduser(): void { @@ -2313,7 +2311,7 @@ class Localuser { } messageCreate(messagep: messageCreateJson): void { messagep.d.guild_id ??= "@me"; - const channel = this.channelids.get(messagep.d.channel_id); + const channel = this.channels.get(messagep.d.channel_id); if (channel) { channel.messageCreate(messagep); this.unreads(); @@ -2391,7 +2389,7 @@ class Localuser { return sum; } async typingStart(typing: startTypingjson): Promise { - const channel = this.channelids.get(typing.d.channel_id); + const channel = this.channels.get(typing.d.channel_id); if (!channel) return; channel.typingStart(typing); } @@ -4690,7 +4688,7 @@ class Localuser { //FIXME total_results shall be ignored as it's known to be bad, spacebar bug. const messages = json.messages .map(([m]) => { - const c = this.channelids.get(m.channel_id); + const c = this.channels.get(m.channel_id); if (!c) return; if (c.messages.get(m.id)) { return c.messages.get(m.id); diff --git a/src/webpage/markdown.ts b/src/webpage/markdown.ts index 7e17b19..4b7c6b1 100644 --- a/src/webpage/markdown.ts +++ b/src/webpage/markdown.ts @@ -702,7 +702,7 @@ class MarkDown { } break; case "#": - const channel = this.localuser.channelids.get(id); + const channel = this.localuser.channels.get(id); if (channel) { mention.textContent = `#${channel.name}`; if (!keep && !stdsize) { diff --git a/src/webpage/message.ts b/src/webpage/message.ts index a5a3071..d6e579c 100644 --- a/src/webpage/message.ts +++ b/src/webpage/message.ts @@ -434,11 +434,11 @@ class Message extends SnowFlake { this.components = new Components(messagejson.components, this); continue; } else if (thing === "thread" && messagejson.thread) { - let thread = this.localuser.channelids.get(messagejson.thread.id); + let thread = this.localuser.channels.get(messagejson.thread.id); if (!thread) { thread = new Channel(messagejson.thread, this.guild); thread.resolveparent(); - this.localuser.channelids.set(thread.id, thread); + this.localuser.channels.set(thread.id, thread); } this.thread = thread; continue;