[READ-ONLY] Mirror of https://github.com/probablykasper/ferrum. Music library app for Mac, Linux and Windows ferrum.kasper.space
electron linux macos music music-library music-player napi windows
0

Configure Feed

Select the types of activity you want to include in your feed.

Fix dragging tracks to up next/autoplay queue boundary

Kasper (Sep 7, 2024, 8:02 AM +0200) a2214585 e8ad8f7d

+26 -15
+3 -2
CHANGELOG.md
··· 1 1 # Changelog 2 2 3 3 ## Next 4 + - Drop support for Windows 7 and 8 5 + - Drop support for macOS 10.13 and 10.14 4 6 - Add playback history to queue panel 7 + - Fix dragging tracks to up next/autoplay queue boundary 5 8 - Update dependencies 6 - - Drop support for Windows 7 and 8 7 - - Drop support for macOS 10.13 and 10.14 8 9 9 10 ## 0.18.0 - 2024 Jun 7 10 11 - Add arm64 support for macOS and Windows
+2 -6
src/components/Queue.svelte
··· 192 192 return 193 193 } 194 194 if (dragged.tracks) { 195 - if ($queue.userQueue.length === 0) { 196 - // if user drags to top of autoqueue, create userqueue 197 - dragTopOfItem = false 198 - } 199 195 const newSelection = dragged.tracks.queueIndexes 200 - ? moveIndexes(dragged.tracks.queueIndexes, dragToIndex, !dragTopOfItem) 201 - : insertIds(dragged.tracks.ids, dragToIndex, !dragTopOfItem) 196 + ? moveIndexes(dragged.tracks.queueIndexes, dragToIndex, dragTopOfItem) 197 + : insertIds(dragged.tracks.ids, dragToIndex, dragTopOfItem) 202 198 for (let i = newSelection.from; i <= newSelection.to; i++) { 203 199 selection.add(i) 204 200 }
+21 -7
src/lib/queue.ts
··· 155 155 }) 156 156 } 157 157 158 - export function moveIndexes(indexes: number[], newIndex: number, top = false) { 158 + export function moveIndexes(indexes: number[], newIndex: number, bias_up = false) { 159 159 const items: QueueItem[] = [] 160 160 queue.update((q) => { 161 + const user_queue_index = q.past.length + Number(!!q.current) 162 + const had_user_queue = q.userQueue.length > 0 163 + 161 164 // Sort descending. We need to remove the last indexes first to not mess up the indexes 162 165 for (const index of indexes.sort((a, b) => b - a)) { 163 166 const removed_item = removeIndex(q, index) ··· 170 173 items.push(newQueueItem(getByQueueIndex(index).id)) 171 174 } 172 175 } 176 + const user_queue_got_removed = had_user_queue && q.userQueue.length === 0 177 + // If the user is dragging down to the bottom of the user queue, enable bias_up 178 + // to make sure the user queue gets re-added 179 + if (!bias_up && user_queue_got_removed && newIndex === user_queue_index) { 180 + bias_up = true 181 + } 173 182 return q 174 183 }) 175 184 // We sorted the indexes descending, so now reverse them 176 - return insertItems(items.reverse(), newIndex, top) 185 + return insertItems(items.reverse(), newIndex, bias_up) 177 186 } 178 187 179 - function insertItems(items: QueueItem[], index: number, top = false) { 188 + function insertItems(items: QueueItem[], index: number, bias_up = false) { 180 189 queue.update((q) => { 181 190 const user_queue_index = q.past.length + Number(!!q.current) 182 191 index -= user_queue_index 183 - const snapTop = index === q.userQueue.length && top 184 - if (index < q.userQueue.length || snapTop) { 192 + 193 + const to_auto_queue_start = q.userQueue.length === 0 && bias_up 194 + const create_user_queue = to_auto_queue_start && index === 0 195 + 196 + const to_user_queue_end = index === q.userQueue.length && !bias_up 197 + 198 + if (index < q.userQueue.length || create_user_queue || to_user_queue_end) { 185 199 q.userQueue.splice(index, 0, ...items) 186 200 return q 187 201 } ··· 195 209 } 196 210 } 197 211 198 - export function insertIds(ids: TrackID[], index: number, top = false) { 199 - return insertItems(ids.map(newQueueItem), index, top) 212 + export function insertIds(ids: TrackID[], index: number, bias_top = false) { 213 + return insertItems(ids.map(newQueueItem), index, bias_top) 200 214 } 201 215 202 216 function removeIndex(q: Queue, index: number): QueueItem | null {