|
|
@ -35,16 +35,18 @@ const api = {
|
|
|
|
enableMastoSockets (store) {
|
|
|
|
enableMastoSockets (store) {
|
|
|
|
const { state, dispatch } = store
|
|
|
|
const { state, dispatch } = store
|
|
|
|
if (state.mastoUserSocket) return
|
|
|
|
if (state.mastoUserSocket) return
|
|
|
|
dispatch('startMastoUserSocket')
|
|
|
|
return dispatch('startMastoUserSocket')
|
|
|
|
},
|
|
|
|
},
|
|
|
|
disableMastoSockets (store) {
|
|
|
|
disableMastoSockets (store) {
|
|
|
|
const { state, dispatch } = store
|
|
|
|
const { state, dispatch } = store
|
|
|
|
if (!state.mastoUserSocket) return
|
|
|
|
if (!state.mastoUserSocket) return
|
|
|
|
dispatch('stopMastoUserSocket')
|
|
|
|
return dispatch('stopMastoUserSocket')
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
// MastoAPI 'User' sockets
|
|
|
|
// MastoAPI 'User' sockets
|
|
|
|
startMastoUserSocket (store) {
|
|
|
|
startMastoUserSocket (store) {
|
|
|
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
|
|
|
try {
|
|
|
|
const { state, dispatch } = store
|
|
|
|
const { state, dispatch } = store
|
|
|
|
state.mastoUserSocket = state.backendInteractor.startUserSocket({ store })
|
|
|
|
state.mastoUserSocket = state.backendInteractor.startUserSocket({ store })
|
|
|
|
state.mastoUserSocket.addEventListener(
|
|
|
|
state.mastoUserSocket.addEventListener(
|
|
|
@ -84,11 +86,16 @@ const api = {
|
|
|
|
dispatch('restartMastoUserSocket')
|
|
|
|
dispatch('restartMastoUserSocket')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
resolve()
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
|
|
reject(e)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
restartMastoUserSocket ({ dispatch }) {
|
|
|
|
restartMastoUserSocket ({ dispatch }) {
|
|
|
|
// This basically starts MastoAPI user socket and stops conventional
|
|
|
|
// This basically starts MastoAPI user socket and stops conventional
|
|
|
|
// fetchers when connection reestablished
|
|
|
|
// fetchers when connection reestablished
|
|
|
|
dispatch('startMastoUserSocket').then(() => {
|
|
|
|
return dispatch('startMastoUserSocket').then(() => {
|
|
|
|
dispatch('stopFetchingTimeline', { timeline: 'friends' })
|
|
|
|
dispatch('stopFetchingTimeline', { timeline: 'friends' })
|
|
|
|
dispatch('stopFetchingNotifications')
|
|
|
|
dispatch('stopFetchingNotifications')
|
|
|
|
})
|
|
|
|
})
|
|
|
|