refactor queu store to use play track using index

- this allows to have duplicate tracks in queue safely
- store indexes in localstorage instead of track objects.
This commit is contained in:
geoffrey45
2022-07-02 18:13:54 +03:00
committed by Mungai Geoffrey
parent f0d3c1c663
commit c9830842ed
10 changed files with 62 additions and 89 deletions
+8 -4
View File
@@ -9,7 +9,7 @@
:index="track.index"
@updateQueue="updateQueue"
:isPlaying="queue.playing"
:isCurrent="queue.current.trackid == track.trackid"
:isCurrent="queue.currentid == track.trackid"
/>
</div>
</div>
@@ -47,18 +47,22 @@ let route = useRoute().name;
* @param track Track object
*/
function updateQueue(track: Track) {
const index = props.tracks.findIndex(
(t: Track) => t.trackid === track.trackid
);
switch (route) {
case "FolderView":
queue.playFromFolder(props.path, props.tracks);
queue.play(track);
queue.play(index);
break;
case "AlbumView":
queue.playFromAlbum(track.album, track.albumartist, props.tracks);
queue.play(track);
queue.play(index);
break;
case "PlaylistView":
queue.playFromPlaylist(props.pname, props.playlistid, props.tracks);
queue.play(track);
queue.play(index);
break;
}
}