mirror of
https://github.com/penpot/penpot.git
synced 2025-01-09 00:10:11 -05:00
♻️ Refactor thumbnails queue to priority queue
This commit is contained in:
parent
49203f53aa
commit
1de2af744f
1 changed files with 19 additions and 3 deletions
|
@ -85,7 +85,15 @@
|
|||
(let [items (unchecked-get queue "items")]
|
||||
(.shift items)))
|
||||
|
||||
(defn enqueue
|
||||
(defn enqueue-first
|
||||
[queue item]
|
||||
(assert (instance? Queue queue))
|
||||
(let [items (unchecked-get queue "items")]
|
||||
(.unshift items item)
|
||||
(when-not (has-requested-process? queue)
|
||||
(request-process queue (next-process-time queue)))))
|
||||
|
||||
(defn enqueue-last
|
||||
[queue item]
|
||||
(assert (instance? Queue queue))
|
||||
(let [items (unchecked-get queue "items")]
|
||||
|
@ -97,5 +105,13 @@
|
|||
[queue item f]
|
||||
(assert (instance? Queue queue))
|
||||
(let [items (unchecked-get queue "items")]
|
||||
(when-not (.findLast ^js items f)
|
||||
(enqueue queue item))))
|
||||
;; If tag is "frame", then they are added to the front of the queue
|
||||
;; so that they are processed first, anything else is added to the
|
||||
;; end of the queue.
|
||||
(if (= (unchecked-get item "tag") "frame")
|
||||
(when-not (.find ^js items f)
|
||||
(enqueue-first queue item))
|
||||
(when-not (.findLast ^js items f)
|
||||
(enqueue-last queue item)))
|
||||
(when-not (has-requested-process? queue)
|
||||
(request-process queue (next-process-time queue)))))
|
||||
|
|
Loading…
Reference in a new issue