diff --git a/frontend/src/app/main/data/workspace.cljs b/frontend/src/app/main/data/workspace.cljs index 7b5436f78..0a7d1159b 100644 --- a/frontend/src/app/main/data/workspace.cljs +++ b/frontend/src/app/main/data/workspace.cljs @@ -291,31 +291,30 @@ (ptk/reify ::fetch-bundle ptk/WatchEvent (watch [_ state stream] - (let [component-id (get-in state [:route :query-params :component-id])] - (->> (rx/merge - (rx/of (fetch-bundle-stage-1 project-id file-id)) + (->> (rx/merge + (rx/of (fetch-bundle-stage-1 project-id file-id)) + (->> stream + (rx/filter (ptk/type? ::bundle-stage-1)) + (rx/observe-on :async) + (rx/map deref) + (rx/map fetch-bundle-stage-2)) + + (->> stream + (rx/filter (ptk/type? ::bundle-stage-2)) + (rx/observe-on :async) + (rx/map deref) + (rx/map bundle-fetched)) + + (when-let [component-id (get-in state [:route :query-params :component-id])] (->> stream - (rx/filter (ptk/type? ::bundle-stage-1)) + (rx/filter (ptk/type? ::workspace-initialized)) (rx/observe-on :async) - (rx/map deref) - (rx/map fetch-bundle-stage-2)) + (rx/take 1) + (rx/map #(go-to-component (uuid/uuid component-id)))))) - (->> stream - (rx/filter (ptk/type? ::bundle-stage-2)) - (rx/observe-on :async) - (rx/map deref) - (rx/map bundle-fetched)) - - (when component-id - (->> stream - (rx/filter (ptk/type? ::workspace-initialized)) - (rx/observe-on :async) - (rx/take 1) - (rx/map #(go-to-component (uuid/uuid component-id)))))) - - (rx/take-until - (rx/filter (ptk/type? ::fetch-bundle) stream))))))) + (rx/take-until + (rx/filter (ptk/type? ::fetch-bundle) stream)))))) (defn initialize-file [project-id file-id] 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 60291315c..0409d4445 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/assets/common.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/assets/common.cljs @@ -307,7 +307,9 @@ workspace-libraries (deref refs/workspace-libraries) current-file {:id current-file-id :data workspace-data} - find-component #(ctf/resolve-component % current-file workspace-libraries) + find-component (fn [shape include-deleted?] + (ctf/resolve-component + shape current-file workspace-libraries {:include-deleted? include-deleted?})) local-or-exists (fn [shape] (let [library-id (:component-file shape)] @@ -315,11 +317,11 @@ (some? (get workspace-libraries library-id))))) restorable-copies (->> copies - (filter #(nil? (find-component %))) + (filter #(nil? (find-component % false))) (filter #(local-or-exists %))) touched-not-dangling (filter #(and (cfh/component-touched? objects (:id %)) - (find-component %)) copies) + (find-component % false)) copies) can-reset-overrides? (or (not components-v2) (seq touched-not-dangling)) @@ -332,7 +334,7 @@ library-id (:component-file shape) local-component? (= library-id current-file-id) - component (find-component shape) + component (find-component shape false) lacks-annotation? (nil? (:annotation component)) is-dangling? (nil? component) @@ -385,7 +387,9 @@ #(st/emit! (dw/go-to-component component-id)) do-show-remote-component - #(st/emit! (dwl/nav-to-component-file library-id component)) + #(let [comp (find-component shape true)] ;; When the show-remote is after a restore, the component may still be deleted + (when comp + (st/emit! (dwl/nav-to-component-file library-id comp)))) do-show-component #(if local-component? @@ -401,7 +405,7 @@ (st/emit! (dwl/restore-components comps-to-restore)) (when (= 1 (count comps-to-restore)) - do-show-component)) + (ts/schedule 1000 do-show-component))) menu-entries [(when (and (not multi) main-instance?) {:msg "workspace.shape.menu.show-in-assets"