shorten channel name

This commit is contained in:
Mathium05
2026-07-30 16:28:27 -05:00
parent 27c743b680
commit f0e35ea4a8
2 changed files with 19 additions and 9 deletions
+14 -7
View File
@@ -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 = "";
+5 -2
View File
@@ -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,