mirror of
https://github.com/penpot/penpot.git
synced 2025-02-12 18:18:24 -05:00
Merge pull request #3097 from penpot/hiru-fix-features-detect
♻️ Enhance features loading to avoid race conditions
This commit is contained in:
commit
c1ed5a5b33
2 changed files with 28 additions and 18 deletions
|
@ -13,6 +13,7 @@
|
||||||
[app.main.data.users :as du]
|
[app.main.data.users :as du]
|
||||||
[app.main.data.websocket :as ws]
|
[app.main.data.websocket :as ws]
|
||||||
[app.main.errors]
|
[app.main.errors]
|
||||||
|
[app.main.features :as features]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.main.ui :as ui]
|
[app.main.ui :as ui]
|
||||||
[app.main.ui.alert]
|
[app.main.ui.alert]
|
||||||
|
@ -26,7 +27,6 @@
|
||||||
[app.util.theme :as theme]
|
[app.util.theme :as theme]
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
[debug]
|
[debug]
|
||||||
[features]
|
|
||||||
[potok.core :as ptk]
|
[potok.core :as ptk]
|
||||||
[rumext.v2 :as mf]))
|
[rumext.v2 :as mf]))
|
||||||
|
|
||||||
|
@ -57,6 +57,7 @@
|
||||||
(watch [_ _ stream]
|
(watch [_ _ stream]
|
||||||
(rx/merge
|
(rx/merge
|
||||||
(rx/of (ev/initialize)
|
(rx/of (ev/initialize)
|
||||||
|
(features/initialize)
|
||||||
(du/initialize-profile))
|
(du/initialize-profile))
|
||||||
|
|
||||||
(->> stream
|
(->> stream
|
||||||
|
|
|
@ -11,12 +11,13 @@
|
||||||
[app.config :as cf]
|
[app.config :as cf]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.util.timers :as tm]
|
[app.util.timers :as tm]
|
||||||
|
[beicon.core :as rx]
|
||||||
[cuerdas.core :as str]
|
[cuerdas.core :as str]
|
||||||
[okulary.core :as l]
|
[okulary.core :as l]
|
||||||
[potok.core :as ptk]
|
[potok.core :as ptk]
|
||||||
[rumext.v2 :as mf]))
|
[rumext.v2 :as mf]))
|
||||||
|
|
||||||
(log/set-level! :trace)
|
(log/set-level! :warn)
|
||||||
|
|
||||||
(def available-features
|
(def available-features
|
||||||
#{:auto-layout :components-v2})
|
#{:auto-layout :components-v2})
|
||||||
|
@ -78,20 +79,28 @@
|
||||||
active-feature? (mf/deref active-feature-ref)]
|
active-feature? (mf/deref active-feature-ref)]
|
||||||
active-feature?))
|
active-feature?))
|
||||||
|
|
||||||
|
(defn initialize
|
||||||
|
[]
|
||||||
|
(ptk/reify ::initialize
|
||||||
|
ptk/WatchEvent
|
||||||
|
(watch [_ _ _]
|
||||||
|
(log/trace :hint "event:initialize" :fn "features")
|
||||||
|
(rx/concat
|
||||||
;; Enable all features set on the configuration
|
;; Enable all features set on the configuration
|
||||||
(->> @cf/flags
|
(->> (rx/from @cf/flags)
|
||||||
(map name)
|
(rx/map name)
|
||||||
(keep (fn [flag]
|
(rx/map (fn [flag]
|
||||||
(when (str/starts-with? flag "frontend-feature-")
|
(when (str/starts-with? flag "frontend-feature-")
|
||||||
(subs flag 17))))
|
(subs flag 17))))
|
||||||
(map keyword)
|
(rx/filter some?)
|
||||||
(run! enable-feature!))
|
(rx/map keyword)
|
||||||
|
(rx/map enable-feature))
|
||||||
|
|
||||||
;; Enable the rest of available configuration if we are on development
|
;; Enable the rest of available configuration if we are on development
|
||||||
;; environemnt (aka devenv).
|
;; environemnt (aka devenv).
|
||||||
(when *assert*
|
(when *assert*
|
||||||
;; By default, all features disabled, except in development
|
;; By default, all features disabled, except in development
|
||||||
;; environment, that are enabled except components-v2
|
;; environment, that are enabled except components-v2
|
||||||
(->> available-features
|
(->> (rx/from available-features)
|
||||||
(remove #(= % :components-v2))
|
(rx/filter #(not= % :components-v2))
|
||||||
(run! enable-feature!)))
|
(rx/map enable-feature)))))))
|
||||||
|
|
Loading…
Add table
Reference in a new issue