improved initial notifications fetching
This commit is contained in:
parent
319bb4ac28
commit
172ebaf4e6
4 changed files with 33 additions and 6 deletions
|
@ -31,18 +31,32 @@ const api = {
|
|||
},
|
||||
actions: {
|
||||
startMastoSocket (store) {
|
||||
store.state.mastoSocket = store.state.backendInteractor
|
||||
const { state, dispatch } = store
|
||||
state.mastoSocket = state.backendInteractor
|
||||
.startUserSocket({
|
||||
store,
|
||||
onMessage: (message) => {
|
||||
if (!message) return
|
||||
if (message.event === 'notification') {
|
||||
store.dispatch('addNewNotifications', { notifications: [message.notification], older: false })
|
||||
dispatch('addNewNotifications', {
|
||||
notifications: [message.notification],
|
||||
older: false
|
||||
})
|
||||
} else if (message.event === 'update') {
|
||||
store.dispatch('addNewStatuses', { statuses: [message.status], userId: false, showImmediately: false, timeline: 'friends' })
|
||||
dispatch('addNewStatuses', {
|
||||
statuses: [message.status],
|
||||
userId: false,
|
||||
showImmediately: false,
|
||||
timeline: 'friends'
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
state.mastoSocket.addEventListener('error', error => {
|
||||
console.error('Error with MastoAPI websocket:', error)
|
||||
dispatch('startFetchingTimeline', { timeline: 'friends' })
|
||||
dispatch('startFetchingNotifications')
|
||||
})
|
||||
},
|
||||
startFetchingTimeline (store, { timeline = 'friends', tag = false, userId = false }) {
|
||||
// Don't start fetching if we already are.
|
||||
|
@ -58,6 +72,9 @@ const api = {
|
|||
const fetcher = store.state.backendInteractor.startFetchingNotifications({ store })
|
||||
store.commit('addFetcher', { fetcherName: 'notifications', fetcher })
|
||||
},
|
||||
fetchAndUpdateNotifications (store) {
|
||||
store.state.backendInteractor.fetchAndUpdateNotifications({ store })
|
||||
},
|
||||
startFetchingFollowRequest (store) {
|
||||
// Don't start fetching if we already are.
|
||||
if (store.state.fetchers['followRequest']) return
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue