diff --git a/CHANGES.md b/CHANGES.md index 8b2a77093..68ed86a7f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,11 @@ # CHANGELOG +## 2.4.1 + +### :bug: Bugs fixed + +- Fix problem with thumbnail generation when changing between versions [Taiga #9624](https://tree.taiga.io/project/penpot/issue/9624) + ## 2.4.0 ### :rocket: Epics and highlights diff --git a/frontend/src/app/main/data/workspace/thumbnails.cljs b/frontend/src/app/main/data/workspace/thumbnails.cljs index 0d2ef2239..132db9156 100644 --- a/frontend/src/app/main/data/workspace/thumbnails.cljs +++ b/frontend/src/app/main/data/workspace/thumbnails.cljs @@ -52,6 +52,11 @@ (defonce queue (q/create find-request (/ 1000 30))) +(defn clear-queue! + [] + (l/dbg :hint "clearing thumbnail queue") + (q/clear! queue)) + ;; 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 ;; that returns the image as a Blob. Finally we create a URI for that blob. diff --git a/frontend/src/app/main/data/workspace/versions.cljs b/frontend/src/app/main/data/workspace/versions.cljs index 0808c6f47..7b350d65a 100644 --- a/frontend/src/app/main/data/workspace/versions.cljs +++ b/frontend/src/app/main/data/workspace/versions.cljs @@ -11,6 +11,7 @@ [app.main.data.events :as ev] [app.main.data.persistence :as dwp] [app.main.data.workspace :as dw] + [app.main.data.workspace.thumbnails :as th] [app.main.refs :as refs] [app.main.repo :as rp] [app.util.time :as dt] @@ -132,6 +133,7 @@ (rx/filter #(or (nil? %) (= :saved %))) (rx/take 1) (rx/mapcat #(rp/cmd! :restore-file-snapshot {:file-id file-id :id id})) + (rx/tap #(th/clear-queue!)) (rx/map #(dw/initialize-file project-id file-id))) (case origin :version diff --git a/frontend/src/app/util/queue.cljs b/frontend/src/app/util/queue.cljs index 564fd3cda..4fbc72b30 100644 --- a/frontend/src/app/util/queue.cljs +++ b/frontend/src/app/util/queue.cljs @@ -9,6 +9,7 @@ (:require [app.common.logging :as l] [app.common.math :as mth] + [app.util.object :as obj] [app.util.time :as t] [beicon.v2.core :as rx])) @@ -47,13 +48,14 @@ ;; NOTE: Right now there are no cases where we need to cancel a process ;; but if we do, we can use this function -;; (defn- cancel-process -;; [queue] -;; (l/dbg :hint "queue::cancel-process") -;; (let [timeout (unchecked-get queue "timeout")] -;; (when (some? timeout) -;; (js/clearTimeout timeout)) -;; (unchecked-set queue "timeout" nil))) +(defn- cancel-process! + [queue] + (l/dbg :hint "queue::cancel-process") + (let [timeout (unchecked-get queue "timeout")] + (when (some? timeout) + (js/clearTimeout timeout)) + (unchecked-set queue "timeout" nil)) + queue) (defn- process [queue iterations] @@ -131,3 +133,10 @@ (enqueue-last queue request)))) (rx/to-observable result))) + +(defn clear! + [queue] + (-> queue + (cancel-process!) + (obj/set! "items" #js []) + (obj/set! "time" 0)))