From 384b666ac22acc51746c8c03459d71919409e087 Mon Sep 17 00:00:00 2001 From: MathMan05 Date: Sat, 7 Sep 2024 18:24:44 -0500 Subject: [PATCH] more DM fixes --- .dist/direct.js | 27 ++++++++++++++++----------- webpage/direct.ts | 26 ++++++++++++++++---------- 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/.dist/direct.js b/.dist/direct.js index 5c6c4ab..507907a 100644 --- a/.dist/direct.js +++ b/.dist/direct.js @@ -179,6 +179,7 @@ class Group extends Channel { } this.infinite.addedBottom(); } + this.unreads(); if (messagez.author === this.localuser.user) { return; } @@ -195,28 +196,32 @@ class Group extends Channel { notititle(message) { return message.author.username; } + readbottom() { + super.readbottom(); + this.unreads(); + } + all = new WeakRef(document.createElement("div")); + noti = new WeakRef(document.createElement("div")); unreads() { const sentdms = document.getElementById("sentdms"); //Need to change sometime - let current = null; - for (const thing of sentdms.children) { - if (thing["all"] === this) { - current = thing; - } - } + const current = this.all.deref(); if (this.hasunreads) { - if (current) { - current["noti"].textContent = this.mentions; - return; + { + const noti = this.noti.deref(); + if (noti) { + noti.textContent = this.mentions + ""; + return; + } } const div = document.createElement("div"); div.classList.add("servernoti"); const noti = document.createElement("div"); noti.classList.add("unread", "notiunread", "pinged"); noti.textContent = "" + this.mentions; - div["noti"] = noti; + this.noti = new WeakRef(noti); div.append(noti); const buildpfp = this.user.buildpfp(); - div["all"] = this; + this.all = new WeakRef(div); buildpfp.classList.add("mentioned"); div.append(buildpfp); sentdms.append(div); diff --git a/webpage/direct.ts b/webpage/direct.ts index 2eca86e..00cc791 100644 --- a/webpage/direct.ts +++ b/webpage/direct.ts @@ -183,6 +183,7 @@ class Group extends Channel{ } this.infinite.addedBottom(); } + this.unreads(); if(messagez.author===this.localuser.user){ return; } @@ -198,27 +199,32 @@ class Group extends Channel{ notititle(message){ return message.author.username; } + readbottom(){ + super.readbottom(); + this.unreads(); + } + all:WeakRef=new WeakRef(document.createElement("div")); + noti:WeakRef=new WeakRef(document.createElement("div")); unreads(){ const sentdms=document.getElementById("sentdms") as HTMLDivElement;//Need to change sometime - let current:HTMLElement|null=null; - for(const thing of sentdms.children){ - if(thing["all"]===this){ - current=thing as HTMLElement; - } - } + const current=this.all.deref(); if(this.hasunreads){ - if(current){ - current["noti"].textContent=this.mentions;return; + { + const noti=this.noti.deref(); + if(noti){ + noti.textContent=this.mentions+""; + return; + } } const div=document.createElement("div"); div.classList.add("servernoti"); const noti=document.createElement("div"); noti.classList.add("unread","notiunread","pinged"); noti.textContent=""+this.mentions; - div["noti"]=noti; + this.noti=new WeakRef(noti); div.append(noti); const buildpfp=this.user.buildpfp(); - div["all"]=this; + this.all=new WeakRef(div); buildpfp.classList.add("mentioned"); div.append(buildpfp); sentdms.append(div);