Skip to content

Commit

Permalink
exclude steams from save play queue and fix current param
Browse files Browse the repository at this point in the history
  • Loading branch information
tamland committed Oct 21, 2024
1 parent b94c447 commit c5b166e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/player/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,8 @@ function setupAudio(store: Store<any>, mainStore: ReturnType<typeof useMainStore
(_: any, [oldQueue]) => {
if (oldQueue !== null) {
lastSaved.value = Date.now()
const { queue, queueIndex, currentTime } = store.state.player
return api.savePlayQueue(queue, queueIndex, currentTime)
const { queue, currentTime } = store.state.player
return api.savePlayQueue(queue, store.getters['player/track'], currentTime)
}
})

Expand All @@ -409,8 +409,8 @@ function setupAudio(store: Store<any>, mainStore: ReturnType<typeof useMainStore
const duration = now - lastSaved.value
if (duration >= maxDuration) {
lastSaved.value = now
const { queue, queueIndex, currentTime } = store.state.player
return api.savePlayQueue(queue, queueIndex, currentTime)
const { queue, currentTime } = store.state.player
return api.savePlayQueue(queue, store.getters['player/track'], currentTime)
}
})
}
Expand Down
7 changes: 4 additions & 3 deletions src/shared/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,11 @@ export class API {
}
}

async savePlayQueue(tracks: Track[], current: number, currentTime: number) {
async savePlayQueue(tracks: Track[], currentTrack: Track, currentTime: number) {
const tracksIds = tracks.filter(track => !track.isStream).map(track => track.id)
const params = {
id: tracks.map(track => track.id),
current: tracks[current]?.id,
id: tracksIds,
current: currentTrack.isStream ? null : currentTrack.id,
position: Math.round(currentTime * 1000),
}
try {
Expand Down

0 comments on commit c5b166e

Please sign in to comment.