From 20a86ad65a3e76fa456b3f3a7ca189a48c5ac22d Mon Sep 17 00:00:00 2001 From: Pablo Alba Date: Wed, 29 Nov 2023 18:35:26 +0100 Subject: [PATCH] :bug: Fix Old thumbnail present after component sync --- .../app/main/data/workspace/libraries.cljs | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/main/data/workspace/libraries.cljs b/frontend/src/app/main/data/workspace/libraries.cljs index 5fc21fc0d..2f1879180 100644 --- a/frontend/src/app/main/data/workspace/libraries.cljs +++ b/frontend/src/app/main/data/workspace/libraries.cljs @@ -944,7 +944,20 @@ (when sync-typographies? (dwlh/generate-sync-file it file-id :typographies asset-id library-id state))]) - changes (pcb/concat-changes library-changes file-changes)] + changes (pcb/concat-changes library-changes file-changes) + + find-shape (fn [data] + (for [page-id [(:page-id data)] + id (:shapes data)] + (-> (get-in state [:workspace-data :pages-index page-id :objects id]) + (assoc :page-id page-id)))) + + updated-copies (->> changes + :redo-changes + (filter #(= (:type %) :reg-objects)) + (mapcat find-shape) + (filter ctk/instance-head?) + distinct)] (log/debug :msg "SYNC-FILE finished" :js/rchanges (log-changes (:redo-changes changes) @@ -955,6 +968,13 @@ (when (seq (:redo-changes changes)) (rx/of (dch/commit-changes (assoc changes ;; TODO a ver qué pasa con esto :file-id file-id)))) + (when-not (empty? updated-copies) + (->> (rx/from updated-copies) + (rx/mapcat (fn [shape] + (rx/of + (dwt/clear-thumbnail file-id (:page-id shape) (:id shape) "frame") + (when-not (= (:frame-id shape) uuid/zero) + (dwt/clear-thumbnail file-id (:page-id shape) (:frame-id shape) "frame"))))))) (when (not= file-id library-id) ;; When we have just updated the library file, give some time for the ;; update to finish, before marking this file as synced.