Old queue migration system
This commit is contained in:
parent
8367e09e6c
commit
e4759d14c9
|
@ -13,6 +13,8 @@ import { useTracks } from '~/composables/audio/tracks'
|
||||||
import { gettext } from '~/init/locale'
|
import { gettext } from '~/init/locale'
|
||||||
|
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
|
import { set } from 'idb-keyval'
|
||||||
|
import { setGain } from './audio-api'
|
||||||
|
|
||||||
export interface QueueTrackSource {
|
export interface QueueTrackSource {
|
||||||
uuid: string
|
uuid: string
|
||||||
|
@ -308,6 +310,25 @@ export const useQueue = createGlobalState(() => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Remove at 1.5.0
|
||||||
|
// Migrate old queue format to the new one
|
||||||
|
if (localStorage.queue) {
|
||||||
|
(async () => {
|
||||||
|
const { queue: { currentIndex: index, tracks } } = JSON.parse(localStorage.queue) as { queue: { currentIndex: number, tracks: Track[] } }
|
||||||
|
if (tracks.length !== 0) {
|
||||||
|
await enqueue(...tracks)
|
||||||
|
}
|
||||||
|
|
||||||
|
currentIndex.value = index
|
||||||
|
delete localStorage.queue
|
||||||
|
|
||||||
|
const { looping: loopingMode, volume } = JSON.parse(localStorage.player)
|
||||||
|
looping.value = loopingMode
|
||||||
|
setGain(volume)
|
||||||
|
delete localStorage.player
|
||||||
|
})().catch((error) => console.error('Could not successfully migrate between queue versions', error))
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
tracks,
|
tracks,
|
||||||
queue,
|
queue,
|
||||||
|
|
Loading…
Reference in New Issue