From cc07c7a580a7a1281c96b8b089fe03c0151b3ba4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Moya?= Date: Thu, 28 Sep 2023 17:02:15 +0200 Subject: [PATCH] :sparkles: Ensure features is always initialized, even after logout --- .../src/app/common/types/components_list.cljc | 6 +-- frontend/src/app/config.cljs | 2 +- frontend/src/app/main/data/dashboard.cljs | 38 ++++++++++--------- frontend/src/app/main/data/workspace.cljs | 1 + frontend/src/app/main/features.cljs | 2 +- 5 files changed, 26 insertions(+), 23 deletions(-) diff --git a/common/src/app/common/types/components_list.cljc b/common/src/app/common/types/components_list.cljc index bcec70c24..39dbdc43e 100644 --- a/common/src/app/common/types/components_list.cljc +++ b/common/src/app/common/types/components_list.cljc @@ -8,7 +8,7 @@ (:require [app.common.data :as d] [app.common.data.macros :as dm] - [app.common.files.features :as feat] + [app.common.files.features :as ffeat] [app.common.time :as dt] [app.common.types.component :as ctk])) @@ -40,7 +40,7 @@ (cond-> (update-in fdata [:components id] assoc :main-instance-id main-instance-id :main-instance-page main-instance-page) annotation (update-in [:components id] assoc :annotation annotation)) - (let [wrap-object-fn feat/*wrap-with-objects-map-fn*] + (let [wrap-object-fn ffeat/*wrap-with-objects-map-fn*] (assoc-in fdata [:components id :objects] (->> shapes (d/index-by :id) @@ -48,7 +48,7 @@ (defn mod-component [file-data {:keys [id name path main-instance-id main-instance-page objects annotation]}] - (let [wrap-objects-fn feat/*wrap-with-objects-map-fn*] + (let [wrap-objects-fn ffeat/*wrap-with-objects-map-fn*] (d/update-in-when file-data [:components id] (fn [component] (let [objects (some-> objects wrap-objects-fn)] diff --git a/frontend/src/app/config.cljs b/frontend/src/app/config.cljs index aede5e11f..67612ebf8 100644 --- a/frontend/src/app/config.cljs +++ b/frontend/src/app/config.cljs @@ -82,7 +82,7 @@ date))) -;; --- Globar Config Vars +;; --- Global Config Vars (def default-theme "default") (def default-language "en") diff --git a/frontend/src/app/main/data/dashboard.cljs b/frontend/src/app/main/data/dashboard.cljs index 13cef28fe..2f2c1cb48 100644 --- a/frontend/src/app/main/data/dashboard.cljs +++ b/frontend/src/app/main/data/dashboard.cljs @@ -58,25 +58,27 @@ ptk/WatchEvent (watch [_ state stream] - (rx/merge - ;;fetch teams must be first in case the team doesn't exist - (ptk/watch (du/fetch-teams) state stream) - (ptk/watch (df/load-team-fonts id) state stream) - (ptk/watch (fetch-projects) state stream) - (ptk/watch (fetch-team-members) state stream) - (ptk/watch (du/fetch-users {:team-id id}) state stream) + (rx/concat + (rx/of (features/initialize)) + (rx/merge + ;; fetch teams must be first in case the team doesn't exist + (ptk/watch (du/fetch-teams) state stream) + (ptk/watch (df/load-team-fonts id) state stream) + (ptk/watch (fetch-projects) state stream) + (ptk/watch (fetch-team-members) state stream) + (ptk/watch (du/fetch-users {:team-id id}) state stream) - (let [stoper (rx/filter (ptk/type? ::finalize) stream) - profile-id (:profile-id state)] - (->> stream - (rx/filter (ptk/type? ::dws/message)) - (rx/map deref) - (rx/filter (fn [{:keys [subs-id type] :as msg}] - (and (or (= subs-id uuid/zero) - (= subs-id profile-id)) - (= :notification type)))) - (rx/map handle-notification) - (rx/take-until stoper))))))) + (let [stoper (rx/filter (ptk/type? ::finalize) stream) + profile-id (:profile-id state)] + (->> stream + (rx/filter (ptk/type? ::dws/message)) + (rx/map deref) + (rx/filter (fn [{:keys [subs-id type] :as msg}] + (and (or (= subs-id uuid/zero) + (= subs-id profile-id)) + (= :notification type)))) + (rx/map handle-notification) + (rx/take-until stoper)))))))) (defn finalize [params] diff --git a/frontend/src/app/main/data/workspace.cljs b/frontend/src/app/main/data/workspace.cljs index 77593b5bd..8bcd1d7bd 100644 --- a/frontend/src/app/main/data/workspace.cljs +++ b/frontend/src/app/main/data/workspace.cljs @@ -316,6 +316,7 @@ ptk/WatchEvent (watch [_ _ _] (rx/of msg/hide + (features/initialize) (dcm/retrieve-comment-threads file-id) (dwp/initialize-file-persistence file-id) (fetch-bundle project-id file-id))) diff --git a/frontend/src/app/main/features.cljs b/frontend/src/app/main/features.cljs index a922dac97..85c753e05 100644 --- a/frontend/src/app/main/features.cljs +++ b/frontend/src/app/main/features.cljs @@ -100,7 +100,7 @@ ;; environemnt (aka devenv). (when *assert* ;; By default, all features disabled, except in development - ;; environment, that are enabled except components-v2 + ;; environment, that are enabled except components-v2 and new css (->> (rx/from available-features) (rx/filter #(not= % :components-v2)) (rx/filter #(not= % :new-css-system))