Clear state after vue instance was destroyed

This commit is contained in:
Angelina Filippova 2020-05-10 21:13:29 +03:00
parent 8e7eb99f1f
commit 8d1d9940c9
2 changed files with 13 additions and 3 deletions

View file

@ -58,6 +58,14 @@ const status = {
dispatch('FetchStatusesByInstance')
}
},
ClearState({ commit }) {
commit('CHANGE_SELECTED_INSTANCE', '')
commit('SET_STATUSES_BY_INSTANCE', [])
commit('CHANGE_LOCAL_CHECKBOX_VALUE', false)
commit('CHANGE_GODMODE_CHECKBOX_VALUE', false)
commit('SET_ALL_LOADED', false)
commit('CHANGE_PAGE', 1)
},
async DeleteStatus({ dispatch, getters }, { statusId, reportCurrentPage, userId, godmode, fetchStatusesByInstance }) {
await deleteStatus(statusId, getters.authHost, getters.token)
if (reportCurrentPage !== 0) { // called from Reports
@ -74,10 +82,9 @@ const status = {
commit('SET_STATUS_VISIBILITY', data.status_visibility)
commit('SET_LOADING', false)
},
async FetchStatusesByInstance({ commit, getters, state, rootState }) {
const { data } = await fetchStatusesCount(state.statusesByInstance.selectedInstance, getters.authHost, getters.token)
commit('SET_STATUS_VISIBILITY', data.status_visibility)
async FetchStatusesByInstance({ commit, dispatch, getters, state, rootState }) {
commit('SET_LOADING', true)
dispatch('FetchStatusesCount', state.statusesByInstance.selectedInstance)
if (state.statusesByInstance.selectedInstance === '') {
commit('SET_STATUSES_BY_INSTANCE', [])
} else {

View file

@ -142,6 +142,9 @@ export default {
this.$store.dispatch('FetchPeers')
this.$store.dispatch('FetchStatusesCount')
},
destroyed() {
this.$store.dispatch('ClearState')
},
methods: {
handleFilterChange() {
this.$store.dispatch('HandlePageChange', 1)