diff --git a/frontend/src/app/main/data/workspace.cljs b/frontend/src/app/main/data/workspace.cljs index 620cbd821..2bd275501 100644 --- a/frontend/src/app/main/data/workspace.cljs +++ b/frontend/src/app/main/data/workspace.cljs @@ -1350,15 +1350,19 @@ (ptk/reify ::show-component-in-assets ptk/WatchEvent (watch [_ state _] - (let [project-id (get-in state [:workspace-project :id]) - file-id (get-in state [:workspace-file :id]) - page-id (get state :current-page-id) - pparams {:file-id file-id :project-id project-id} - qparams {:page-id page-id :layout :assets}] - (rx/of (rt/nav :workspace pparams qparams) - (set-assets-section-open file-id :library true) - (set-assets-section-open file-id :components true) - (select-single-asset file-id component-id :components)))) + (let [project-id (get-in state [:workspace-project :id]) + file-id (get-in state [:workspace-file :id]) + page-id (get state :current-page-id) + pparams {:file-id file-id :project-id project-id} + qparams {:page-id page-id :layout :assets} + component-path (cph/split-path (get-in state [:workspace-data :components component-id :path])) + paths (map (fn [i] (cph/join-path (take (inc i) component-path))) (range (count component-path)))] + (rx/concat + (rx/from (map #(set-assets-group-open file-id :components % true) paths)) + (rx/of (rt/nav :workspace pparams qparams) + (set-assets-section-open file-id :library true) + (set-assets-section-open file-id :components true) + (select-single-asset file-id component-id :components))))) ptk/EffectEvent (effect [_ _ _] diff --git a/frontend/src/app/main/data/workspace/libraries.cljs b/frontend/src/app/main/data/workspace/libraries.cljs index a38cc7abf..a3424b7e0 100644 --- a/frontend/src/app/main/data/workspace/libraries.cljs +++ b/frontend/src/app/main/data/workspace/libraries.cljs @@ -842,6 +842,15 @@ (def valid-asset-types #{:colors :components :typographies}) +(defn set-updating-library + [updating?] + (ptk/reify ::set-updating-library + ptk/UpdateEvent + (update [_ state] + (if updating? + (assoc state :updating-library true) + (dissoc state :updating-library))))) + (defn sync-file "Synchronize the given file from the given library. Walk through all shapes in all pages in the file that use some color, typography or @@ -912,7 +921,8 @@ (:redo-changes changes) file)) (rx/concat - (rx/of (msg/hide-tag :sync-dialog)) + (rx/of (set-updating-library false) + (msg/hide-tag :sync-dialog)) (when (seq (:redo-changes changes)) (rx/of (dch/commit-changes (assoc changes ;; TODO a ver qué pasa con esto :file-id file-id)))) diff --git a/frontend/src/app/main/refs.cljs b/frontend/src/app/main/refs.cljs index 4eaf864e3..283901616 100644 --- a/frontend/src/app/main/refs.cljs +++ b/frontend/src/app/main/refs.cljs @@ -576,3 +576,6 @@ (def specialized-panel (l/derived :specialized-panel st/state)) + +(def updating-library + (l/derived :updating-library st/state)) diff --git a/frontend/src/app/main/ui/workspace/libraries.cljs b/frontend/src/app/main/ui/workspace/libraries.cljs index 85a312635..ba7f845df 100644 --- a/frontend/src/app/main/ui/workspace/libraries.cljs +++ b/frontend/src/app/main/ui/workspace/libraries.cljs @@ -441,9 +441,8 @@ {::mf/wrap-props false} [{:keys [file-id file-data libraries]}] (let [summary?* (mf/use-state true) - updating?* (mf/use-state false) summary? (deref summary?*) - updating? (deref updating?*) + updating? (mf/deref refs/updating-library) see-all-assets (mf/use-fn @@ -467,8 +466,9 @@ (let [library-id (some-> (dom/get-target event) (dom/get-data "library-id") (parse-uuid))] - (reset! updating?* true) - (st/emit! (dwl/sync-file file-id library-id))))))] + (st/emit! + (dwl/set-updating-library true) + (dwl/sync-file file-id library-id))))))] (if new-css-system [:div {:class (stl/css :section)} 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 5938dc450..ba14db0ce 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/assets/common.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/assets/common.cljs @@ -334,7 +334,7 @@ local-component? (= library-id current-file-id) component (find-component shape) - lacks-annotation? (nil? (:annotation shape)) + lacks-annotation? (nil? (:annotation component)) is-dangling? (nil? component) can-update-main? (or (not components-v2)