Merge pull request #9036 from penpot/alotor-fix-thumbnail-images

🐛 Fix problem with dashboard thumbnails images
This commit is contained in:
Elena Torró 2026-04-20 13:03:53 +02:00 committed by GitHub
commit 3f0d103cb3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 22 additions and 20 deletions

View File

@ -492,7 +492,9 @@
(try (try
(when (wasm.api/init-canvas-context os-canvas) (when (wasm.api/init-canvas-context os-canvas)
(wasm.api/initialize-viewport (wasm.api/initialize-viewport
objects scale bounds "#000000" 0 objects scale bounds
:background-opacity 0
:on-render
(fn [] (fn []
(wasm.api/render-sync-shape object-id) (wasm.api/render-sync-shape object-id)
(ts/raf (ts/raf

View File

@ -408,7 +408,7 @@
(mf/set-ref-val! last-file-version-id-ref file-version-id)) (mf/set-ref-val! last-file-version-id-ref file-version-id))
(when (and (some? file-version-id) (when (and (some? file-version-id)
(not= file-version-id (mf/ref-val last-file-version-id-ref))) (not= file-version-id (mf/ref-val last-file-version-id-ref)))
(wasm.api/initialize-viewport base-objects zoom vbox background) (wasm.api/initialize-viewport base-objects zoom vbox :background background)
(mf/set-ref-val! last-file-version-id-ref file-version-id))))) (mf/set-ref-val! last-file-version-id-ref file-version-id)))))
(mf/with-effect [focus] (mf/with-effect [focus]

View File

@ -1398,14 +1398,14 @@
loading begins, allowing callers to reveal the page content during loading begins, allowing callers to reveal the page content during
transitions." transitions."
([objects] ([objects]
(set-objects objects nil nil)) (set-objects objects nil nil false))
([objects render-callback] ([objects render-callback]
(set-objects objects render-callback nil)) (set-objects objects render-callback nil false))
([objects render-callback on-shapes-ready] ([objects render-callback on-shapes-ready force-sync]
(perf/begin-measure "set-objects") (perf/begin-measure "set-objects")
(let [shapes (shapes-in-tree-order objects) (let [shapes (shapes-in-tree-order objects)
total-shapes (count shapes)] total-shapes (count shapes)]
(if (< total-shapes ASYNC_THRESHOLD) (if (or force-sync (< total-shapes ASYNC_THRESHOLD))
(set-objects-sync shapes render-callback on-shapes-ready) (set-objects-sync shapes render-callback on-shapes-ready)
(do (do
(begin-shapes-loading!) (begin-shapes-loading!)
@ -1554,19 +1554,16 @@
(request-render "set-modifiers"))))) (request-render "set-modifiers")))))
(defn initialize-viewport (defn initialize-viewport
([base-objects zoom vbox background] [base-objects zoom vbox &
(initialize-viewport base-objects zoom vbox background 1 nil nil)) {:keys [background background-opacity on-render on-shapes-ready force-sync]
([base-objects zoom vbox background callback] :or {background-opacity 1}}]
(initialize-viewport base-objects zoom vbox background 1 callback nil)) (let [rgba (when background (sr-clr/hex->u32argb background background-opacity))
([base-objects zoom vbox background background-opacity callback] total-shapes (count (vals base-objects))]
(initialize-viewport base-objects zoom vbox background background-opacity callback nil))
([base-objects zoom vbox background background-opacity callback on-shapes-ready] (when rgba (h/call wasm/internal-module "_set_canvas_background" rgba))
(let [rgba (sr-clr/hex->u32argb background background-opacity) (h/call wasm/internal-module "_set_view" zoom (- (:x vbox)) (- (:y vbox)))
total-shapes (count (vals base-objects))] (h/call wasm/internal-module "_init_shapes_pool" total-shapes)
(h/call wasm/internal-module "_set_canvas_background" rgba) (set-objects base-objects on-render on-shapes-ready force-sync)))
(h/call wasm/internal-module "_set_view" zoom (- (:x vbox)) (- (:y vbox)))
(h/call wasm/internal-module "_init_shapes_pool" total-shapes)
(set-objects base-objects callback on-shapes-ready))))
(def ^:private default-context-options (def ^:private default-context-options
#js {:antialias false #js {:antialias false

View File

@ -171,7 +171,10 @@
zoom (/ width (:width vbox))] zoom (/ width (:width vbox))]
(wasm.api/initialize-viewport (wasm.api/initialize-viewport
objects zoom vbox bgcolor objects zoom vbox
:background bgcolor
:force-sync true
:on-render
(fn [] (fn []
(if frame (if frame
(wasm.api/render-sync-shape (:id frame)) (wasm.api/render-sync-shape (:id frame))