From 62d0bc47b333135f31abea90b4f5a3c28e608733 Mon Sep 17 00:00:00 2001 From: Shpuld Shpuldson Date: Wed, 1 Jul 2020 14:15:04 +0300 Subject: [PATCH] remove unnecessary fetchAndUpdate, change notifications fetcher to not double fetch --- src/components/notifications/notifications.js | 5 ----- src/modules/api.js | 3 --- .../backend_interactor_service.js | 4 ---- .../notifications_fetcher/notifications_fetcher.service.js | 7 +++++-- 4 files changed, 5 insertions(+), 14 deletions(-) diff --git a/src/components/notifications/notifications.js b/src/components/notifications/notifications.js index 26ffbab6..e999a18e 100644 --- a/src/components/notifications/notifications.js +++ b/src/components/notifications/notifications.js @@ -56,11 +56,6 @@ const Notifications = { components: { Notification }, - created () { - const { dispatch } = this.$store - - dispatch('fetchAndUpdateNotifications') - }, watch: { unseenCount (count) { if (count > 0) { diff --git a/src/modules/api.js b/src/modules/api.js index 748570e5..04ef6ab4 100644 --- a/src/modules/api.js +++ b/src/modules/api.js @@ -138,9 +138,6 @@ const api = { if (!fetcher) return store.commit('removeFetcher', { fetcherName: 'notifications', fetcher }) }, - fetchAndUpdateNotifications (store) { - store.state.backendInteractor.fetchAndUpdateNotifications({ store }) - }, // Follow requests startFetchingFollowRequests (store) { diff --git a/src/services/backend_interactor_service/backend_interactor_service.js b/src/services/backend_interactor_service/backend_interactor_service.js index e1c32860..45e6bd0e 100644 --- a/src/services/backend_interactor_service/backend_interactor_service.js +++ b/src/services/backend_interactor_service/backend_interactor_service.js @@ -12,10 +12,6 @@ const backendInteractorService = credentials => ({ return notificationsFetcher.startFetching({ store, credentials }) }, - fetchAndUpdateNotifications ({ store }) { - return notificationsFetcher.fetchAndUpdate({ store, credentials }) - }, - startFetchingFollowRequests ({ store }) { return followRequestFetcher.startFetching({ store, credentials }) }, diff --git a/src/services/notifications_fetcher/notifications_fetcher.service.js b/src/services/notifications_fetcher/notifications_fetcher.service.js index 64499a1b..581931f5 100644 --- a/src/services/notifications_fetcher/notifications_fetcher.service.js +++ b/src/services/notifications_fetcher/notifications_fetcher.service.js @@ -31,8 +31,11 @@ const fetchAndUpdate = ({ store, credentials, older = false }) => { const notifications = timelineData.data const readNotifsIds = notifications.filter(n => n.seen).map(n => n.id) if (readNotifsIds.length) { - args['since'] = Math.max(...readNotifsIds) - fetchNotifications({ store, args, older }) + const possibleMax = Math.max(...readNotifsIds) + if (possibleMax !== timelineData.maxId) { + args['since'] = possibleMax + fetchNotifications({ store, args, older }) + } } return result