mirror of
https://github.com/penpot/penpot.git
synced 2025-07-29 16:57:20 +02:00
🐛 Fix loading same resources multiple times
This commit is contained in:
parent
8c20159fb0
commit
a8d4b293dc
2 changed files with 42 additions and 42 deletions
|
@ -189,11 +189,12 @@
|
||||||
|
|
||||||
(defn- get-string-length [string] (+ (count string) 1))
|
(defn- get-string-length [string] (+ (count string) 1))
|
||||||
|
|
||||||
(defn- store-image
|
(defn- fetch-image
|
||||||
[id]
|
[id]
|
||||||
(let [buffer (uuid/get-u32 id)
|
(let [buffer (uuid/get-u32 id)
|
||||||
url (cf/resolve-file-media {:id id})]
|
url (cf/resolve-file-media {:id id})]
|
||||||
(->> (http/send! {:method :get
|
{:key url
|
||||||
|
:callback #(->> (http/send! {:method :get
|
||||||
:uri url
|
:uri url
|
||||||
:response-type :blob})
|
:response-type :blob})
|
||||||
(rx/map :body)
|
(rx/map :body)
|
||||||
|
@ -209,7 +210,7 @@
|
||||||
(aget buffer 1)
|
(aget buffer 1)
|
||||||
(aget buffer 2)
|
(aget buffer 2)
|
||||||
(aget buffer 3))
|
(aget buffer 3))
|
||||||
true))))))
|
true))))}))
|
||||||
|
|
||||||
(defn- get-fill-images
|
(defn- get-fill-images
|
||||||
[leaf]
|
[leaf]
|
||||||
|
@ -227,7 +228,7 @@
|
||||||
(aget buffer 2)
|
(aget buffer 2)
|
||||||
(aget buffer 3))]
|
(aget buffer 3))]
|
||||||
(when (zero? cached-image?)
|
(when (zero? cached-image?)
|
||||||
(store-image id))))))
|
(fetch-image id))))))
|
||||||
|
|
||||||
(defn set-shape-text-images
|
(defn set-shape-text-images
|
||||||
[content]
|
[content]
|
||||||
|
@ -269,7 +270,7 @@
|
||||||
(aget buffer 2)
|
(aget buffer 2)
|
||||||
(aget buffer 3))]
|
(aget buffer 3))]
|
||||||
(when (zero? cached-image?)
|
(when (zero? cached-image?)
|
||||||
(store-image id))))
|
(fetch-image id))))
|
||||||
image-fills))))
|
image-fills))))
|
||||||
|
|
||||||
(defn set-shape-strokes
|
(defn set-shape-strokes
|
||||||
|
@ -308,7 +309,7 @@
|
||||||
(dm/get-prop image :height))
|
(dm/get-prop image :height))
|
||||||
(h/call wasm/internal-module "_add_shape_stroke_fill")
|
(h/call wasm/internal-module "_add_shape_stroke_fill")
|
||||||
(when (== cached-image? 0)
|
(when (== cached-image? 0)
|
||||||
(store-image id)))
|
(fetch-image id)))
|
||||||
|
|
||||||
(some? color)
|
(some? color)
|
||||||
(do
|
(do
|
||||||
|
@ -763,16 +764,20 @@
|
||||||
pending)))
|
pending)))
|
||||||
|
|
||||||
|
|
||||||
(defn process-object
|
(defn process-pending
|
||||||
[shape]
|
[pending]
|
||||||
(let [pending (set-object [] shape)]
|
(when-let [pending (-> (d/index-by :key :callback pending) vals)]
|
||||||
(when-let [pending (seq pending)]
|
|
||||||
(->> (rx/from pending)
|
(->> (rx/from pending)
|
||||||
(rx/mapcat identity)
|
(rx/mapcat (fn [callback] (callback)))
|
||||||
(rx/reduce conj [])
|
(rx/reduce conj [])
|
||||||
(rx/subs! (fn [_]
|
(rx/subs! (fn [_]
|
||||||
(clear-drawing-cache)
|
(clear-drawing-cache)
|
||||||
(request-render "set-objects")))))))
|
(request-render "set-objects"))))))
|
||||||
|
|
||||||
|
(defn process-object
|
||||||
|
[shape]
|
||||||
|
(let [pending (set-object [] shape)]
|
||||||
|
(process-pending pending)))
|
||||||
|
|
||||||
(defn set-objects
|
(defn set-objects
|
||||||
[objects]
|
[objects]
|
||||||
|
@ -789,13 +794,7 @@
|
||||||
(perf/end-measure "set-objects")
|
(perf/end-measure "set-objects")
|
||||||
(clear-drawing-cache)
|
(clear-drawing-cache)
|
||||||
(request-render "set-objects")
|
(request-render "set-objects")
|
||||||
(when-let [pending (seq pending)]
|
(process-pending pending)))
|
||||||
(->> (rx/from pending)
|
|
||||||
(rx/mapcat identity)
|
|
||||||
(rx/reduce conj [])
|
|
||||||
(rx/subs! (fn [_]
|
|
||||||
(clear-drawing-cache)
|
|
||||||
(request-render "set-objects")))))))
|
|
||||||
|
|
||||||
(defn set-structure-modifiers
|
(defn set-structure-modifiers
|
||||||
[entries]
|
[entries]
|
||||||
|
|
|
@ -94,13 +94,14 @@
|
||||||
fallback?)
|
fallback?)
|
||||||
true))
|
true))
|
||||||
|
|
||||||
(defn- store-font-url
|
(defn- fetch-font
|
||||||
[font-data font-url emoji? fallback?]
|
[font-data font-url emoji? fallback?]
|
||||||
(->> (http/send! {:method :get
|
{:key font-url
|
||||||
|
:callback #(->> (http/send! {:method :get
|
||||||
:uri font-url
|
:uri font-url
|
||||||
:response-type :buffer})
|
:response-type :buffer})
|
||||||
(rx/map (fn [{:keys [body]}]
|
(rx/map (fn [{:keys [body]}]
|
||||||
(store-font-buffer font-data body emoji? fallback?)))))
|
(store-font-buffer font-data body emoji? fallback?))))})
|
||||||
|
|
||||||
(defn- google-font-ttf-url
|
(defn- google-font-ttf-url
|
||||||
[font-id font-variant-id]
|
[font-id font-variant-id]
|
||||||
|
@ -134,7 +135,7 @@
|
||||||
(:style font-data)
|
(:style font-data)
|
||||||
emoji?))]
|
emoji?))]
|
||||||
(when-not font-stored?
|
(when-not font-stored?
|
||||||
(store-font-url font-data uri emoji? fallback?)))))
|
(fetch-font font-data uri emoji? fallback?)))))
|
||||||
|
|
||||||
(defn serialize-font-style
|
(defn serialize-font-style
|
||||||
[font-style]
|
[font-style]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue