mirror of
https://github.com/penpot/penpot.git
synced 2025-02-02 04:19:08 -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.websocket :as ws]
|
||||
[app.main.errors]
|
||||
[app.main.features :as features]
|
||||
[app.main.store :as st]
|
||||
[app.main.ui :as ui]
|
||||
[app.main.ui.alert]
|
||||
|
@ -26,7 +27,6 @@
|
|||
[app.util.theme :as theme]
|
||||
[beicon.core :as rx]
|
||||
[debug]
|
||||
[features]
|
||||
[potok.core :as ptk]
|
||||
[rumext.v2 :as mf]))
|
||||
|
||||
|
@ -57,6 +57,7 @@
|
|||
(watch [_ _ stream]
|
||||
(rx/merge
|
||||
(rx/of (ev/initialize)
|
||||
(features/initialize)
|
||||
(du/initialize-profile))
|
||||
|
||||
(->> stream
|
||||
|
|
|
@ -11,12 +11,13 @@
|
|||
[app.config :as cf]
|
||||
[app.main.store :as st]
|
||||
[app.util.timers :as tm]
|
||||
[beicon.core :as rx]
|
||||
[cuerdas.core :as str]
|
||||
[okulary.core :as l]
|
||||
[potok.core :as ptk]
|
||||
[rumext.v2 :as mf]))
|
||||
|
||||
(log/set-level! :trace)
|
||||
(log/set-level! :warn)
|
||||
|
||||
(def available-features
|
||||
#{:auto-layout :components-v2})
|
||||
|
@ -78,20 +79,28 @@
|
|||
active-feature? (mf/deref active-feature-ref)]
|
||||
active-feature?))
|
||||
|
||||
;; Enable all features set on the configuration
|
||||
(->> @cf/flags
|
||||
(map name)
|
||||
(keep (fn [flag]
|
||||
(when (str/starts-with? flag "frontend-feature-")
|
||||
(subs flag 17))))
|
||||
(map keyword)
|
||||
(run! enable-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
|
||||
(->> (rx/from @cf/flags)
|
||||
(rx/map name)
|
||||
(rx/map (fn [flag]
|
||||
(when (str/starts-with? flag "frontend-feature-")
|
||||
(subs flag 17))))
|
||||
(rx/filter some?)
|
||||
(rx/map keyword)
|
||||
(rx/map enable-feature))
|
||||
|
||||
;; Enable the rest of available configuration if we are on development
|
||||
;; environemnt (aka devenv).
|
||||
(when *assert*
|
||||
;; By default, all features disabled, except in development
|
||||
;; environment, that are enabled except components-v2
|
||||
(->> available-features
|
||||
(remove #(= % :components-v2))
|
||||
(run! enable-feature!)))
|
||||
;; Enable the rest of available configuration if we are on development
|
||||
;; environemnt (aka devenv).
|
||||
(when *assert*
|
||||
;; By default, all features disabled, except in development
|
||||
;; environment, that are enabled except components-v2
|
||||
(->> (rx/from available-features)
|
||||
(rx/filter #(not= % :components-v2))
|
||||
(rx/map enable-feature)))))))
|
||||
|
|
Loading…
Add table
Reference in a new issue