aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/components/notifications/notifications.js3
-rw-r--r--src/modules/statuses.js24
-rw-r--r--src/modules/users.js2
3 files changed, 24 insertions, 5 deletions
diff --git a/src/components/notifications/notifications.js b/src/components/notifications/notifications.js
index 5e95631a..9fc5e38a 100644
--- a/src/components/notifications/notifications.js
+++ b/src/components/notifications/notifications.js
@@ -11,7 +11,8 @@ const Notifications = {
const store = this.$store
const credentials = store.state.users.currentUser.credentials
- notificationsFetcher.startFetching({ store, credentials })
+ const fetcherId = notificationsFetcher.startFetching({ store, credentials })
+ this.$store.commit('setNotificationFetcher', { fetcherId })
},
data () {
return {
diff --git a/src/modules/statuses.js b/src/modules/statuses.js
index f1387461..7571b62a 100644
--- a/src/modules/statuses.js
+++ b/src/modules/statuses.js
@@ -19,7 +19,7 @@ const emptyTl = (userId = 0) => ({
flushMarker: 0
})
-export const defaultState = {
+export const defaultState = () => ({
allStatuses: [],
allStatusesObject: {},
maxId: 0,
@@ -30,7 +30,8 @@ export const defaultState = {
data: [],
idStore: {},
loading: false,
- error: false
+ error: false,
+ fetcherId: null
},
favorites: new Set(),
error: false,
@@ -45,7 +46,7 @@ export const defaultState = {
tag: emptyTl(),
dms: emptyTl()
}
-}
+})
export const prepareStatus = (status) => {
// Set deleted flag
@@ -335,6 +336,15 @@ export const mutations = {
oldTimeline.visibleStatusesObject = {}
each(oldTimeline.visibleStatuses, (status) => { oldTimeline.visibleStatusesObject[status.id] = status })
},
+ setNotificationFetcher (state, { fetcherId }) {
+ state.notifications.fetcherId = fetcherId
+ },
+ resetStatuses (state) {
+ const emptyState = defaultState()
+ Object.entries(emptyState).forEach(([key, value]) => {
+ state[key] = value
+ })
+ },
clearTimeline (state, { timeline }) {
state.timelines[timeline] = emptyTl(state.timelines[timeline].userId)
},
@@ -385,7 +395,7 @@ export const mutations = {
}
const statuses = {
- state: defaultState,
+ state: defaultState(),
actions: {
addNewStatuses ({ rootState, commit }, { statuses, showImmediately = false, timeline = false, noIdUpdate = false, userId }) {
commit('addNewStatuses', { statuses, showImmediately, timeline, noIdUpdate, user: rootState.users.currentUser, userId })
@@ -405,6 +415,12 @@ const statuses = {
setNotificationsSilence ({ rootState, commit }, { value }) {
commit('setNotificationsSilence', { value })
},
+ stopFetchingNotifications ({ rootState, commit }) {
+ if (rootState.statuses.notifications.fetcherId) {
+ window.clearInterval(rootState.statuses.notifications.fetcherId)
+ }
+ commit('setNotificationFetcher', { fetcherId: null })
+ },
deleteStatus ({ rootState, commit }, status) {
commit('setDeleted', { status })
apiService.deleteStatus({ id: status.id, credentials: rootState.users.currentUser.credentials })
diff --git a/src/modules/users.js b/src/modules/users.js
index 093af497..4159964c 100644
--- a/src/modules/users.js
+++ b/src/modules/users.js
@@ -295,6 +295,8 @@ const users = {
store.commit('setToken', false)
store.dispatch('stopFetching', 'friends')
store.commit('setBackendInteractor', backendInteractorService())
+ store.dispatch('stopFetchingNotifications')
+ store.commit('resetStatuses')
},
loginUser (store, accessToken) {
return new Promise((resolve, reject) => {