From 291180816abbb421d38034b9bcdb4b0e10a9242d Mon Sep 17 00:00:00 2001 From: Pablo Alba Date: Mon, 5 Jun 2023 16:12:02 +0200 Subject: [PATCH] :bug: Fix go to main component on another page --- frontend/src/app/main/data/workspace.cljs | 28 ++++++++++++++++------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/frontend/src/app/main/data/workspace.cljs b/frontend/src/app/main/data/workspace.cljs index 7da23cae8..bfc4609ec 100644 --- a/frontend/src/app/main/data/workspace.cljs +++ b/frontend/src/app/main/data/workspace.cljs @@ -1172,7 +1172,6 @@ (ptk/reify ::select-single-asset ptk/UpdateEvent (update [_ state] - (prn "select-single-asset" file-id asset-id type) (assoc-in state [:workspace-assets :selected file-id type] #{asset-id})))) (defn select-assets @@ -1211,7 +1210,21 @@ current-project-id (:current-project-id state) file-id (or file-id current-file-id) - redirect-to + select-and-zoom + (fn [shape-id] + (rx/of (dws/select-shapes (d/ordered-set shape-id)) + dwz/zoom-to-selected-shape)) + + redirect-to-page + (fn [page-id shape-id] + (rx/concat + (rx/of (go-to-page page-id)) + (->> stream + (rx/filter (ptk/type? ::initialize-page)) + (rx/take 1)) + (select-and-zoom shape-id))) + + redirect-to-file (fn [file-id page-id] (let [pparams {:file-id file-id :project-id current-project-id} qparams {:page-id page-id}] @@ -1227,17 +1240,16 @@ (if (= file-id current-file-id) (let [component (dm/get-in state [:workspace-data :components component-id]) - page-id (:main-instance-page component)] + page-id (:main-instance-page component) + shape-id (:main-instance-id component)] (when (some? page-id) (if (= page-id current-page-id) - (let [shape-id (:main-instance-id component)] - (rx/of (dws/select-shapes (d/ordered-set shape-id)) - dwz/zoom-to-selected-shape)) - (redirect-to current-file-id page-id)))) + (select-and-zoom shape-id) + (redirect-to-page page-id shape-id)))) (let [component (dm/get-in state [:workspace-libraries file-id :data :components component-id])] (some->> (:main-instance-page component) - (redirect-to file-id)))))))) + (redirect-to-file file-id)))))))) (defn go-to-component