Fixed loading channel bugs
This commit is contained in:
parent
e49360fba1
commit
5d84518b50
7 changed files with 20 additions and 70 deletions
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -453,7 +453,9 @@ class Channel{
|
|||
return new Message(json[0],this);
|
||||
}
|
||||
}
|
||||
static genid:number=0;
|
||||
async getHTML(){
|
||||
const id=++Channel.genid;
|
||||
if(this.guild!==this.localuser.lookingguild){
|
||||
this.guild.loadGuild();
|
||||
}
|
||||
|
@ -466,6 +468,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);
|
||||
|
|
|
@ -100,6 +100,7 @@ class Group extends Channel{
|
|||
return div;
|
||||
}
|
||||
async getHTML(){
|
||||
const id=++Channel.genid;
|
||||
if(this.guild!==this.localuser.lookingguild){
|
||||
this.guild.loadGuild();
|
||||
}
|
||||
|
@ -108,6 +109,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;
|
||||
|
|
|
@ -332,40 +332,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) {
|
||||
|
|
|
@ -487,9 +487,9 @@ p {
|
|||
.startreply {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
width: 22px;
|
||||
margin-left: 25px;
|
||||
width: 25px;
|
||||
border-color: var(--reply-border);
|
||||
margin-left: 26px;
|
||||
}
|
||||
|
||||
.replypfp {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue