From 7647b2398dc765cc9cf2dce7f44cd4c08a813d04 Mon Sep 17 00:00:00 2001 From: MathMan05 Date: Tue, 27 Jan 2026 19:55:30 -0600 Subject: [PATCH] more unread changes --- src/webpage/channel.ts | 7 ++++--- src/webpage/infiniteScroller.ts | 17 ++++++++++------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/webpage/channel.ts b/src/webpage/channel.ts index 9737efd..069d8d8 100644 --- a/src/webpage/channel.ts +++ b/src/webpage/channel.ts @@ -2890,6 +2890,10 @@ class Channel extends SnowFlake { } this.setLastMessageId(messagez.id); + if (this.infinite.atBottom()) { + this.lastreadmessageid = messagez.id; + } + this.unreads(); this.guild.unreads(); if (this === this.localuser.channelfocus) { @@ -2902,9 +2906,6 @@ class Channel extends SnowFlake { if (messagez.author === this.localuser.user) { this.lastSentMessage = messagez; this.slowmode(); - this.lastreadmessageid = messagez.id; - this.lastmessage = messagez; - this.lastreadmessageid = messagez.id; this.mentions = 0; this.unreads(); this.guild.unreads(); diff --git a/src/webpage/infiniteScroller.ts b/src/webpage/infiniteScroller.ts index ab413bb..b780a72 100644 --- a/src/webpage/infiniteScroller.ts +++ b/src/webpage/infiniteScroller.ts @@ -183,20 +183,23 @@ class InfiniteScroller { snap(); } - snapBottom(): () => void { - const nothing = () => {}; + atBottom() { const scroll = this.scroller; - if (!scroll) return nothing; + if (!scroll) return false; const last = this.weakElmId.get(Array.from(scroll.children).at(-1) as HTMLElement); - if (!last) return nothing; - if (this.backElm.get(last) || !this.backElm.has(last)) return nothing; - if (this.div) { + if (!last) return false; + if (this.backElm.get(last) || !this.backElm.has(last)) return false; + return this.scrollBottom < 4; + } + + snapBottom(): () => void { + if (this.div && this.atBottom()) { const trigger = this.scrollBottom < 4; return () => { if (this.div && trigger) this.div.scrollTop = this.div.scrollHeight; }; } else { - return nothing; + return () => {}; } }