diff --git a/.dist/infiniteScroller.js b/.dist/infiniteScroller.js index 63455f0..32e12f6 100644 --- a/.dist/infiniteScroller.js +++ b/.dist/infiniteScroller.js @@ -53,11 +53,17 @@ class InfiniteScroller { currrunning = false; async addedBottom() { this.updatestuff(); - const scrollBottom = this.scrollBottom; + const func = this.snapBottom(); await this.watchForChange(); - if (scrollBottom < 30) { - this.scroll.scrollTop = this.scroll.scrollHeight; - } + func(); + } + snapBottom() { + const scrollBottom = this.scrollBottom; + return () => { + if (scrollBottom < 30) { + this.scroll.scrollTop = this.scroll.scrollHeight; + } + }; } async watchForTop() { let again = false; diff --git a/.dist/message.js b/.dist/message.js index 313e9cf..fca2bed 100644 --- a/.dist/message.js +++ b/.dist/message.js @@ -103,6 +103,7 @@ class Message { }); } giveData(messagejson) { + const func = this.channel.infinite.snapBottom(); for (const thing of Object.keys(messagejson)) { if (thing === "attachments") { this.attachments = []; @@ -154,6 +155,7 @@ class Message { if (this.div) { this.generateMessage(); } + func(); } canDelete() { return this.channel.hasPermission("MANAGE_MESSAGES") || this.author.snowflake === this.localuser.user.snowflake; @@ -389,6 +391,7 @@ class Message { const reactdiv = this.reactdiv.deref(); if (!reactdiv) return; + const func = this.channel.infinite.snapBottom(); reactdiv.innerHTML = ""; for (const thing of this.reactions) { console.log(thing, ":3"); @@ -418,6 +421,7 @@ class Message { this.reactionToggle(thing.emoji.name); }; } + func(); } giveReaction(data, member) { for (const thing of this.reactions) { diff --git a/webpage/infiniteScroller.ts b/webpage/infiniteScroller.ts index 3044210..89368be 100644 --- a/webpage/infiniteScroller.ts +++ b/webpage/infiniteScroller.ts @@ -55,10 +55,16 @@ class InfiniteScroller{ currrunning:boolean=false; async addedBottom(){ this.updatestuff(); - const scrollBottom=this.scrollBottom; + const func=this.snapBottom(); await this.watchForChange(); - if(scrollBottom<30){ - this.scroll.scrollTop=this.scroll.scrollHeight; + func(); + } + snapBottom(){ + const scrollBottom=this.scrollBottom; + return ()=>{ + if(scrollBottom<30){ + this.scroll.scrollTop=this.scroll.scrollHeight; + } } } private async watchForTop():Promise{ diff --git a/webpage/message.ts b/webpage/message.ts index b90c005..b40630e 100644 --- a/webpage/message.ts +++ b/webpage/message.ts @@ -110,6 +110,7 @@ class Message{ }) } giveData(messagejson:messagejson){ + const func=this.channel.infinite.snapBottom(); for(const thing of Object.keys(messagejson)){ if(thing==="attachments"){ this.attachments=[]; @@ -158,6 +159,7 @@ class Message{ if(this.div){ this.generateMessage(); } + func(); } canDelete(){ return this.channel.hasPermission("MANAGE_MESSAGES")||this.author.snowflake===this.localuser.user.snowflake; @@ -394,6 +396,7 @@ class Message{ updateReactions(){ const reactdiv=this.reactdiv.deref(); if(!reactdiv) return; + const func=this.channel.infinite.snapBottom(); reactdiv.innerHTML=""; for(const thing of this.reactions){ console.log(thing,":3") @@ -422,6 +425,7 @@ class Message{ this.reactionToggle(thing.emoji.name); } } + func(); } giveReaction(data:{name:string},member:Member|{id:string}){ for(const thing of this.reactions){