mirror of
https://github.com/penpot/penpot.git
synced 2025-02-22 23:06:08 -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
|
;; 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
|
(defn- parents-frames
|
||||||
"Go trough the parents and get all of them that are a head of a component."
|
"Go trough the parents and get all of them that are a frame."
|
||||||
[id objects]
|
[id objects]
|
||||||
(->> (cfh/get-parents-with-self objects id)
|
(->> (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]}]
|
[file-data {:keys [id page-id _component-id operations]}]
|
||||||
(when page-id
|
(when page-id
|
||||||
(let [page (ctpl/get-page file-data page-id)
|
(let [page (ctpl/get-page file-data page-id)
|
||||||
|
@ -830,29 +830,29 @@
|
||||||
(get ctk/sync-attrs (:attr operation))))
|
(get ctk/sync-attrs (:attr operation))))
|
||||||
any-sync? (some need-sync? operations)]
|
any-sync? (some need-sync? operations)]
|
||||||
(when any-sync?
|
(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}]
|
[file-data {:keys [page-id _component-id parent-id shapes] :as change}]
|
||||||
(when page-id
|
(when page-id
|
||||||
(let [page (ctpl/get-page file-data page-id)]
|
(let [page (ctpl/get-page file-data page-id)]
|
||||||
(concat
|
(concat
|
||||||
(find-all-heads parent-id (:objects page))
|
(parents-frames parent-id (:objects page))
|
||||||
(mapcat #(find-all-heads (:parent-id %) (:objects page)) shapes)))))
|
(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}]
|
[file-data {:keys [parent-id page-id _component-id] :as change}]
|
||||||
(when page-id
|
(when page-id
|
||||||
(let [page (ctpl/get-page file-data 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}]
|
[file-data {:keys [id page-id _component-id] :as change}]
|
||||||
(when page-id
|
(when page-id
|
||||||
(let [page (ctpl/get-page file-data 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)
|
nil)
|
||||||
|
|
||||||
|
|
|
@ -947,15 +947,15 @@
|
||||||
changes (pcb/concat-changes library-changes file-changes)
|
changes (pcb/concat-changes library-changes file-changes)
|
||||||
|
|
||||||
|
|
||||||
find-heads (fn [change]
|
find-frames (fn [change]
|
||||||
(->> (ch/heads-changed file change)
|
(->> (ch/frames-changed file change)
|
||||||
(map #(assoc %1 :page-id (:page-id change)))))
|
(map #(assoc %1 :page-id (:page-id change)))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
updated-copies (->> changes
|
updated-frames (->> changes
|
||||||
:redo-changes
|
:redo-changes
|
||||||
(mapcat find-heads)
|
(mapcat find-frames)
|
||||||
distinct)]
|
distinct)]
|
||||||
|
|
||||||
(log/debug :msg "SYNC-FILE finished" :js/rchanges (log-changes
|
(log/debug :msg "SYNC-FILE finished" :js/rchanges (log-changes
|
||||||
|
@ -967,8 +967,8 @@
|
||||||
(when (seq (:redo-changes changes))
|
(when (seq (:redo-changes changes))
|
||||||
(rx/of (dch/commit-changes (assoc changes ;; TODO a ver qué pasa con esto
|
(rx/of (dch/commit-changes (assoc changes ;; TODO a ver qué pasa con esto
|
||||||
:file-id file-id))))
|
:file-id file-id))))
|
||||||
(when-not (empty? updated-copies)
|
(when-not (empty? updated-frames)
|
||||||
(->> (rx/from updated-copies)
|
(->> (rx/from updated-frames)
|
||||||
(rx/mapcat (fn [shape]
|
(rx/mapcat (fn [shape]
|
||||||
(rx/of
|
(rx/of
|
||||||
(dwt/clear-thumbnail file-id (:page-id shape) (:id shape) "frame")
|
(dwt/clear-thumbnail file-id (:page-id shape) (:id shape) "frame")
|
||||||
|
|
Loading…
Add table
Reference in a new issue