[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 playing track not included when repeating

Kasper (Mar 31, 2023, 1:19 AM +0200) e3cd24c8 bcff0f34

+31 -12
+1
CHANGELOG.md
··· 8 8 - Clicking "Previous" now replays the first track instead of stopping 9 9 - Fix plays and skips not counted for last track in queue 10 10 - Fix playing indicator staying after playback stops 11 + - Fix playing track not included when repeating 11 12 12 13 ## 0.16.5 - 2022 Jan 19 13 14 - Fix queue rearranging reversing tracks
+30 -12
src/lib/queue.ts
··· 29 29 */ 30 30 export type Queue = { 31 31 past: QueueItem[] 32 - current: QueueItem | null 32 + current: { 33 + item: QueueItem 34 + fromAutoQueue: boolean 35 + } | null 33 36 userQueue: QueueItem[] 34 37 autoQueue: QueueItem[] 35 38 } ··· 112 115 }) 113 116 114 117 export function getCurrent() { 115 - return queue.get().current 118 + return queue.get().current?.item ?? null 116 119 } 117 120 export function getQueueLength() { 118 121 const { userQueue, autoQueue } = queue.get() ··· 200 203 export function removeDeleted() { 201 204 const q = queue.get() 202 205 const past = q.past.filter((qi) => methods.trackExists(qi.id)) 203 - const current = q.current && methods.trackExists(q.current.id) ? q.current : null 206 + const current = q.current && methods.trackExists(q.current.item.id) ? q.current : null 204 207 const userQueue = q.userQueue.filter((qi) => methods.trackExists(qi.id)) 205 208 const autoQueue = q.autoQueue.filter((qi) => methods.trackExists(qi.id)) 206 209 if ( ··· 216 219 export function next() { 217 220 const q = queue.get() 218 221 if (q.current) { 219 - q.past.push(q.current) 220 - q.current = null 222 + q.past.push(q.current.item) 221 223 } 222 224 if (q.userQueue.length) { 223 - q.current = q.userQueue.shift()! 225 + q.current = { 226 + item: q.userQueue.shift()!, 227 + fromAutoQueue: false, 228 + } 224 229 } else if (q.autoQueue.length) { 225 - q.current = q.autoQueue.shift()! 226 - if (repeat.get()) { 227 - q.autoQueue.push(newQueueItem(q.current.id)) 230 + if (repeat.get() && q.current) { 231 + q.autoQueue.push(newQueueItem(q.current.item.id)) 228 232 } 233 + q.current = { 234 + item: q.autoQueue.shift()!, 235 + fromAutoQueue: true, 236 + } 237 + } else { 238 + q.current = null 229 239 } 230 240 queue.set(q) 231 241 } ··· 233 243 const q = queue.get() 234 244 if (q.past.length) { 235 245 if (q.current) { 236 - q.userQueue.unshift(q.current) 246 + q.userQueue.unshift(q.current.item) 247 + } 248 + q.current = { 249 + item: q.past.pop()!, 250 + fromAutoQueue: false, 237 251 } 238 - q.current = q.past.pop()! 239 252 queue.set(q) 240 253 } 241 254 } ··· 246 259 const current = newIds.pop() 247 260 queue.set({ 248 261 past: newIds.map(newQueueItem), 249 - current: current ? newQueueItem(current) : null, 262 + current: current 263 + ? { 264 + item: newQueueItem(current), 265 + fromAutoQueue: true, 266 + } 267 + : null, 250 268 userQueue: [], 251 269 autoQueue: autoQueue.map(newQueueItem), 252 270 })