remove unnecessary fetchAndUpdate, change notifications fetcher to not double fetch

This commit is contained in:
Shpuld Shpuldson 2020-07-01 14:15:04 +03:00
parent 82944f862d
commit 62d0bc47b3
4 changed files with 5 additions and 14 deletions

View file

@ -56,11 +56,6 @@ const Notifications = {
components: {
Notification
},
created () {
const { dispatch } = this.$store
dispatch('fetchAndUpdateNotifications')
},
watch: {
unseenCount (count) {
if (count > 0) {

View file

@ -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) {

View file

@ -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 })
},

View file

@ -31,9 +31,12 @@ 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)
const possibleMax = Math.max(...readNotifsIds)
if (possibleMax !== timelineData.maxId) {
args['since'] = possibleMax
fetchNotifications({ store, args, older })
}
}
return result
}