From 45ac159e30b96a4425d37ed50a64c1d8a91d0dd4 Mon Sep 17 00:00:00 2001 From: "Fredrick W. Warren" Date: Mon, 15 Feb 2021 10:46:33 -0800 Subject: [PATCH] 23.02 Clear the State after User Logs Out --- src/store/store-auth.js | 2 +- src/store/store-tasks.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/store/store-auth.js b/src/store/store-auth.js index 53e79cd..228ea4d 100644 --- a/src/store/store-auth.js +++ b/src/store/store-auth.js @@ -35,7 +35,6 @@ const actions = { }) }, logoutUser () { - console.log('xx') firebaseAuth.signOut() }, handleAuthStateChange ({ commit, dispatch }) { @@ -47,6 +46,7 @@ const actions = { this.$router.push('/').catch(err => {}) dispatch('tasks/fbReadData', null, { root: true }) } else { + commit('tasks/clearTasks', null, { root: true }) commit('setLoggedIn', false) commit('/tasks/setTasksDownloaded', false, { root: true }) this.$router.replace('/auth').catch(err => { }) diff --git a/src/store/store-tasks.js b/src/store/store-tasks.js index bf8beee..94c4e3f 100644 --- a/src/store/store-tasks.js +++ b/src/store/store-tasks.js @@ -40,6 +40,9 @@ const mutations = { addTask (state, payload) { Vue.set(state.tasks, payload.id, payload.task) }, + clearTasks (state) { + state.tasks = {} + }, setSearch (state, value) { state.search = value },