#392: stale data served to new user account

This commit is contained in:
dave 2019-02-28 14:03:44 -05:00
parent 24f3770fb5
commit ba2e05bc63
3 changed files with 18 additions and 4 deletions

View File

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

View File

@ -1,4 +1,4 @@
import { remove, slice, each, find, maxBy, minBy, merge, last, isArray } from 'lodash'
import { remove, slice, each, find, maxBy, minBy, merge, last, isArray, cloneDeep } from 'lodash'
import apiService from '../services/api/api.service.js'
// import parse from '../services/status_parser/status_parser.js'
@ -29,7 +29,8 @@ export const defaultState = {
data: [],
idStore: {},
loading: false,
error: false
error: false,
fetcherId: null
},
favorites: new Set(),
error: false,
@ -321,6 +322,14 @@ export const mutations = {
oldTimeline.visibleStatusesObject = {}
each(oldTimeline.visibleStatuses, (status) => { oldTimeline.visibleStatusesObject[status.id] = status })
},
setNotificationFetcher (state, { fetcherId }) {
state.notifications.fetcherId = fetcherId
},
resetStatuses (state) {
Object.keys(state).forEach(key => {
state[key] = cloneDeep(defaultState[key])
})
},
clearTimeline (state, { timeline }) {
state.timelines[timeline] = emptyTl(state.timelines[timeline].userId)
},
@ -371,7 +380,7 @@ export const mutations = {
}
const statuses = {
state: defaultState,
state: cloneDeep(defaultState),
actions: {
addNewStatuses ({ rootState, commit }, { statuses, showImmediately = false, timeline = false, noIdUpdate = false, userId }) {
commit('addNewStatuses', { statuses, showImmediately, timeline, noIdUpdate, user: rootState.users.currentUser, userId })

View File

@ -290,6 +290,10 @@ const users = {
store.commit('setToken', false)
store.dispatch('stopFetching', 'friends')
store.commit('setBackendInteractor', backendInteractorService())
if (store.rootState.statuses.notifications.fetcherId) {
window.clearInterval(store.rootState.statuses.notifications.fetcherId)
}
store.commit('resetStatuses')
},
loginUser (store, accessToken) {
return new Promise((resolve, reject) => {