logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://hacktivis.me/git/pleroma-fe.git
commit: e36548579fb179d0431591529158a65f85e5b134
parent 37e3a23f2a25120e13aa4f1ff65e444060d24abb
Author: Henry Jameson <me@hjkos.com>
Date:   Tue, 21 Nov 2023 15:26:31 +0200

fix notifications not catching up with "read" status as intended

Diffstat:

Achangelog.d/unreads-sync.fix1+
Msrc/services/api/api.service.js4++++
Msrc/services/notifications_fetcher/notifications_fetcher.service.js8+++++---
3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/changelog.d/unreads-sync.fix b/changelog.d/unreads-sync.fix @@ -0,0 +1 @@ +unread notifications should now properly catch up (eventually) in polling mode diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js @@ -671,6 +671,7 @@ const fetchTimeline = ({ timeline, credentials, since = false, + minId = false, until = false, userId = false, listId = false, @@ -705,6 +706,9 @@ const fetchTimeline = ({ url = url(listId) } + if (minId) { + params.push(['min_id', minId]) + } if (since) { params.push(['since_id', since]) } diff --git a/src/services/notifications_fetcher/notifications_fetcher.service.js b/src/services/notifications_fetcher/notifications_fetcher.service.js @@ -49,9 +49,11 @@ const fetchAndUpdate = ({ store, credentials, older = false, since }) => { // The normal maxId-check does not tell if older notifications have changed const notifications = timelineData.data const readNotifsIds = notifications.filter(n => n.seen).map(n => n.id) - const numUnseenNotifs = notifications.length - readNotifsIds.length - if (numUnseenNotifs > 0 && readNotifsIds.length > 0) { - args.since = Math.max(...readNotifsIds) + const unreadNotifsIds = notifications.filter(n => !n.seen).map(n => n.id) + if (readNotifsIds.length > 0 && readNotifsIds.length > 0) { + const minId = Math.min(...unreadNotifsIds) // Oldest known unread notification + args.since = false // Don't use since_id since it sorta conflicts with min_id + args.minId = minId - 1 // go beyond fetchNotifications({ store, args, older }) }