mirror of
https://github.com/penpot/penpot.git
synced 2026-05-02 22:58:35 +00:00
🐛 Fix incorrect subscription fetching after profile registration
This commit is contained in:
parent
a7552d412a
commit
dedeae8641
@ -195,7 +195,9 @@
|
||||
(ptk/reify ::login-from-token
|
||||
ptk/WatchEvent
|
||||
(watch [_ _ _]
|
||||
(->> (rx/of (logged-in (with-meta profile {::ev/source "login-with-token"})))
|
||||
(->> (dp/on-fetch-profile-success profile)
|
||||
(rx/map (fn [profile]
|
||||
(logged-in (with-meta profile {::ev/source "login-with-token"}))))
|
||||
;; NOTE: we need this to be asynchronous because the effect
|
||||
;; should be called before proceed with the login process
|
||||
(rx/observe-on :async)))))
|
||||
|
||||
@ -77,22 +77,25 @@
|
||||
(rx/of (rt/nav-raw :href href)))
|
||||
(rx/throw cause))))
|
||||
|
||||
(defn on-fetch-profile-success
|
||||
[profile]
|
||||
(if (and (contains? cf/flags :subscriptions)
|
||||
(is-authenticated? profile))
|
||||
(->> (rp/cmd! :get-subscription-usage {})
|
||||
(rx/map (fn [{:keys [editors]}]
|
||||
(update-in profile [:props :subscription] assoc :editors editors)))
|
||||
(rx/catch (fn [cause]
|
||||
(js/console.error "unexpected error on obtaining subscription usage" cause)
|
||||
(rx/of profile))))
|
||||
(rx/of profile)))
|
||||
|
||||
(defn fetch-profile
|
||||
[]
|
||||
(ptk/reify ::fetch-profile
|
||||
ptk/WatchEvent
|
||||
(watch [_ _ _]
|
||||
(->> (rp/cmd! :get-profile)
|
||||
(rx/mapcat (fn [profile]
|
||||
(if (and (contains? cf/flags :subscriptions)
|
||||
(is-authenticated? profile))
|
||||
(->> (rp/cmd! :get-subscription-usage {})
|
||||
(rx/map (fn [{:keys [editors]}]
|
||||
(update-in profile [:props :subscription] assoc :editors editors)))
|
||||
(rx/catch (fn [cause]
|
||||
(js/console.error "unexpected error on obtaining subscription usage" cause)
|
||||
(rx/of profile))))
|
||||
(rx/of profile))))
|
||||
(rx/mapcat on-fetch-profile-success)
|
||||
(rx/map (partial ptk/data-event ::profile-fetched))
|
||||
(rx/catch on-fetch-profile-exception)))))
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user