From e8dde477a576199aa862fc1500de6fd7f95b657c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Moya?= Date: Wed, 21 Jun 2023 17:04:11 +0200 Subject: [PATCH] :bug: Fix restore remote component --- frontend/src/app/main/data/workspace/libraries.cljs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/frontend/src/app/main/data/workspace/libraries.cljs b/frontend/src/app/main/data/workspace/libraries.cljs index 2b8be6910..2a2d17e8a 100644 --- a/frontend/src/app/main/data/workspace/libraries.cljs +++ b/frontend/src/app/main/data/workspace/libraries.cljs @@ -453,9 +453,9 @@ (ptk/reify ::restore-component ptk/WatchEvent (watch [it state _] - (let [page-id (:current-page-id state) - current-page (dm/get-in state [:workspace-data :pages-index page-id]) - objects (wsh/lookup-page-objects state page-id) + (let [page-id (:current-page-id state) + current-page (dm/get-in state [:workspace-data :pages-index page-id]) + objects (wsh/lookup-page-objects state page-id) library-data (wsh/get-file state library-id) {:keys [changes shape]} (dwlh/prepare-restore-component library-data component-id current-page it) parent-id (:parent-id shape) @@ -464,14 +464,13 @@ (update-in [parent-id :shapes] #(conj % (:id shape)))) - ;; Adds a resize-parents operation so the groups are updated. We add all the new objects new-objects-ids (->> changes :redo-changes (filter #(= (:type %) :add-obj)) (mapv :id)) changes (-> changes (pcb/with-objects objects) (pcb/resize-parents new-objects-ids))] - (rx/of (dch/commit-changes changes)))))) + (rx/of (dch/commit-changes (assoc changes :file-id library-id))))))) (defn instantiate-component "Create a new shape in the current page, from the component with the given id @@ -480,7 +479,6 @@ (dm/assert! (uuid? file-id)) (dm/assert! (uuid? component-id)) (dm/assert! (gpt/point? position)) - (ptk/reify ::instantiate-component ptk/WatchEvent (watch [it state _]