Fix new messages indicator

This commit is contained in:
Jon Staab 2026-07-08 11:53:57 -07:00
parent 8f7016b60c
commit a254ec10f1
2 changed files with 14 additions and 4 deletions

View file

@ -230,7 +230,12 @@
}
const manageScrollPosition = () => {
showScrollButton = !isNaN(at) || Math.abs(element?.scrollTop || 0) > 1500
// Only treat an `at` jump as "scrolled up" when it targets an event below the
// newest one; jumping to the most recent message already lands us at the bottom.
const newestEvent = $events[$events.length - 1]
const atIsBelowNewest = !isNaN(at) && newestEvent !== undefined && at < newestEvent.created_at
showScrollButton = atIsBelowNewest || Math.abs(element?.scrollTop || 0) > 1500
const newMessages = document.getElementById("new-messages")
@ -316,7 +321,7 @@
let newMessagesSeen = false
if (events) {
const lastUserEvent = $events.find(e => e.pubkey === $pubkey)
const lastUserEvent = $events.findLast(e => e.pubkey === $pubkey)
// Adjust last checked to account for messages that came from a different device
const adjustedLastChecked =

View file

@ -113,7 +113,12 @@
}
const manageScrollPosition = () => {
showScrollButton = !isNaN(at) || Math.abs(element?.scrollTop || 0) > 1500
// Only treat an `at` jump as "scrolled up" when it targets an event below the
// newest one; jumping to the most recent message already lands us at the bottom.
const newestEvent = $events[$events.length - 1]
const atIsBelowNewest = !isNaN(at) && newestEvent !== undefined && at < newestEvent.created_at
showScrollButton = atIsBelowNewest || Math.abs(element?.scrollTop || 0) > 1500
const newMessages = document.getElementById("new-messages")
@ -197,7 +202,7 @@
let newMessagesSeen = false
if (events) {
const lastUserEvent = $events.find(e => e.pubkey === $pubkey)
const lastUserEvent = $events.findLast(e => e.pubkey === $pubkey)
// Adjust last checked to account for messages that came from a different device
const adjustedLastChecked =