From 0c717c579b812e70acecec48c73c927c16e32f4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Moya?= Date: Wed, 17 Aug 2022 14:28:37 +0200 Subject: [PATCH] :bug: Some small fixes * Remove an unneeded condition in sync. * Correctly duplicate main instances. * Slightly enhance sync logging. --- .../src/app/main/data/workspace/libraries.cljs | 13 +++++++++---- .../main/data/workspace/libraries_helpers.cljs | 17 ++++++++--------- .../src/app/main/data/workspace/selection.cljs | 3 ++- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/frontend/src/app/main/data/workspace/libraries.cljs b/frontend/src/app/main/data/workspace/libraries.cljs index d460cbf89..769ee703f 100644 --- a/frontend/src/app/main/data/workspace/libraries.cljs +++ b/frontend/src/app/main/data/workspace/libraries.cljs @@ -637,7 +637,9 @@ (when (and (some? file-id) (some? library-id)) ; Prevent race conditions while navigating out of the file (log/info :msg "SYNC-FILE" :file (dwlh/pretty-file file-id state) - :library (dwlh/pretty-file library-id state)) + :library (dwlh/pretty-file library-id state) + :asset-type asset-type + :asset-id asset-id) (let [file (wsh/get-file state file-id) sync-components? (or (nil? asset-type) (= asset-type :components)) @@ -713,10 +715,11 @@ (pcb/empty-changes it) [(dwlh/generate-sync-file it file-id :components asset-id library-id state) (dwlh/generate-sync-library it file-id :components asset-id library-id state)])] + + (log/debug :msg "SYNC-FILE (2nd stage) finished" :js/rchanges (log-changes + (:redo-changes changes) + file)) (when (seq (:redo-changes changes)) - (log/debug :msg "SYNC-FILE (2nd stage) finished" :js/rchanges (log-changes - (:redo-changes changes) - file)) (rx/of (dch/commit-changes (assoc changes :file-id file-id)))))))) (def ignore-sync @@ -788,6 +791,8 @@ #{} changes)] (when (d/not-empty? components-changed) + (log/info :msg "DETECTED COMPONENTS CHANGED" + :ids (map str components-changed)) (run! st/emit! (map #(update-component-sync % (:id data)) components-changed)))))] diff --git a/frontend/src/app/main/data/workspace/libraries_helpers.cljs b/frontend/src/app/main/data/workspace/libraries_helpers.cljs index 7126bce51..f48b3ba45 100644 --- a/frontend/src/app/main/data/workspace/libraries_helpers.cljs +++ b/frontend/src/app/main/data/workspace/libraries_helpers.cljs @@ -237,7 +237,7 @@ (log/debug :msg "Sync component in local library" :component-id (:id container))) (let [linked-shapes (->> (vals (:objects container)) - (filter #(uses-assets? asset-type asset-id % library-id (cph/page? container))))] + (filter #(uses-assets? asset-type asset-id % library-id)))] (loop [shapes (seq linked-shapes) changes (-> (pcb/empty-changes it) (pcb/with-container container) @@ -254,23 +254,22 @@ (defmulti uses-assets? "Checks if a shape uses some asset of the given type in the given library." - (fn [asset-type _ _ _ _] asset-type)) + (fn [asset-type _ _ _] asset-type)) (defmethod uses-assets? :components - [_ component-id shape library-id page?] - (and (if (nil? component-id) - (ctk/uses-library-components? shape library-id) - (ctk/instance-of? shape library-id component-id)) - (or (:component-root? shape) (not page?)))) ; avoid nested components inside pages + [_ component-id shape library-id] + (if (nil? component-id) + (ctk/uses-library-components? shape library-id) + (ctk/instance-of? shape library-id component-id))) (defmethod uses-assets? :colors - [_ color-id shape library-id _] + [_ color-id shape library-id] (if (nil? color-id) (ctc/uses-library-colors? shape library-id) (ctc/uses-library-color? shape library-id color-id))) (defmethod uses-assets? :typographies - [_ typography-id shape library-id _] + [_ typography-id shape library-id] (if (nil? typography-id) (cty/uses-library-typographies? shape library-id) (cty/uses-library-typography? shape library-id typography-id))) diff --git a/frontend/src/app/main/data/workspace/selection.cljs b/frontend/src/app/main/data/workspace/selection.cljs index 3348ce30d..f58572368 100644 --- a/frontend/src/app/main/data/workspace/selection.cljs +++ b/frontend/src/app/main/data/workspace/selection.cljs @@ -360,7 +360,8 @@ :name name :parent-id parent-id :frame-id frame-id) - (dissoc :shapes) + (dissoc :shapes + :main-instance?) (gsh/move delta) (d/update-when :interactions #(ctsi/remap-interactions % ids-map objects)))