From aad3225d25460170a8dd48f8ffcbc63f99a28b7f Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Thu, 16 Nov 2023 19:26:18 +0200 Subject: refactored notifications into their own module separate from statuses (WIP) --- src/services/notifications_fetcher/notifications_fetcher.service.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/services/notifications_fetcher/notifications_fetcher.service.js') diff --git a/src/services/notifications_fetcher/notifications_fetcher.service.js b/src/services/notifications_fetcher/notifications_fetcher.service.js index 6c247210..3c280b74 100644 --- a/src/services/notifications_fetcher/notifications_fetcher.service.js +++ b/src/services/notifications_fetcher/notifications_fetcher.service.js @@ -21,7 +21,7 @@ const fetchAndUpdate = ({ store, credentials, older = false, since }) => { const args = { credentials } const { getters } = store const rootState = store.rootState || store.state - const timelineData = rootState.statuses.notifications + const timelineData = rootState.notifications const hideMutedPosts = getters.mergedConfig.hideMutedPosts args.includeTypes = mastoApiNotificationTypes -- cgit v1.2.3-70-g09d2 From e36548579fb179d0431591529158a65f85e5b134 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Tue, 21 Nov 2023 15:26:31 +0200 Subject: fix notifications not catching up with "read" status as intended --- changelog.d/unreads-sync.fix | 1 + src/services/api/api.service.js | 4 ++++ .../notifications_fetcher/notifications_fetcher.service.js | 8 +++++--- 3 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 changelog.d/unreads-sync.fix (limited to 'src/services/notifications_fetcher/notifications_fetcher.service.js') diff --git a/changelog.d/unreads-sync.fix b/changelog.d/unreads-sync.fix new file mode 100644 index 00000000..1eac3364 --- /dev/null +++ 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 index f45e3958..bde2e163 100644 --- 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 index 3c280b74..21540845 100644 --- 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 }) } -- cgit v1.2.3-70-g09d2 From 92685e37b61d27cfd964c000f45331535d97de39 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Tue, 21 Nov 2023 15:29:49 +0200 Subject: fix infinity case --- .../notifications_fetcher/notifications_fetcher.service.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/services/notifications_fetcher/notifications_fetcher.service.js') diff --git a/src/services/notifications_fetcher/notifications_fetcher.service.js b/src/services/notifications_fetcher/notifications_fetcher.service.js index 21540845..c91a86c8 100644 --- a/src/services/notifications_fetcher/notifications_fetcher.service.js +++ b/src/services/notifications_fetcher/notifications_fetcher.service.js @@ -52,9 +52,11 @@ const fetchAndUpdate = ({ store, credentials, older = false, since }) => { 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 }) + if (minId !== Infinity) { + 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 }) + } } return result -- cgit v1.2.3-70-g09d2