mirror of
https://github.com/penpot/penpot.git
synced 2025-01-29 18:09:19 -05:00
Merge pull request #3476 from penpot/niwinz-staging-hotfix-4
✨ Improve ws-conn handling on session expiration
This commit is contained in:
commit
2ec5a3ba6a
2 changed files with 26 additions and 25 deletions
|
@ -50,6 +50,23 @@
|
||||||
(mf/mount (mf/element ui/app) (dom/get-element "app"))
|
(mf/mount (mf/element ui/app) (dom/get-element "app"))
|
||||||
(mf/mount (mf/element modal) (dom/get-element "modal")))
|
(mf/mount (mf/element modal) (dom/get-element "modal")))
|
||||||
|
|
||||||
|
(defn- initialize-profile
|
||||||
|
"Event used mainly on application bootstrap; it fetches the profile
|
||||||
|
and if and only if the fetched profile corresponds to an
|
||||||
|
authenticated user; proceed to fetch teams."
|
||||||
|
[stream]
|
||||||
|
(rx/merge
|
||||||
|
(rx/of (du/fetch-profile))
|
||||||
|
(->> stream
|
||||||
|
(rx/filter (ptk/type? ::profile-fetched))
|
||||||
|
(rx/take 1)
|
||||||
|
(rx/map deref)
|
||||||
|
(rx/mapcat (fn [profile]
|
||||||
|
(if (du/is-authenticated? profile)
|
||||||
|
(rx/of (du/fetch-teams))
|
||||||
|
(rx/empty))))
|
||||||
|
(rx/observe-on :async))))
|
||||||
|
|
||||||
(defn initialize
|
(defn initialize
|
||||||
[]
|
[]
|
||||||
(ptk/reify ::initialize
|
(ptk/reify ::initialize
|
||||||
|
@ -61,14 +78,19 @@
|
||||||
(watch [_ _ stream]
|
(watch [_ _ stream]
|
||||||
(rx/merge
|
(rx/merge
|
||||||
(rx/of (ev/initialize)
|
(rx/of (ev/initialize)
|
||||||
(feat/initialize)
|
(feat/initialize))
|
||||||
(du/initialize-profile))
|
|
||||||
|
|
||||||
|
(initialize-profile stream)
|
||||||
|
|
||||||
|
;; Once profile is fetched, initialize all penpot application
|
||||||
|
;; routes
|
||||||
(->> stream
|
(->> stream
|
||||||
(rx/filter du/profile-fetched?)
|
(rx/filter du/profile-fetched?)
|
||||||
(rx/take 1)
|
(rx/take 1)
|
||||||
(rx/map #(rt/init-routes)))
|
(rx/map #(rt/init-routes)))
|
||||||
|
|
||||||
|
;; Once profile fetched and the current user is authenticated,
|
||||||
|
;; proceed to initialize the websockets connection.
|
||||||
(->> stream
|
(->> stream
|
||||||
(rx/filter du/profile-fetched?)
|
(rx/filter du/profile-fetched?)
|
||||||
(rx/map deref)
|
(rx/map deref)
|
||||||
|
|
|
@ -117,28 +117,6 @@
|
||||||
(->> (rp/cmd! :get-profile)
|
(->> (rp/cmd! :get-profile)
|
||||||
(rx/map profile-fetched)))))
|
(rx/map profile-fetched)))))
|
||||||
|
|
||||||
;; --- EVENT: INITIALIZE PROFILE
|
|
||||||
|
|
||||||
(defn initialize-profile
|
|
||||||
"Event used mainly on application bootstrap; it fetches the profile
|
|
||||||
and if and only if the fetched profile corresponds to an
|
|
||||||
authenticated user; proceed to fetch teams."
|
|
||||||
[]
|
|
||||||
(ptk/reify ::initialize-profile
|
|
||||||
ptk/WatchEvent
|
|
||||||
(watch [_ _ stream]
|
|
||||||
(rx/merge
|
|
||||||
(rx/of (fetch-profile))
|
|
||||||
(->> stream
|
|
||||||
(rx/filter (ptk/type? ::profile-fetched))
|
|
||||||
(rx/take 1)
|
|
||||||
(rx/map deref)
|
|
||||||
(rx/mapcat (fn [profile]
|
|
||||||
(if (= uuid/zero (:id profile))
|
|
||||||
(rx/empty)
|
|
||||||
(rx/of (fetch-teams)))))
|
|
||||||
(rx/observe-on :async))))))
|
|
||||||
|
|
||||||
;; --- EVENT: login
|
;; --- EVENT: login
|
||||||
|
|
||||||
(defn- logged-in
|
(defn- logged-in
|
||||||
|
@ -164,7 +142,8 @@
|
||||||
(when (is-authenticated? profile)
|
(when (is-authenticated? profile)
|
||||||
(->> (rx/of (profile-fetched profile)
|
(->> (rx/of (profile-fetched profile)
|
||||||
(fetch-teams)
|
(fetch-teams)
|
||||||
(get-redirect-event))
|
(get-redirect-event)
|
||||||
|
(ws/initialize))
|
||||||
(rx/observe-on :async)))))))
|
(rx/observe-on :async)))))))
|
||||||
|
|
||||||
(declare login-from-register)
|
(declare login-from-register)
|
||||||
|
|
Loading…
Add table
Reference in a new issue