Adjust data profile alias

This commit is contained in:
Andrey Antukh 2024-11-26 20:34:57 +01:00
parent c6b96a81f1
commit f31e2b72e6
2 changed files with 17 additions and 17 deletions

View file

@ -12,7 +12,7 @@
[app.config :as cf]
[app.main.data.auth :as da]
[app.main.data.event :as ev]
[app.main.data.profile :as du]
[app.main.data.profile :as dp]
[app.main.data.websocket :as ws]
[app.main.errors]
[app.main.features :as feat]
@ -67,14 +67,14 @@
authenticated user; proceed to fetch teams."
[stream]
(rx/merge
(rx/of (du/fetch-profile))
(rx/of (dp/fetch-profile))
(->> stream
(rx/filter du/profile-fetched?)
(rx/filter dp/profile-fetched?)
(rx/take 1)
(rx/map deref)
(rx/mapcat (fn [profile]
(if (du/is-authenticated? profile)
(rx/of (du/initialize-profile profile))
(if (dp/is-authenticated? profile)
(rx/of (dp/initialize-profile profile))
(rx/empty))))
(rx/observe-on :async))))
@ -95,22 +95,22 @@
;; Watch for profile deletion events
(->> stream
(rx/filter du/profile-deleted?)
(rx/filter dp/profile-deleted?)
(rx/map da/logged-out))
;; Once profile is fetched, initialize all penpot application
;; routes
(->> stream
(rx/filter du/profile-fetched?)
(rx/filter dp/profile-fetched?)
(rx/take 1)
(rx/map #(rt/init-routes)))
;; Once profile fetched and the current user is authenticated,
;; proceed to initialize the websockets connection.
(->> stream
(rx/filter du/profile-fetched?)
(rx/filter dp/profile-fetched?)
(rx/map deref)
(rx/filter du/is-authenticated?)
(rx/filter dp/is-authenticated?)
(rx/take 1)
(rx/map #(ws/initialize)))))))