Fixed loading channel bugs

This commit is contained in:
MathMan05 2024-06-29 13:02:32 -05:00
parent e49360fba1
commit 5d84518b50
7 changed files with 20 additions and 70 deletions

View file

@ -446,7 +446,9 @@ class Channel {
return new Message(json[0], this);
}
}
static genid = 0;
async getHTML() {
const id = ++Channel.genid;
if (this.guild !== this.localuser.lookingguild) {
this.guild.loadGuild();
}
@ -459,6 +461,9 @@ class Channel {
const prom = Message.wipeChanel();
await this.putmessages();
await prom;
if (id !== Channel.genid) {
return;
}
this.makereplybox();
this.buildmessages();
history.pushState(null, null, "/channels/" + this.guild_id + "/" + this.id);

View file

@ -98,6 +98,7 @@ class Group extends Channel {
return div;
}
async getHTML() {
const id = ++Channel.genid;
if (this.guild !== this.localuser.lookingguild) {
this.guild.loadGuild();
}
@ -106,6 +107,9 @@ class Group extends Channel {
this.localuser.channelfocus = this;
await this.putmessages();
await prom;
if (id !== Channel.genid) {
return;
}
this.buildmessages();
history.pushState(null, null, "/channels/" + this.guild_id + "/" + this.id);
document.getElementById("channelname").textContent = "@" + this.name;

View file

@ -324,40 +324,6 @@ class Message {
this.div = div;
return this.generateMessage(premessage);
}
createunknown(fname, fsize, src) {
const div = document.createElement("table");
div.classList.add("unknownfile");
const nametr = document.createElement("tr");
div.append(nametr);
const fileicon = document.createElement("td");
nametr.append(fileicon);
fileicon.append("🗎");
fileicon.classList.add("fileicon");
fileicon.rowSpan = 2;
const nametd = document.createElement("td");
if (src) {
const a = document.createElement("a");
a.href = src;
a.textContent = fname;
nametd.append(a);
}
else {
nametd.textContent = fname;
}
nametd.classList.add("filename");
nametr.append(nametd);
const sizetr = document.createElement("tr");
const size = document.createElement("td");
sizetr.append(size);
size.textContent = "Size:" + this.filesizehuman(fsize);
size.classList.add("filesize");
div.appendChild(sizetr);
return div;
}
filesizehuman(fsize) {
var i = fsize == 0 ? 0 : Math.floor(Math.log(fsize) / Math.log(1024));
return +((fsize / Math.pow(1024, i)).toFixed(2)) * 1 + ' ' + ['Bytes', 'Kilobytes', 'Megabytes', 'Gigabytes', 'Terabytes'][i];
}
}
function formatTime(date) {
const now = new Date();