diff --git a/frontend/src/app/util/queue.cljs b/frontend/src/app/util/queue.cljs index 38b4a10f8..d0d8545d1 100644 --- a/frontend/src/app/util/queue.cljs +++ b/frontend/src/app/util/queue.cljs @@ -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)))))