@@ -8,6 +8,8 @@ import { type Amethyst, amethyst } from "@/amethyst.js";
88import { fisherYatesShuffle } from "@/logic/math.js" ;
99import { Track } from "@/logic/track.js" ;
1010
11+ import { MediaSourceType } from "./MediaSource/index.js" ;
12+
1113const COMPARATORS_BY_METHOD = {
1214 default : ( ) => 0 ,
1315 trackNumber : ( a , b ) => {
@@ -44,7 +46,7 @@ const COMPARATORS_BY_METHOD = {
4446export type PossibleSortingMethods = keyof typeof COMPARATORS_BY_METHOD ;
4547
4648export class Queue {
47- private savedQueue = useLocalStorage < string [ ] > ( "queuev2" , [ ] ) ;
49+ private savedQueue = useLocalStorage < { path : string ; type : MediaSourceType } [ ] > ( "queuev2" , [ ] ) ;
4850 private list : Ref < Map < string , Track > > = ref ( new Map ( ) ) ;
4951 private lastSearch = "" ;
5052 private lastSearchList : Track [ ] = [ ] ;
@@ -55,9 +57,19 @@ export class Queue {
5557 public currentSortingDirection : Ref < "ascending" | "descending" > = ref ( "ascending" ) ;
5658
5759 public constructor ( private amethyst : Amethyst , paths ?: string [ ] ) {
58- paths
59- ? this . add ( paths )
60- : this . add ( this . savedQueue . value ) ;
60+ if ( paths ) this . add ( paths ) ;
61+ else {
62+ // load saved queue from local storage
63+ this . savedQueue . value . forEach ( ( item ) => {
64+ const track = new Track ( this . amethyst , item . path ) ;
65+
66+ if ( item . type == MediaSourceType . Subsonic ) {
67+ track . sourceType = MediaSourceType . Subsonic ;
68+ }
69+
70+ this . add ( track ) ;
71+ } ) ;
72+ }
6173 }
6274
6375 public getList ( ) {
@@ -112,7 +124,7 @@ export class Queue {
112124 * Saves the current queue to local storage for persistance
113125 */
114126 private syncLocalStorage ( ) {
115- this . savedQueue . value = this . getList ( ) . map ( ( t ) => t . absolutePath ) ;
127+ this . savedQueue . value = this . getList ( ) . map ( ( t ) => ( { path : t . absolutePath , type : t . sourceType } ) ) ;
116128 }
117129
118130 /**
0 commit comments