Attempt to fix new messages button #114

This commit is contained in:
Jon Staab
2025-02-11 11:49:17 -08:00
parent 622214713b
commit 0ba55f2387
@@ -147,6 +147,12 @@
let newMessagesSeen = false
if (events) {
const lastUserEvent = $events.find(e => e.pubkey === $pubkey)
// Adjust last checked to account for messages that came from a different device
const adjustedLastChecked =
lastChecked && lastUserEvent ? Math.max(lastUserEvent.created_at, lastChecked) : lastChecked
for (const event of $events.toReversed()) {
if (seen.has(event.id)) {
continue
@@ -156,9 +162,9 @@
if (
!newMessagesSeen &&
adjustedLastChecked &&
event.pubkey !== $pubkey &&
lastChecked &&
event.created_at > lastChecked
event.created_at > adjustedLastChecked
) {
elements.push({type: "new-messages", id: "new-messages"})
newMessagesSeen = true