feat: store current track object to enable clear queue to work correctly

This commit is contained in:
geoffrey45
2022-08-05 20:20:34 +03:00
parent b9f0368f5b
commit aa4db95547
5 changed files with 26 additions and 21 deletions
+13 -9
View File
@@ -1,16 +1,16 @@
import { defineStore } from "pinia";
import state from "../composables/state";
import { useNotifStore, NotifType } from "./notification";
import { NotifType, useNotifStore } from "./notification";
import { FromOptions } from "../composables/enums";
import notif from "../composables/mediaNotification";
import {
Track,
fromFolder,
fromAlbum,
fromFolder,
fromPlaylist,
fromSearch,
Track,
} from "../interfaces";
import notif from "../composables/mediaNotification";
import { FromOptions } from "../composables/enums";
function writeQueue(
from: fromFolder | fromAlbum | fromPlaylist,
@@ -61,13 +61,14 @@ export default defineStore("Queue", {
prev: 0,
currentid: "",
playing: false,
from: <From>{},
tracks: <Track[]>[defaultTrack],
from: {} as From,
currenttrack: {} as Track,
tracks: [defaultTrack] as Track[],
}),
actions: {
play(index: number = 0) {
const track = this.tracks[index];
this.current = index;
const track = this.tracks[index];
this.currentid = track.trackid;
const uri = state.settings.uri + "/file/" + track.trackid;
const elem = document.getElementById("progress");
@@ -165,6 +166,7 @@ export default defineStore("Queue", {
setCurrent(index: number) {
const track = this.tracks[index];
this.currenttrack = track;
this.current = index;
this.currentid = track.trackid;
this.duration.full = track.length;
@@ -250,7 +252,9 @@ export default defineStore("Queue", {
this.next = 0;
this.prev = 0;
this.from = <From>{};
console.log(this.current);
writeQueue(this.from, [defaultTrack] as Track[]);
writeCurrent(0);
},
},
});