mirror of
https://github.com/penpot/penpot.git
synced 2025-04-09 21:41:23 -05:00
✨ Clear storage on user logout
This commit is contained in:
parent
b8c6103858
commit
1281670c61
1 changed files with 9 additions and 9 deletions
|
@ -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 {}))
|
||||
|
|
Loading…
Add table
Reference in a new issue