diff --git a/backend/deps.edn b/backend/deps.edn index 51898e67c..688f4ecec 100644 --- a/backend/deps.edn +++ b/backend/deps.edn @@ -22,8 +22,8 @@ java-http-clj/java-http-clj {:mvn/version "0.4.3"} funcool/yetti - {:git/tag "v9.11" - :git/sha "6f9197a" + {:git/tag "v9.12" + :git/sha "51646d8" :git/url "https://github.com/funcool/yetti.git" :exclusions [org.slf4j/slf4j-api]} diff --git a/backend/src/app/loggers/audit.clj b/backend/src/app/loggers/audit.clj index a795d29e7..31b00a535 100644 --- a/backend/src/app/loggers/audit.clj +++ b/backend/src/app/loggers/audit.clj @@ -323,7 +323,7 @@ where archived_at is not null") (defn- clean-archived - [{:keys [pool]}] + [{:keys [::db/pool]}] (let [result (db/exec-one! pool [sql:clean-archived]) result (:next.jdbc/update-count result)] (l/debug :hint "delete archived audit log entries" :deleted result) diff --git a/frontend/src/app/main/ui/workspace/shapes/frame/thumbnail_render.cljs b/frontend/src/app/main/ui/workspace/shapes/frame/thumbnail_render.cljs index 4bb5c9864..0900b8b75 100644 --- a/frontend/src/app/main/ui/workspace/shapes/frame/thumbnail_render.cljs +++ b/frontend/src/app/main/ui/workspace/shapes/frame/thumbnail_render.cljs @@ -18,9 +18,11 @@ [app.main.ui.shapes.frame :as frame] [app.util.dom :as dom] [app.util.timers :as ts] + [app.util.webapi :as wapi] [beicon.core :as rx] [cuerdas.core :as str] [debug :refer [debug?]] + [promesa.core :as p] [rumext.v2 :as mf])) (defn- draw-thumbnail-canvas! @@ -229,6 +231,16 @@ (.disconnect @observer-ref) (reset! observer-ref nil))))) + ;; When the thumbnail-data is empty we regenerate the thumbnail + (mf/use-effect + (mf/deps (:selrect shape) thumbnail-data) + (fn [] + (let [{:keys [width height]} (:selrect shape)] + (p/then (wapi/empty-png-size width height) + (fn [data] + (when (<= (count thumbnail-data) (+ 100 (count data))) + (rx/push! updates-str :update))))))) + [on-load-frame-dom @render-frame? (mf/html diff --git a/frontend/src/app/util/webapi.cljs b/frontend/src/app/util/webapi.cljs index 8044f54c9..1f3a9397d 100644 --- a/frontend/src/app/util/webapi.cljs +++ b/frontend/src/app/util/webapi.cljs @@ -11,7 +11,8 @@ [app.common.logging :as log] [app.util.object :as obj] [beicon.core :as rx] - [cuerdas.core :as str])) + [cuerdas.core :as str] + [promesa.core :as p])) (log/set-level! :warn) @@ -144,3 +145,24 @@ (.observe ^js obs node) (fn [] (.disconnect ^js obs)))))) + +(defn empty-png-size* + [width height] + (p/create + (fn [resolve reject] + (try + (let [canvas (.createElement js/document "canvas") + _ (set! (.-width canvas) width) + _ (set! (.-height canvas) height) + _ (set! (.-background canvas) "white") + canvas-context (.getContext canvas "2d")] + (.fillRect canvas-context 0 0 width height) + (.toBlob canvas + (fn [blob] + (->> (read-file-as-data-url blob) + (rx/catch (fn [err] (reject err))) + (rx/subs (fn [result] (resolve result))))))) + + (catch :default e (reject e)))))) + +(def empty-png-size (memoize empty-png-size*))