From 5996954c4a542503e575577b857dd97f3ab18d59 Mon Sep 17 00:00:00 2001 From: eugenijm Date: Sun, 24 May 2020 22:04:36 +0300 Subject: [PATCH] Reset the chat list on logout --- src/modules/chats.js | 12 ++++++++++-- src/modules/users.js | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/modules/chats.js b/src/modules/chats.js index 0e18723a..99c80290 100644 --- a/src/modules/chats.js +++ b/src/modules/chats.js @@ -100,6 +100,10 @@ const chats = { deleteChatMessage ({ rootState, commit, dispatch }, value) { rootState.api.backendInteractor.deleteChatMessage(value) commit('deleteChatMessage', { commit, ...value }) + }, + resetChats ({ commit, dispatch }) { + dispatch('clearCurrentChat') + commit('resetChats', { commit }) } }, mutations: { @@ -154,8 +158,12 @@ const chats = { state.chats.idStore = omitBy(state.chats.idStore, conversation => conversation.last_status.id === id) }, resetChats (state, { _dispatch }) { - state.chats.data = [] - state.chats.idStore = {} + state.chatList = emptyChatList() + state.chats.openedChats = {} + state.chats.openedChatMessageServices = {} + state.chats.fetcher = undefined + state.chats.chatFocused = false + state.chats.currentChatId = null }, setChatsLoading (state, { value }) { state.chats.loading = value diff --git a/src/modules/users.js b/src/modules/users.js index 2c69fe37..f6de206a 100644 --- a/src/modules/users.js +++ b/src/modules/users.js @@ -495,6 +495,7 @@ const users = { store.dispatch('stopFetchingFollowRequests') store.commit('clearNotifications') store.commit('resetStatuses') + store.dispatch('resetChats') }) }, loginUser (store, accessToken) {