From e5894ceea1b0cc483e370a1524f89f82f79ad460 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 10 Dec 2024 14:45:56 +0100 Subject: [PATCH] :recycle: Rename workspace-libraries to libraries on state and refs --- frontend/src/app/main/data/changes.cljs | 6 ++--- frontend/src/app/main/data/persistence.cljs | 2 +- frontend/src/app/main/data/workspace.cljs | 6 ++--- .../app/main/data/workspace/libraries.cljs | 26 +++++++++---------- .../main/data/workspace/notifications.cljs | 2 +- .../main/data/workspace/state_helpers.cljs | 8 +++--- frontend/src/app/main/refs.cljs | 3 --- .../ui/viewer/inspect/attributes/common.cljs | 2 +- .../ui/viewer/inspect/attributes/text.cljs | 2 +- .../main/ui/viewer/inspect/right_sidebar.cljs | 5 +--- .../app/main/ui/workspace/color_palette.cljs | 2 +- .../ui/workspace/color_palette_ctx_menu.cljs | 2 +- .../ui/workspace/colorpicker/libraries.cljs | 2 +- .../src/app/main/ui/workspace/libraries.cljs | 4 +-- .../app/main/ui/workspace/sidebar/assets.cljs | 4 +-- .../ui/workspace/sidebar/assets/common.cljs | 6 ++--- .../workspace/sidebar/assets/components.cljs | 4 +-- .../main/ui/workspace/sidebar/options.cljs | 2 +- .../sidebar/options/menus/component.cljs | 6 ++--- .../workspace/sidebar/options/menus/text.cljs | 2 +- .../sidebar/options/rows/color_row.cljs | 2 +- .../sidebar/options/shapes/text.cljs | 2 +- .../app/main/ui/workspace/text_palette.cljs | 2 +- .../ui/workspace/text_palette_ctx_menu.cljs | 7 +++-- frontend/src/app/plugins/api.cljs | 4 +-- frontend/src/app/plugins/library.cljs | 4 +-- frontend/src/app/plugins/utils.cljs | 10 +++---- frontend/src/debug.cljs | 8 +++--- 28 files changed, 64 insertions(+), 71 deletions(-) diff --git a/frontend/src/app/main/data/changes.cljs b/frontend/src/app/main/data/changes.cljs index 4da9215a2..341357e98 100644 --- a/frontend/src/app/main/data/changes.cljs +++ b/frontend/src/app/main/data/changes.cljs @@ -79,7 +79,7 @@ (let [current-file-id (get state :current-file-id) path (if (= file-id current-file-id) [:workspace-data] - [:workspace-libraries file-id :data]) + [:libraries file-id :data]) undo-changes (if pending (->> pending @@ -159,14 +159,14 @@ (let [file (:workspace-file state)] (if (= (:id file) file-id) (:revn file) - (dm/get-in state [:workspace-libraries file-id :revn])))) + (dm/get-in state [:libraries file-id :revn])))) (defn- resolve-file-vern [state file-id] (let [file (:workspace-file state)] (if (= (:id file) file-id) (:vern file) - (dm/get-in state [:workspace-libraries file-id :vern])))) + (dm/get-in state [:libraries file-id :vern])))) (defn commit-changes "Schedules a list of changes to execute now, and add the corresponding undo changes to diff --git a/frontend/src/app/main/data/persistence.cljs b/frontend/src/app/main/data/persistence.cljs index 12112ca91..759bc0fb9 100644 --- a/frontend/src/app/main/data/persistence.cljs +++ b/frontend/src/app/main/data/persistence.cljs @@ -52,7 +52,7 @@ (if-let [current-file-id (:current-file-id state)] (if (= file-id current-file-id) (update-in state [:workspace-file :revn] max revn) - (d/update-in-when state [:workspace-libraries file-id :revn] max revn)) + (d/update-in-when state [:libraries file-id :revn] max revn)) state)) ptk/EffectEvent diff --git a/frontend/src/app/main/data/workspace.cljs b/frontend/src/app/main/data/workspace.cljs index bf802087d..c289ec5ca 100644 --- a/frontend/src/app/main/data/workspace.cljs +++ b/frontend/src/app/main/data/workspace.cljs @@ -172,7 +172,7 @@ (ptk/reify ::libraries-fetched ptk/UpdateEvent (update [_ state] - (assoc state :workspace-libraries (d/index-by :id libraries))) + (assoc state :libraries (d/index-by :id libraries))) ptk/WatchEvent (watch [_ state _] @@ -363,7 +363,7 @@ :workspace-data :workspace-editor-state :workspace-file - :workspace-libraries + :libraries :workspace-media-objects :workspace-persistence :workspace-presence @@ -572,7 +572,7 @@ (let [file-data (if (= file-id (:current-file-id state)) (:workspace-data state) - (get-in state [:workspace-libraries file-id :data])) + (get-in state [:libraries file-id :data])) changes (-> (pcb/empty-changes it) diff --git a/frontend/src/app/main/data/workspace/libraries.cljs b/frontend/src/app/main/data/workspace/libraries.cljs index 7fd97095d..6a6ac39dd 100644 --- a/frontend/src/app/main/data/workspace/libraries.cljs +++ b/frontend/src/app/main/data/workspace/libraries.cljs @@ -59,11 +59,11 @@ ;; Change this to :info :debug or :trace to debug this module, or :warn to reset to default (log/set-level! :warn) -(defn- pretty-file +(defn- debug-pretty-file [file-id state] (if (= file-id (:current-file-id state)) "" - (str "<" (get-in state [:workspace-libraries file-id :name]) ">"))) + (str "<" (get-in state [:libraries file-id :name]) ">"))) (defn- log-changes [changes file] @@ -760,9 +760,9 @@ ptk/UpdateEvent (update [_ state] (-> state - (update-in [:workspace-libraries library-id] + (update-in [:libraries library-id] assoc :modified-at modified-at :revn revn) - (d/update-in-when [:workspace-libraries library-id :data] + (d/update-in-when [:libraries library-id :data] ch/process-changes changes))) ptk/WatchEvent @@ -898,7 +898,7 @@ current-file? (= current-file-id file-id) data (if current-file? (get state :workspace-data) - (get-in state [:workspace-libraries file-id :data])) + (get-in state [:libraries file-id :data])) component (ctkl/get-component data component-id) page-id (:main-instance-page component) root-id (:main-instance-id component)] @@ -1022,7 +1022,7 @@ (watch [_ state _] (let [undo-id (js/Symbol)] (log/info :msg "COMPONENT-SWAP" - :file (pretty-file file-id state) + :file (debug-pretty-file file-id state) :id-new-component id-new-component :undo-id undo-id) (rx/concat @@ -1068,15 +1068,15 @@ (update [_ state] (if (and (not= library-id (:current-file-id state)) (nil? asset-id)) - (d/assoc-in-when state [:workspace-libraries library-id :synced-at] (dt/now)) + (d/assoc-in-when state [:libraries library-id :synced-at] (dt/now)) state)) ptk/WatchEvent (watch [it state _] (when (and (some? file-id) (some? library-id)) ; Prevent race conditions while navigating out of the file (log/info :msg "SYNC-FILE" - :file (pretty-file file-id state) - :library (pretty-file library-id state) + :file (debug-pretty-file file-id state) + :library (debug-pretty-file library-id state) :asset-type asset-type :asset-id asset-id :undo-group undo-group) @@ -1172,7 +1172,7 @@ (let [file-data (:workspace-data state) ignore-until (dm/get-in state [:workspace-file :ignore-sync-until]) libraries-need-sync (filter #(seq (assets-need-sync % file-data ignore-until)) - (vals (get state :workspace-libraries))) + (vals (get state :libraries))) do-more-info #(modal/show! :libraries-dialog {:starting-tab "updates"}) do-update #(do (apply st/emit! (map (fn [library] (sync-file (:current-file-id state) @@ -1359,7 +1359,7 @@ (let [libraries (:workspace-shared-files state) library (d/seek #(= (:id %) library-id) libraries)] (if library - (update state :workspace-libraries assoc library-id (dissoc library :library-summary)) + (update state :libraries assoc library-id (dissoc library :library-summary)) state))) ptk/WatchEvent @@ -1373,7 +1373,7 @@ (rx/merge-map fpmap/resolve-file) (rx/map (fn [file] (fn [state] - (assoc-in state [:workspace-libraries library-id] file))))) + (assoc-in state [:libraries library-id] file))))) (->> (rp/cmd! :get-file-object-thumbnails {:file-id library-id :tag "component"}) (rx/map (fn [thumbnails] (fn [state] @@ -1391,7 +1391,7 @@ ptk/UpdateEvent (update [_ state] - (d/dissoc-in state [:workspace-libraries library-id])) + (d/dissoc-in state [:libraries library-id])) ptk/WatchEvent (watch [_ _ _] diff --git a/frontend/src/app/main/data/workspace/notifications.cljs b/frontend/src/app/main/data/workspace/notifications.cljs index 55e6baba7..e59e7b92b 100644 --- a/frontend/src/app/main/data/workspace/notifications.cljs +++ b/frontend/src/app/main/data/workspace/notifications.cljs @@ -314,6 +314,6 @@ (ptk/reify ::handle-library-change ptk/WatchEvent (watch [_ state _] - (when (contains? (:workspace-libraries state) file-id) + (when (contains? (:libraries state) file-id) (rx/of (dwl/ext-library-changed file-id modified-at revn changes) (dwl/notify-sync-file file-id)))))) diff --git a/frontend/src/app/main/data/workspace/state_helpers.cljs b/frontend/src/app/main/data/workspace/state_helpers.cljs index 4d33f2838..eefcb7428 100644 --- a/frontend/src/app/main/data/workspace/state_helpers.cljs +++ b/frontend/src/app/main/data/workspace/state_helpers.cljs @@ -29,7 +29,7 @@ (defn lookup-library-objects [state file-id page-id] - (dm/get-in state [:workspace-libraries file-id :data :pages-index page-id :objects])) + (dm/get-in state [:libraries file-id :data :pages-index page-id :objects])) (defn lookup-objects [state file-id page-id] @@ -108,7 +108,7 @@ [state file-id] (if (= file-id (:current-file-id state)) (get state :workspace-data) - (dm/get-in state [:workspace-libraries file-id :data]))) + (dm/get-in state [:libraries file-id :data]))) (defn get-file-full "Get the data content of the given file (it may be the current file @@ -117,13 +117,13 @@ (if (= file-id (:current-file-id state)) (-> (get state :workspace-file) (assoc :data (get state :workspace-data))) - (dm/get-in state [:workspace-libraries file-id :data]))) + (dm/get-in state [:libraries file-id :data]))) (defn get-libraries "Retrieve all libraries, including the local file." [state] (let [{:keys [id] :as local} (:workspace-data state)] - (-> (:workspace-libraries state) + (-> (:libraries state) (assoc id {:id id :data local})))) diff --git a/frontend/src/app/main/refs.cljs b/frontend/src/app/main/refs.cljs index 61bfa3983..5b7cdc14e 100644 --- a/frontend/src/app/main/refs.cljs +++ b/frontend/src/app/main/refs.cljs @@ -264,9 +264,6 @@ :components])) st/state =)) -(def workspace-libraries - (l/derived :workspace-libraries st/state)) - (def workspace-presence (l/derived :workspace-presence st/state)) diff --git a/frontend/src/app/main/ui/viewer/inspect/attributes/common.cljs b/frontend/src/app/main/ui/viewer/inspect/attributes/common.cljs index b5c26b07f..fcc2eb250 100644 --- a/frontend/src/app/main/ui/viewer/inspect/attributes/common.cljs +++ b/frontend/src/app/main/ui/viewer/inspect/attributes/common.cljs @@ -39,7 +39,7 @@ mf/deref) colors-library-ws (-> (mf/use-memo (mf/deps (:file-id color)) - #(make-colors-library-ref :workspace-libraries (:file-id color))) + #(make-colors-library-ref :libraries (:file-id color))) mf/deref)] (or colors-library-v colors-library-ws))) diff --git a/frontend/src/app/main/ui/viewer/inspect/attributes/text.cljs b/frontend/src/app/main/ui/viewer/inspect/attributes/text.cljs index 66cf55eb3..03c9de511 100644 --- a/frontend/src/app/main/ui/viewer/inspect/attributes/text.cljs +++ b/frontend/src/app/main/ui/viewer/inspect/attributes/text.cljs @@ -59,7 +59,7 @@ file-typographies-viewer (mf/deref file-typographies-ref) file-typographies-workspace (mf/deref refs/workspace-file-typography) - file-library-workspace (get (mf/deref refs/workspace-libraries) (:typography-ref-file style)) + file-library-workspace (get (mf/deref refs/libraries) (:typography-ref-file style)) typography-external-lib (get-in file-library-workspace [:data :typographies (:typography-ref-id style)]) color-format (mf/use-state :hex) diff --git a/frontend/src/app/main/ui/viewer/inspect/right_sidebar.cljs b/frontend/src/app/main/ui/viewer/inspect/right_sidebar.cljs index 1ccf82636..29aff8a27 100644 --- a/frontend/src/app/main/ui/viewer/inspect/right_sidebar.cljs +++ b/frontend/src/app/main/ui/viewer/inspect/right_sidebar.cljs @@ -7,7 +7,6 @@ (ns app.main.ui.viewer.inspect.right-sidebar (:require-macros [app.main.style :as stl]) (:require - [app.common.data.macros :as dm] [app.common.types.component :as ctk] [app.main.data.event :as ev] [app.main.refs :as refs] @@ -29,7 +28,7 @@ (if (= from :workspace) (let [workspace-data (deref refs/workspace-data) {:keys [id] :as local} workspace-data - libraries (deref refs/workspace-libraries)] + libraries (deref refs/libraries)] (-> libraries (assoc id {:id id :data local}))) @@ -54,8 +53,6 @@ file-id (or file-id (:id file)) libraries (get-libraries from) - - file (mf/deref refs/viewer-file) main-instance? (ctk/main-instance? first-shape) handle-change-tab diff --git a/frontend/src/app/main/ui/workspace/color_palette.cljs b/frontend/src/app/main/ui/workspace/color_palette.cljs index e12ec9c23..e1dfb52fa 100644 --- a/frontend/src/app/main/ui/workspace/color_palette.cljs +++ b/frontend/src/app/main/ui/workspace/color_palette.cljs @@ -157,7 +157,7 @@ [{:keys [size width selected] :as props}] (let [recent-colors (mf/deref refs/workspace-recent-colors) file-colors (mf/deref refs/workspace-file-colors) - shared-libs (mf/deref refs/workspace-libraries) + shared-libs (mf/deref refs/libraries) colors (mf/use-state [])] (mf/with-effect [selected shared-libs] diff --git a/frontend/src/app/main/ui/workspace/color_palette_ctx_menu.cljs b/frontend/src/app/main/ui/workspace/color_palette_ctx_menu.cljs index 17dbb9450..9d9097d04 100644 --- a/frontend/src/app/main/ui/workspace/color_palette_ctx_menu.cljs +++ b/frontend/src/app/main/ui/workspace/color_palette_ctx_menu.cljs @@ -19,7 +19,7 @@ [{:keys [show-menu? close-menu on-select-palette selected]}] (let [recent-colors (mf/deref refs/workspace-recent-colors) file-colors (mf/deref refs/workspace-file-colors) - shared-libs (mf/deref refs/workspace-libraries)] + shared-libs (mf/deref refs/libraries)] [:& dropdown {:show show-menu? :on-close close-menu} [:ul {:class (stl/css :palette-menu)} diff --git a/frontend/src/app/main/ui/workspace/colorpicker/libraries.cljs b/frontend/src/app/main/ui/workspace/colorpicker/libraries.cljs index 66120bfdd..22524b678 100644 --- a/frontend/src/app/main/ui/workspace/colorpicker/libraries.cljs +++ b/frontend/src/app/main/ui/workspace/colorpicker/libraries.cljs @@ -30,7 +30,7 @@ (let [selected (h/use-shared-state mdc/colorpicker-selected-broadcast-key :recent) current-colors (mf/use-state []) - shared-libs (mf/deref refs/workspace-libraries) + shared-libs (mf/deref refs/libraries) file-colors (mf/deref refs/workspace-file-colors) recent-colors (mf/deref refs/workspace-recent-colors) recent-colors (h/use-equal-memo (filter #(or (:gradient %) (:color %) (:image %)) recent-colors)) diff --git a/frontend/src/app/main/ui/workspace/libraries.cljs b/frontend/src/app/main/ui/workspace/libraries.cljs index 915f95fca..872f7d8db 100644 --- a/frontend/src/app/main/ui/workspace/libraries.cljs +++ b/frontend/src/app/main/ui/workspace/libraries.cljs @@ -62,7 +62,7 @@ (let [fdata (let [{:keys [id] :as wfile} (:workspace-data state)] (if (= id library-id) wfile - (dm/get-in state [:workspace-libraries library-id :data])))] + (dm/get-in state [:libraries library-id :data])))] {:colors (-> fdata :colors vals) :media (-> fdata :media vals) :components (ctkl/components-seq fdata) @@ -557,7 +557,7 @@ file-id (:id file) shared? (:is-shared file) - libraries (mf/deref refs/workspace-libraries) + libraries (mf/deref refs/libraries) libraries (mf/with-memo [libraries] (d/removem (fn [[_ val]] (:is-indirect val)) libraries)) diff --git a/frontend/src/app/main/ui/workspace/sidebar/assets.cljs b/frontend/src/app/main/ui/workspace/sidebar/assets.cljs index 850c0b515..bd0fa05f6 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/assets.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/assets.cljs @@ -31,7 +31,7 @@ ::mf/props :obj ::mf/private true} [{:keys [filters]}] - (let [libraries (mf/deref refs/workspace-libraries) + (let [libraries (mf/deref refs/libraries) libraries (mf/with-memo [libraries] (->> (vals libraries) (remove :is-indirect) @@ -88,7 +88,7 @@ section (:section filters) ordering (:ordering filters) reverse-sort? (= :desc ordering) - num-libs (count (mf/deref refs/workspace-libraries)) + num-libs (count (mf/deref refs/libraries)) toggle-ordering (mf/use-fn diff --git a/frontend/src/app/main/ui/workspace/sidebar/assets/common.cljs b/frontend/src/app/main/ui/workspace/sidebar/assets/common.cljs index 6af530691..20f4bdafa 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/assets/common.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/assets/common.cljs @@ -315,17 +315,17 @@ current-file-id (mf/use-ctx ctx/current-file-id) objects (deref refs/workspace-page-objects) workspace-data (deref refs/workspace-data) - workspace-libraries (deref refs/workspace-libraries) + libraries (deref refs/libraries) current-file {:id current-file-id :data workspace-data} find-component (fn [shape include-deleted?] (ctf/resolve-component - shape current-file workspace-libraries {:include-deleted? include-deleted?})) + shape current-file libraries {:include-deleted? include-deleted?})) local-or-exists (fn [shape] (let [library-id (:component-file shape)] (or (= library-id current-file-id) - (some? (get workspace-libraries library-id))))) + (some? (get libraries library-id))))) restorable-copies (->> copies (filter #(nil? (find-component % false))) diff --git a/frontend/src/app/main/ui/workspace/sidebar/assets/components.cljs b/frontend/src/app/main/ui/workspace/sidebar/assets/components.cljs index 0b3a5d1c1..f94ebbb4c 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/assets/components.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/assets/components.cljs @@ -50,7 +50,7 @@ (if components-v2 (ctf/get-component-page data component) component)]) - (let [data (dm/get-in @refs/workspace-libraries [file-id :data]) + (let [data (dm/get-in @refs/libraries [file-id :data]) root-shape (ctf/get-component-root data component) container (if components-v2 (ctf/get-component-page data component) @@ -466,7 +466,7 @@ (fn [component event] (let [file-data - (d/nilv (dm/get-in @refs/workspace-libraries [file-id :data]) @refs/workspace-data) + (d/nilv (dm/get-in @refs/libraries [file-id :data]) @refs/workspace-data) shape-main (ctf/get-component-root file-data component)] diff --git a/frontend/src/app/main/ui/workspace/sidebar/options.cljs b/frontend/src/app/main/ui/workspace/sidebar/options.cljs index 3d61627ed..ebf93ffb8 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options.cljs @@ -78,7 +78,7 @@ [{:keys [selected objects page-id file-id selected-shapes shapes-with-children]}] (let [sp-panel (mf/deref refs/specialized-panel) drawing (mf/deref refs/workspace-drawing) - shared-libs (mf/deref refs/workspace-libraries) + shared-libs (mf/deref refs/libraries) edition (mf/deref refs/selected-edition) edit-grid? (ctl/grid-layout? objects edition) grid-edition (mf/deref refs/workspace-grid-edition) diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.cljs index 926f03e0f..fd095088a 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.cljs @@ -272,7 +272,7 @@ (letfn [(get-libraries [state] (let [file (:workspace-file state) data (:workspace-data state) - libs (:workspace-libraries state)] + libs (:libraries state)] (assoc libs (:id file) (assoc file :data data))))] (l/derived get-libraries st/state))) @@ -524,7 +524,7 @@ (let [current-file-id (mf/use-ctx ctx/current-file-id) components-v2 (mf/use-ctx ctx/components-v2) workspace-data (deref refs/workspace-data) - workspace-libraries (deref refs/workspace-libraries) + libraries (deref refs/libraries) state* (mf/use-state {:show-content true :menu-open false}) @@ -544,7 +544,7 @@ component (ctf/resolve-component shape {:id current-file-id :data workspace-data} - workspace-libraries + libraries {:include-deleted? true}) main-instance? (if components-v2 (ctk/main-instance? shape) true) diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/menus/text.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/menus/text.cljs index 813657d71..e2363c52a 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/menus/text.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/menus/text.cljs @@ -184,7 +184,7 @@ (let [file-id (mf/use-ctx ctx/current-file-id) typographies (mf/deref refs/workspace-file-typography) - shared-libs (mf/deref refs/workspace-libraries) + shared-libs (mf/deref refs/libraries) label (case type :multiple (tr "workspace.options.text-options.title-selection") :group (tr "workspace.options.text-options.title-group") diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/rows/color_row.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/rows/color_row.cljs index e513f1c0f..286596bb1 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/rows/color_row.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/rows/color_row.cljs @@ -51,7 +51,7 @@ disable-drag on-focus on-blur select-only select-on-focus]}] (let [current-file-id (mf/use-ctx ctx/current-file-id) file-colors (mf/deref refs/workspace-file-colors) - shared-libs (mf/deref refs/workspace-libraries) + shared-libs (mf/deref refs/libraries) hover-detach (mf/use-state false) on-change (h/use-ref-callback on-change) src-colors (if (= (:file-id color) current-file-id) diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/shapes/text.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/shapes/text.cljs index ae912c12b..7fdcc2c96 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/shapes/text.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/shapes/text.cljs @@ -53,7 +53,7 @@ (mf/deref refs/workspace-v2-editor-state) (mf/deref refs/workspace-editor-state)) - shared-libs (mf/deref refs/workspace-libraries) + shared-libs (mf/deref refs/libraries) editor-state (when (not (features/active-feature? @st/state "text-editor/v2")) (get state-map (:id shape))) diff --git a/frontend/src/app/main/ui/workspace/text_palette.cljs b/frontend/src/app/main/ui/workspace/text_palette.cljs index 9cb76e456..7c92895dc 100644 --- a/frontend/src/app/main/ui/workspace/text_palette.cljs +++ b/frontend/src/app/main/ui/workspace/text_palette.cljs @@ -183,7 +183,7 @@ [{:keys [size width selected] :as props}] (let [selected-ids (mf/deref refs/selected-shapes) file-typographies (mf/deref refs/workspace-file-typography) - shared-libs (mf/deref refs/workspace-libraries) + shared-libs (mf/deref refs/libraries) current-file-id (mf/use-ctx ctx/current-file-id)] [:& palette {:current-file-id current-file-id :selected-ids selected-ids diff --git a/frontend/src/app/main/ui/workspace/text_palette_ctx_menu.cljs b/frontend/src/app/main/ui/workspace/text_palette_ctx_menu.cljs index 3f1b573df..568e6a84e 100644 --- a/frontend/src/app/main/ui/workspace/text_palette_ctx_menu.cljs +++ b/frontend/src/app/main/ui/workspace/text_palette_ctx_menu.cljs @@ -14,11 +14,10 @@ [app.util.i18n :refer [tr]] [rumext.v2 :as mf])) - (mf/defc text-palette-ctx-menu [{:keys [show-menu? close-menu on-select-palette selected]}] - (let [file-typographies (mf/deref refs/workspace-file-typography) - shared-libs (mf/deref refs/workspace-libraries)] + (let [typographies (mf/deref refs/workspace-file-typography) + shared-libs (mf/deref refs/libraries)] [:& dropdown {:show show-menu? :on-close close-menu} [:ul {:class (stl/css :text-context-menu)} @@ -49,7 +48,7 @@ [:span {:class (stl/css :lib-name)} (tr "workspace.libraries.colors.file-library")] [:span {:class (stl/css :lib-num)} - (dm/str "(" (count file-typographies) ")")]] + (dm/str "(" (count typographies) ")")]] (when (= selected :file) [:span {:class (stl/css :icon-wrapper)} i/tick])]]])) diff --git a/frontend/src/app/plugins/api.cljs b/frontend/src/app/plugins/api.cljs index 2c7157f4c..7b059d7c2 100644 --- a/frontend/src/app/plugins/api.cljs +++ b/frontend/src/app/plugins/api.cljs @@ -160,7 +160,7 @@ (map #(obj/get % "$id")) (mapcat #(cfh/get-children-with-self objects %))) file-id (:current-file-id @st/state) - shared-libs (:workspace-libraries @st/state)] + shared-libs (:libraries @st/state)] (->> (ctc/extract-all-colors shapes file-id shared-libs) (group-by :attrs) @@ -182,7 +182,7 @@ :else (let [file-id (:current-file-id @st/state) - shared-libs (:workspace-libraries @st/state) + shared-libs (:libraries @st/state) objects (u/locate-objects) shapes (->> shapes diff --git a/frontend/src/app/plugins/library.cljs b/frontend/src/app/plugins/library.cljs index 29b8b15b0..5e41f4d5c 100644 --- a/frontend/src/app/plugins/library.cljs +++ b/frontend/src/app/plugins/library.cljs @@ -929,7 +929,7 @@ :connected {:get (fn [] - (let [libraries (get @st/state :workspace-libraries)] + (let [libraries (get @st/state :libraries)] (apply array (->> libraries keys (map (partial library-proxy plugin-id))))))} :availableLibraries @@ -937,7 +937,7 @@ (let [team-id (:current-team-id @st/state)] (js/Promise. (fn [resolve reject] - (let [current-libs (into #{} (map first) (get @st/state :workspace-libraries))] + (let [current-libs (into #{} (map first) (get @st/state :libraries))] (->> (rp/cmd! :get-team-shared-files {:team-id team-id}) (rx/map (fn [result] (->> result diff --git a/frontend/src/app/plugins/utils.cljs b/frontend/src/app/plugins/utils.cljs index 63aea0eed..51d5216f7 100644 --- a/frontend/src/app/plugins/utils.cljs +++ b/frontend/src/app/plugins/utils.cljs @@ -20,7 +20,7 @@ (if (= id (:current-file-id @st/state)) (-> (:workspace-file @st/state) (assoc :data (:workspace-data @st/state))) - (dm/get-in @st/state [:workspace-libraries id]))) + (dm/get-in @st/state [:libraries id]))) (defn locate-page [file-id id] @@ -65,10 +65,10 @@ (defn locate-component [objects shape] (let [current-file-id (:current-file-id @st/state) - workspace-data (:workspace-data @st/state) - workspace-libraries (:workspace-libraries @st/state) - root (ctn/get-instance-root objects shape)] - [root (ctf/resolve-component root {:id current-file-id :data workspace-data} workspace-libraries {:include-deleted? true})])) + workspace-data (:workspace-data @st/state) + libraries (:libraries @st/state) + root (ctn/get-instance-root objects shape)] + [root (ctf/resolve-component root {:id current-file-id :data workspace-data} libraries {:include-deleted? true})])) (defn proxy->file [proxy] diff --git a/frontend/src/debug.cljs b/frontend/src/debug.cljs index 8290e09e9..d4bea0de7 100644 --- a/frontend/src/debug.cljs +++ b/frontend/src/debug.cljs @@ -248,7 +248,7 @@ (let [page-id (get state :current-page-id) file (assoc (get state :workspace-file) :data (get state :workspace-data)) - libraries (get state :workspace-libraries)] + libraries (get state :libraries)] (ctf/dump-tree file page-id libraries {:show-ids show-ids :show-touched show-touched :show-modified show-modified})))) @@ -266,7 +266,7 @@ (let [page-id (get state :current-page-id) file (assoc (get state :workspace-file) :data (get state :workspace-data)) - libraries (get state :workspace-libraries) + libraries (get state :libraries) shape-id (if (some? shape-id) (uuid/uuid shape-id) (let [objects (get-in state [:workspace-data :pages-index page-id :objects]) @@ -383,7 +383,7 @@ ([shape-id] (let [file (assoc (get @st/state :workspace-file) :data (get @st/state :workspace-data)) - libraries (get @st/state :workspace-libraries)] + libraries (get @st/state :libraries)] (try (->> (if-let [shape-id (some-> shape-id parse-uuid)] @@ -417,7 +417,7 @@ fdata (get state :workspace-data) file (assoc file :data fdata) - libs (get state :workspace-libraries) + libs (get state :libraries) errors (cfv/validate-file file libs) _ (l/dbg :hint "repair current file" :errors (count errors))