0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-24 23:49:45 -05:00

🐛 Fix imposter being regenerated indefinitely

This commit is contained in:
Aitor 2024-03-05 11:47:06 +01:00 committed by Andrey Antukh
parent 2465690c7d
commit 9ad0662409
3 changed files with 17 additions and 15 deletions

View file

@ -808,7 +808,7 @@
component (ctkl/get-component data component-id)
page-id (:main-instance-page component)
root-id (:main-instance-id component)]
(dwt/request-thumbnail file-id page-id root-id tag)))
(dwt/request-thumbnail file-id page-id root-id tag "update-component-thumbnail-sync")))
(defn update-component-sync
([shape-id file-id] (update-component-sync shape-id file-id nil))

View file

@ -58,15 +58,17 @@
(defn request-thumbnail
"Enqueues a request to generate a thumbnail for the given ids."
[file-id page-id shape-id tag]
(ptk/reify ::request-thumbnail
ptk/EffectEvent
(effect [_ _ _]
(l/dbg :hint "request thumbnail" :file-id file-id :page-id page-id :shape-id shape-id :tag tag)
(q/enqueue-unique
queue
(create-request file-id page-id shape-id tag)
(partial find-request file-id page-id shape-id tag)))))
([file-id page-id shape-id tag]
(request-thumbnail file-id page-id shape-id tag "unknown"))
([file-id page-id shape-id tag requester]
(ptk/reify ::request-thumbnail
ptk/EffectEvent
(effect [_ _ _]
(l/dbg :hint "request thumbnail" :requester requester :file-id file-id :page-id page-id :shape-id shape-id :tag tag)
(q/enqueue-unique
queue
(create-request file-id page-id shape-id tag)
(partial find-request file-id page-id shape-id tag))))))
;; This function first renders the HTML calling `render/render-frame` that
;; returns HTML as a string, then we send that data to the iframe rasterizer
@ -291,6 +293,6 @@
(->> all-changes-s
(rx/buffer-until notifier-s)
(rx/mapcat #(into #{} %))
(rx/map #(request-thumbnail file-id page-id % "frame"))))
(rx/map #(request-thumbnail file-id page-id % "frame" "watch-state-changes"))))
(rx/take-until stopper-s))))))

View file

@ -107,9 +107,9 @@
(-> (image-size href)
(p/then
(fn [{:keys [width height]}]
(when (or (not (mth/close? width fixed-width 2))
(not (mth/close? height fixed-height 2)))
(st/emit! (dwt/request-thumbnail file-id page-id frame-id "frame"))))))))
(when (or (not (mth/close? width fixed-width 5))
(not (mth/close? height fixed-height 5)))
(st/emit! (dwt/request-thumbnail file-id page-id frame-id "frame" "check-thumbnail-size"))))))))
(defn root-frame-wrapper-factory
[shape-wrapper]
@ -175,7 +175,7 @@
(mf/with-effect []
(when-not (some? thumbnail-uri)
(tm/schedule-on-idle
#(st/emit! (dwt/request-thumbnail file-id page-id frame-id "frame"))))
#(st/emit! (dwt/request-thumbnail file-id page-id frame-id "frame" "root-frame"))))
#(when-let [task (mf/ref-val task-ref)]
(d/close! task)))