0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-12 07:41:43 -05:00

Changed thumbnails to webp format

This commit is contained in:
alonso.torres 2022-04-19 18:06:38 +02:00
parent 6a3a460203
commit f945a6e649
3 changed files with 14 additions and 6 deletions

View file

@ -511,14 +511,14 @@
(map #(vector (:old-id %) (get-in % [:obj :id])))) (map #(vector (:old-id %) (get-in % [:obj :id]))))
id-duplicated (first new-selected)] id-duplicated (first new-selected)]
;; Warning: This order is important for the focus mode. ;; Warning: This order is important for the focus mode.
(rx/merge (rx/merge
(->> (rx/from dup-frames) (->> (rx/from dup-frames)
(rx/map (fn [[old-id new-id]] (dwt/duplicate-thumbnail old-id new-id)))) (rx/map (fn [[old-id new-id]] (dwt/duplicate-thumbnail old-id new-id))))
(rx/of (dch/commit-changes changes) (rx/of (dch/commit-changes changes)
(select-shapes new-selected) (select-shapes new-selected)
(memorize-duplicated id-original id-duplicated)) (memorize-duplicated id-original id-duplicated))))))))))
))))))))
(defn change-hover-state (defn change-hover-state
[id value] [id value]

View file

@ -15,7 +15,9 @@
[beicon.core :as rx] [beicon.core :as rx]
[potok.core :as ptk])) [potok.core :as ptk]))
(defn force-render-stream [id] (defn force-render-stream
"Stream that will inform the frame-wrapper to mount into memory"
[id]
(->> st/stream (->> st/stream
(rx/filter (ptk/type? ::force-render)) (rx/filter (ptk/type? ::force-render))
(rx/map deref) (rx/map deref)
@ -23,6 +25,7 @@
(rx/take 1))) (rx/take 1)))
(defn update-thumbnail (defn update-thumbnail
"Updates the thumbnail information for the given frame `id`"
[id data] [id data]
(let [lock (uuid/next)] (let [lock (uuid/next)]
(ptk/reify ::update-thumbnail (ptk/reify ::update-thumbnail
@ -42,6 +45,8 @@
(let [stopper (->> stream (rx/filter (ptk/type? :app.main.data.workspace/finalize))) (let [stopper (->> stream (rx/filter (ptk/type? :app.main.data.workspace/finalize)))
params {:file-id (:current-file-id state) params {:file-id (:current-file-id state)
:object-id id}] :object-id id}]
;; Sends the first event and debounce the rest. Will only make one update once
;; the 2 second debounce is finished
(rx/merge (rx/merge
(->> stream (->> stream
(rx/take-until stopper) (rx/take-until stopper)
@ -123,7 +128,10 @@
(->> changes (every? is-thumbnail-change?)))) (->> changes (every? is-thumbnail-change?))))
(defn watch-state-changes [] (defn watch-state-changes
"Watch the state for changes inside frames. If a change is detected will force a rendering
of the frame data so the thumbnail can be updated."
[]
(ptk/reify ::watch-state-changes (ptk/reify ::watch-state-changes
ptk/WatchEvent ptk/WatchEvent
(watch [_ _ stream] (watch [_ _ stream]

View file

@ -23,7 +23,7 @@
canvas-height (.-height canvas-node)] canvas-height (.-height canvas-node)]
(.clearRect canvas-context 0 0 canvas-width canvas-height) (.clearRect canvas-context 0 0 canvas-width canvas-height)
(.drawImage canvas-context img-node 0 0 canvas-width canvas-height) (.drawImage canvas-context img-node 0 0 canvas-width canvas-height)
(.toDataURL canvas-node "image/jpg" 1))) (.toDataURL canvas-node "image/webp" 0.75)))
(defn use-render-thumbnail (defn use-render-thumbnail
"Hook that will create the thumbnail thata" "Hook that will create the thumbnail thata"