From f0e35ea4a8a145227d8af2f761c0cdc47c7bf9c4 Mon Sep 17 00:00:00 2001 From: Mathium05 Date: Thu, 30 Jul 2026 16:28:27 -0500 Subject: [PATCH] shorten channel name --- src/webpage/channel.ts | 21 ++++++++++++++------- src/webpage/localuser.ts | 7 +++++-- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/webpage/channel.ts b/src/webpage/channel.ts index e89608d..dd9c580 100644 --- a/src/webpage/channel.ts +++ b/src/webpage/channel.ts @@ -44,6 +44,10 @@ class Channel extends SnowFlake { owner: Guild; headers: Localuser["headers"]; name!: string; + get shortName() { + if (this.name.length > 50) return this.name.slice(0, 50) + "..."; + return this.name; + } parentId?: string; parent?: Channel; children!: Channel[]; @@ -410,7 +414,7 @@ class Channel extends SnowFlake { update(); const inviteOptions = new Dialog("", {noSubmit: true}); inviteOptions.options.addTitle(I18n.inviteOptions.title()); - inviteOptions.options.addText(I18n.invite.subtext(this.name, this.guild.properties.name)); + inviteOptions.options.addText(I18n.invite.subtext(this.shortName, this.guild.properties.name)); inviteOptions.options.addSelect( I18n.invite.expireAfter(), @@ -438,7 +442,7 @@ class Channel extends SnowFlake { inviteOptions.show(); } generateSettings() { - const settings = new Settings(I18n.channel.settingsFor(this.name)); + const settings = new Settings(I18n.channel.settingsFor(this.shortName)); { const gensettings = settings.addButton(I18n.channel.settings()); const form = gensettings.addForm("", () => {}, { @@ -1063,7 +1067,7 @@ class Channel extends SnowFlake { const myhtml = document.createElement("p2"); myhtml.classList.add("ellipsis"); - myhtml.textContent = this.name; + myhtml.textContent = this.shortName; this.nameSpan = new WeakRef(myhtml); decdiv.appendChild(myhtml); caps.appendChild(decdiv); @@ -1130,7 +1134,7 @@ class Channel extends SnowFlake { div.append(button); const myhtml = document.createElement("span"); myhtml.classList.add("ellipsis"); - myhtml.textContent = this.name; + myhtml.textContent = this.shortName; this.nameSpan = new WeakRef(myhtml); const decoration = this.renderIcon(); button.appendChild(decoration); @@ -2028,7 +2032,7 @@ class Channel extends SnowFlake { div.append(tags); const title = document.createElement("h3"); - title.textContent = new MarkDown(this.name).makeHTML().textContent; + title.textContent = new MarkDown(this.shortName).makeHTML().textContent; div.append(title); const member = @@ -2628,7 +2632,10 @@ class Channel extends SnowFlake { if (this.curCommand) { this.curCommand.render(typebox, this); } - typebox.style.setProperty("--channel-text", JSON.stringify(I18n.channel.typebox(this.name))); + typebox.style.setProperty( + "--channel-text", + JSON.stringify(I18n.channel.typebox(this.shortName)), + ); if (!this.curCommand && !this.isForum()) { const md = typebox.markdown; md.owner = this; @@ -2681,7 +2688,7 @@ class Channel extends SnowFlake { "/channels/" + this.guild.id + "/" + this.id + (aroundMessage ? `/${aroundMessage}` : ""), ); } - this.localuser.pageTitle("#" + this.name); + this.localuser.pageTitle("#" + this.shortName); const channelTopic = document.getElementById("channelTopic") as HTMLSpanElement; if (this.topic) { channelTopic.innerHTML = ""; diff --git a/src/webpage/localuser.ts b/src/webpage/localuser.ts index 4eb3442..1cefaca 100644 --- a/src/webpage/localuser.ts +++ b/src/webpage/localuser.ts @@ -2058,7 +2058,10 @@ class Localuser { menu.bindContextmenu(iconDiv); if (folder.color !== null && folder.color !== undefined) { - folderDiv.style.setProperty("--folder-color", "#" + folder.color.toString(16).padStart(6, "0")); + folderDiv.style.setProperty( + "--folder-color", + "#" + folder.color.toString(16).padStart(6, "0"), + ); if (!folder.color && folder.color !== 0) folderDiv.style.removeProperty("--folder-color"); } iconDiv.append(icon); @@ -4695,7 +4698,7 @@ class Localuser { maybe.sort((a, b) => b[0] - a[0]); this.MDSearchOptions( maybe.map((a) => { - return {name: "# " + a[1].name, replace: `<#${a[1].id}> `}; + return {name: "# " + a[1].shortName, replace: `<#${a[1].id}> `}; }), original, box,