From 1281670c61dc4c3b05027a8f71253e740a7eb493 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 4 Sep 2024 16:18:46 +0200 Subject: [PATCH] :sparkles: Clear storage on user logout --- frontend/src/app/main/data/users.cljs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/frontend/src/app/main/data/users.cljs b/frontend/src/app/main/data/users.cljs index 1a61a0644d..3fc7427837 100644 --- a/frontend/src/app/main/data/users.cljs +++ b/frontend/src/app/main/data/users.cljs @@ -21,7 +21,7 @@ [app.main.repo :as rp] [app.util.i18n :as i18n :refer [tr]] [app.util.router :as rt] - [app.util.storage :refer [storage]] + [app.util.storage :as s] [beicon.v2.core :as rx] [potok.v2.core :as ptk])) @@ -49,14 +49,14 @@ (defn get-current-team-id [profile] - (let [team-id (::current-team-id @storage)] + (let [team-id (::current-team-id @s/storage)] (or team-id (:default-team-id profile)))) (defn set-current-team! [team-id] (if (nil? team-id) - (swap! storage dissoc ::current-team-id) - (swap! storage assoc ::current-team-id team-id))) + (swap! s/storage dissoc ::current-team-id) + (swap! s/storage assoc ::current-team-id team-id))) ;; --- EVENT: fetch-teams @@ -76,9 +76,9 @@ ;; if not, dissoc it from storage. (let [ids (into #{} (map :id) teams)] - (when-let [ctid (::current-team-id @storage)] + (when-let [ctid (::current-team-id @s/storage)] (when-not (contains? ids ctid) - (swap! storage dissoc ::current-team-id))))))) + (swap! s/storage dissoc ::current-team-id))))))) (defn fetch-teams [] @@ -129,10 +129,10 @@ (effect [_ state _] (let [profile (:profile state) email (:email profile) - previous-profile (:profile @storage) + previous-profile (:profile @s/storage) previous-email (:email previous-profile)] (when profile - (swap! storage assoc :profile profile) + (swap! s/storage assoc :profile profile) (i18n/set-locale! (:lang profile)) (when (not= previous-email email) (set-current-team! nil))))))) @@ -311,7 +311,7 @@ ptk/EffectEvent (effect [_ _ _] ;; We prefer to keek some stuff in the storage like the current-team-id and the profile - (set-current-team! nil))))) + (swap! s/storage (constantly {})))))) (defn logout ([] (logout {}))