mirror of
https://github.com/penpot/penpot.git
synced 2025-02-22 06:46:40 -05:00
🐛 Old thumbnail invalidation on frames after sync
This commit is contained in:
parent
6a5d9402d5
commit
a1e810317a
2 changed files with 21 additions and 21 deletions
|
@ -809,17 +809,17 @@
|
|||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;; Analyze one change and checks if if modifies any shape belonging to
|
||||
;; a main or a copy. Return the ids of the mains or copies affected
|
||||
;; frames. Return the ids of the frames affected
|
||||
|
||||
(defn- find-all-heads
|
||||
"Go trough the parents and get all of them that are a head of a component."
|
||||
(defn- parents-frames
|
||||
"Go trough the parents and get all of them that are a frame."
|
||||
[id objects]
|
||||
(->> (cfh/get-parents-with-self objects id)
|
||||
(filter ctk/instance-head?)))
|
||||
(filter cfh/frame-shape?)))
|
||||
|
||||
(defmulti heads-changed (fn [_ change] (:type change)))
|
||||
(defmulti frames-changed (fn [_ change] (:type change)))
|
||||
|
||||
(defmethod heads-changed :mod-obj
|
||||
(defmethod frames-changed :mod-obj
|
||||
[file-data {:keys [id page-id _component-id operations]}]
|
||||
(when page-id
|
||||
(let [page (ctpl/get-page file-data page-id)
|
||||
|
@ -830,29 +830,29 @@
|
|||
(get ctk/sync-attrs (:attr operation))))
|
||||
any-sync? (some need-sync? operations)]
|
||||
(when any-sync?
|
||||
(find-all-heads id (:objects page))))))
|
||||
(parents-frames id (:objects page))))))
|
||||
|
||||
(defmethod heads-changed :mov-objects
|
||||
(defmethod frames-changed :mov-objects
|
||||
[file-data {:keys [page-id _component-id parent-id shapes] :as change}]
|
||||
(when page-id
|
||||
(let [page (ctpl/get-page file-data page-id)]
|
||||
(concat
|
||||
(find-all-heads parent-id (:objects page))
|
||||
(mapcat #(find-all-heads (:parent-id %) (:objects page)) shapes)))))
|
||||
(parents-frames parent-id (:objects page))
|
||||
(mapcat #(parents-frames (:parent-id %) (:objects page)) shapes)))))
|
||||
|
||||
(defmethod heads-changed :add-obj
|
||||
(defmethod frames-changed :add-obj
|
||||
[file-data {:keys [parent-id page-id _component-id] :as change}]
|
||||
(when page-id
|
||||
(let [page (ctpl/get-page file-data page-id)]
|
||||
(find-all-heads parent-id (:objects page)))))
|
||||
(parents-frames parent-id (:objects page)))))
|
||||
|
||||
(defmethod heads-changed :del-obj
|
||||
(defmethod frames-changed :del-obj
|
||||
[file-data {:keys [id page-id _component-id] :as change}]
|
||||
(when page-id
|
||||
(let [page (ctpl/get-page file-data page-id)]
|
||||
(find-all-heads id (:objects page)))))
|
||||
(parents-frames id (:objects page)))))
|
||||
|
||||
(defmethod heads-changed :default
|
||||
(defmethod frames-changed :default
|
||||
[_ _]
|
||||
nil)
|
||||
|
||||
|
|
|
@ -947,15 +947,15 @@
|
|||
changes (pcb/concat-changes library-changes file-changes)
|
||||
|
||||
|
||||
find-heads (fn [change]
|
||||
(->> (ch/heads-changed file change)
|
||||
find-frames (fn [change]
|
||||
(->> (ch/frames-changed file change)
|
||||
(map #(assoc %1 :page-id (:page-id change)))))
|
||||
|
||||
|
||||
|
||||
updated-copies (->> changes
|
||||
updated-frames (->> changes
|
||||
:redo-changes
|
||||
(mapcat find-heads)
|
||||
(mapcat find-frames)
|
||||
distinct)]
|
||||
|
||||
(log/debug :msg "SYNC-FILE finished" :js/rchanges (log-changes
|
||||
|
@ -967,8 +967,8 @@
|
|||
(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)
|
||||
(when-not (empty? updated-frames)
|
||||
(->> (rx/from updated-frames)
|
||||
(rx/mapcat (fn [shape]
|
||||
(rx/of
|
||||
(dwt/clear-thumbnail file-id (:page-id shape) (:id shape) "frame")
|
||||
|
|
Loading…
Add table
Reference in a new issue