forked from coracle/flotilla
Attempt to fix new messages button #114
This commit is contained in:
@@ -147,6 +147,12 @@
|
|||||||
let newMessagesSeen = false
|
let newMessagesSeen = false
|
||||||
|
|
||||||
if (events) {
|
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()) {
|
for (const event of $events.toReversed()) {
|
||||||
if (seen.has(event.id)) {
|
if (seen.has(event.id)) {
|
||||||
continue
|
continue
|
||||||
@@ -156,9 +162,9 @@
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
!newMessagesSeen &&
|
!newMessagesSeen &&
|
||||||
|
adjustedLastChecked &&
|
||||||
event.pubkey !== $pubkey &&
|
event.pubkey !== $pubkey &&
|
||||||
lastChecked &&
|
event.created_at > adjustedLastChecked
|
||||||
event.created_at > lastChecked
|
|
||||||
) {
|
) {
|
||||||
elements.push({type: "new-messages", id: "new-messages"})
|
elements.push({type: "new-messages", id: "new-messages"})
|
||||||
newMessagesSeen = true
|
newMessagesSeen = true
|
||||||
|
|||||||
Reference in New Issue
Block a user