···11# Changelog
2233## Next
44+- Drop support for Windows 7 and 8
55+- Drop support for macOS 10.13 and 10.14
46- Add playback history to queue panel
77+- Fix dragging tracks to up next/autoplay queue boundary
58- Update dependencies
66-- Drop support for Windows 7 and 8
77-- Drop support for macOS 10.13 and 10.14
89910## 0.18.0 - 2024 Jun 7
1011- Add arm64 support for macOS and Windows
+2-6
src/components/Queue.svelte
···192192 return
193193 }
194194 if (dragged.tracks) {
195195- if ($queue.userQueue.length === 0) {
196196- // if user drags to top of autoqueue, create userqueue
197197- dragTopOfItem = false
198198- }
199195 const newSelection = dragged.tracks.queueIndexes
200200- ? moveIndexes(dragged.tracks.queueIndexes, dragToIndex, !dragTopOfItem)
201201- : insertIds(dragged.tracks.ids, dragToIndex, !dragTopOfItem)
196196+ ? moveIndexes(dragged.tracks.queueIndexes, dragToIndex, dragTopOfItem)
197197+ : insertIds(dragged.tracks.ids, dragToIndex, dragTopOfItem)
202198 for (let i = newSelection.from; i <= newSelection.to; i++) {
203199 selection.add(i)
204200 }
+21-7
src/lib/queue.ts
···155155 })
156156}
157157158158-export function moveIndexes(indexes: number[], newIndex: number, top = false) {
158158+export function moveIndexes(indexes: number[], newIndex: number, bias_up = false) {
159159 const items: QueueItem[] = []
160160 queue.update((q) => {
161161+ const user_queue_index = q.past.length + Number(!!q.current)
162162+ const had_user_queue = q.userQueue.length > 0
163163+161164 // Sort descending. We need to remove the last indexes first to not mess up the indexes
162165 for (const index of indexes.sort((a, b) => b - a)) {
163166 const removed_item = removeIndex(q, index)
···170173 items.push(newQueueItem(getByQueueIndex(index).id))
171174 }
172175 }
176176+ const user_queue_got_removed = had_user_queue && q.userQueue.length === 0
177177+ // If the user is dragging down to the bottom of the user queue, enable bias_up
178178+ // to make sure the user queue gets re-added
179179+ if (!bias_up && user_queue_got_removed && newIndex === user_queue_index) {
180180+ bias_up = true
181181+ }
173182 return q
174183 })
175184 // We sorted the indexes descending, so now reverse them
176176- return insertItems(items.reverse(), newIndex, top)
185185+ return insertItems(items.reverse(), newIndex, bias_up)
177186}
178187179179-function insertItems(items: QueueItem[], index: number, top = false) {
188188+function insertItems(items: QueueItem[], index: number, bias_up = false) {
180189 queue.update((q) => {
181190 const user_queue_index = q.past.length + Number(!!q.current)
182191 index -= user_queue_index
183183- const snapTop = index === q.userQueue.length && top
184184- if (index < q.userQueue.length || snapTop) {
192192+193193+ const to_auto_queue_start = q.userQueue.length === 0 && bias_up
194194+ const create_user_queue = to_auto_queue_start && index === 0
195195+196196+ const to_user_queue_end = index === q.userQueue.length && !bias_up
197197+198198+ if (index < q.userQueue.length || create_user_queue || to_user_queue_end) {
185199 q.userQueue.splice(index, 0, ...items)
186200 return q
187201 }
···195209 }
196210}
197211198198-export function insertIds(ids: TrackID[], index: number, top = false) {
199199- return insertItems(ids.map(newQueueItem), index, top)
212212+export function insertIds(ids: TrackID[], index: number, bias_top = false) {
213213+ return insertItems(ids.map(newQueueItem), index, bias_top)
200214}
201215202216function removeIndex(q: Queue, index: number): QueueItem | null {