remove transition group from queue track list

This commit is contained in:
geoffrey45
2022-08-27 19:50:43 +03:00
parent d3d7d1f139
commit 465383b5fa
7 changed files with 60 additions and 140 deletions
-1
View File
@@ -32,7 +32,6 @@ onMounted(() => {
<style lang="scss"> <style lang="scss">
.sidebar-playlists { .sidebar-playlists {
// outline: solid 1px;
display: grid; display: grid;
grid-template-rows: max-content 1fr; grid-template-rows: max-content 1fr;
+4 -35
View File
@@ -1,10 +1,10 @@
<template> <template>
<div class="now-playing-card t-center rounded"> <div class="now-playing-card t-center rounded">
<div> <div>
<SongCard :track="queue.currenttrack" /> <SongCard :track="currenttrack" />
<div class="l-track-time"> <div class="l-track-time">
<span class="rounded">{{ formatSeconds(queue.duration.current) }}</span <span class="rounded">{{ formatSeconds(duration.current) }}</span
><span class="rounded">{{ formatSeconds(queue.duration.full) }}</span> ><span class="rounded">{{ formatSeconds(duration.full) }}</span>
</div> </div>
<Progress /> <Progress />
</div> </div>
@@ -13,16 +13,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref } from "vue";
import useModalStore from "@/stores/modal";
import useQueueStore from "@/stores/queue";
import useQStore from "../../stores/queue"; import useQStore from "../../stores/queue";
import useContextStore from "@/stores/context";
import MenuSvg from "../../assets/icons/more.svg";
import trackContext from "@/contexts/track_context";
import { ContextSrc } from "@/composables/enums";
import { formatSeconds } from "@/utils"; import { formatSeconds } from "@/utils";
import HotKeys from "./NP/HotKeys.vue"; import HotKeys from "./NP/HotKeys.vue";
@@ -30,28 +21,7 @@ import Progress from "./NP/Progress.vue";
import SongCard from "./NP/SongCard.vue"; import SongCard from "./NP/SongCard.vue";
const queue = useQStore(); const queue = useQStore();
const contextStore = useContextStore(); const { currenttrack, duration } = queue;
const context_on = ref(false);
const showContextMenu = (e: Event) => {
e.preventDefault();
e.stopPropagation();
const menus = trackContext(
queue.tracklist[queue.current],
useModalStore,
useQueueStore
);
contextStore.showContextMenu(e, menus, ContextSrc.Track);
context_on.value = true;
contextStore.$subscribe((mutation, state) => {
if (!state.visible) {
context_on.value = false;
}
});
};
</script> </script>
<style lang="scss"> <style lang="scss">
.now-playing-card { .now-playing-card {
@@ -88,7 +58,6 @@ const showContextMenu = (e: Event) => {
} }
} }
.context_on { .context_on {
background-color: $accent; background-color: $accent;
} }
@@ -48,8 +48,6 @@ const props = defineProps<{
.bottom { .bottom {
margin-top: $smaller; margin-top: $smaller;
display: grid;
justify-items: center;
.name { .name {
font-weight: 900; font-weight: 900;
+3 -3
View File
@@ -7,13 +7,13 @@
> >
<div class="grid"> <div class="grid">
<div class="r-content"> <div class="r-content">
<div class="r-dash" v-show="tabs.current === tabs.tabs.home"> <div class="r-dash" v-if="tabs.current === tabs.tabs.home">
<DashBoard /> <DashBoard />
</div> </div>
<div class="r-search" v-show="tabs.current === tabs.tabs.search"> <div class="r-search" v-if="tabs.current === tabs.tabs.search">
<Search /> <Search />
</div> </div>
<div class="r-queue" v-show="tabs.current === tabs.tabs.queue"> <div class="r-queue" v-if="tabs.current === tabs.tabs.queue">
<Queue /> <Queue />
</div> </div>
</div> </div>
+10 -28
View File
@@ -8,18 +8,16 @@
@mouseenter="setMouseOver(true)" @mouseenter="setMouseOver(true)"
@mouseleave="setMouseOver(false)" @mouseleave="setMouseOver(false)"
> >
<TransitionGroup name="queuelist"> <TrackItem
<TrackItem v-for="(t, index) in queue.tracklist"
v-for="(t, index) in queue.tracklist" :key="index"
:key="index" :track="t"
:track="t" @playThis="queue.play(index)"
@playThis="queue.play(index)" :isCurrent="index === queue.currentindex"
:isCurrent="index === queue.current" :isPlaying="queue.playing"
:isPlaying="queue.playing" :isQueueTrack="true"
:isQueueTrack="true" :index="index"
:index="index" />
/>
</TransitionGroup>
</div> </div>
</div> </div>
</div> </div>
@@ -52,21 +50,6 @@ onUpdated(() => {
</script> </script>
<style lang="scss"> <style lang="scss">
.queuelist-move, /* apply transition to moving elements */
.queuelist-enter-active {
transition: all 0.5s ease-in-out;
}
.queuelist-enter-from,
.queuelist-leave-to {
opacity: 0;
}
.queuelist-leave-active {
transition: none;
position: absolute;
}
.up-next { .up-next {
overflow: hidden; overflow: hidden;
height: 100%; height: 100%;
@@ -80,7 +63,6 @@ onUpdated(() => {
position: relative; position: relative;
height: 100%; height: 100%;
.scrollable-r { .scrollable-r {
height: 100%; height: 100%;
overflow: hidden; overflow: hidden;
+13 -13
View File
@@ -1,4 +1,3 @@
import { Track } from "../interfaces.js";
import { paths } from "../config"; import { paths } from "../config";
import useQueueStore from "../stores/queue"; import useQueueStore from "../stores/queue";
@@ -6,54 +5,55 @@ import useQueueStore from "../stores/queue";
export default () => { export default () => {
if ("mediaSession" in navigator) { if ("mediaSession" in navigator) {
const queue = useQueueStore(); const queue = useQueueStore();
const { currenttrack: track } = queue;
navigator.mediaSession.metadata = new window.MediaMetadata({ navigator.mediaSession.metadata = new window.MediaMetadata({
title: queue.currenttrack.title, title: track.title,
artist: queue.currenttrack.artists.join(", "), artist: track.artists.join(", "),
artwork: [ artwork: [
{ {
src: paths.images.thumb + queue.currenttrack.image, src: paths.images.thumb + track.image,
sizes: "96x96", sizes: "96x96",
type: "image/jpeg", type: "image/jpeg",
}, },
{ {
src: paths.images.thumb + queue.currenttrack.image, src: paths.images.thumb + track.image,
sizes: "128x128", sizes: "128x128",
type: "image/webp", type: "image/webp",
}, },
{ {
src: paths.images.thumb + queue.currenttrack.image, src: paths.images.thumb + track.image,
sizes: "192x192", sizes: "192x192",
type: "image/webp", type: "image/webp",
}, },
{ {
src: paths.images.thumb + queue.currenttrack.image, src: paths.images.thumb + track.image,
sizes: "256x256", sizes: "256x256",
type: "image/webp", type: "image/webp",
}, },
{ {
src: paths.images.thumb + queue.currenttrack.image, src: paths.images.thumb + track.image,
sizes: "384x384", sizes: "384x384",
type: "image/webp", type: "image/webp",
}, },
{ {
src: paths.images.thumb + queue.currenttrack.image, src: paths.images.thumb + track.image,
sizes: "512x512", sizes: "512x512",
type: "image/webp", type: "image/webp",
}, },
], ],
}); });
navigator.mediaSession.setActionHandler("play", function () { navigator.mediaSession.setActionHandler("play", () => {
queue.playPause(); queue.playPause();
}); });
navigator.mediaSession.setActionHandler("pause", function () { navigator.mediaSession.setActionHandler("pause", () => {
queue.playPause(); queue.playPause();
}); });
navigator.mediaSession.setActionHandler("previoustrack", function () { navigator.mediaSession.setActionHandler("previoustrack", () => {
queue.playPrev(); queue.playPrev();
}); });
navigator.mediaSession.setActionHandler("nexttrack", function () { navigator.mediaSession.setActionHandler("nexttrack", () => {
queue.playNext(); queue.playNext();
}); });
} }
+30 -58
View File
@@ -32,23 +32,19 @@ export default defineStore("Queue", {
current: 0, current: 0,
full: 0, full: 0,
}, },
current: 0, currentindex: 0,
next: 0,
prev: 0,
currentid: <string | null>"", currentid: <string | null>"",
playing: false, playing: false,
from: {} as From, from: {} as From,
currenttrack: {} as Track,
tracklist: [] as Track[], tracklist: [] as Track[],
}), }),
actions: { actions: {
play(index: number = 0) { play(index: number = 0) {
if (this.tracklist.length === 0) return; if (this.tracklist.length === 0) return;
this.current = index; this.currentindex = index;
const track = this.tracklist[index]; const track = this.tracklist[index];
this.currentid = track.trackid; this.currentid = track.trackid;
const uri = state.settings.uri + "/file/" + track.hash; const uri = state.settings.uri + "/file/" + track.hash;
this.updateCurrent(index);
new Promise((resolve, reject) => { new Promise((resolve, reject) => {
audio.autoplay = true; audio.autoplay = true;
@@ -78,7 +74,7 @@ export default defineStore("Queue", {
NotifType.Error NotifType.Error
); );
if (this.current !== this.tracklist.length - 1) { if (this.currentindex !== this.tracklist.length - 1) {
setTimeout(() => { setTimeout(() => {
this.playNext(); this.playNext();
}, 1000); }, 1000);
@@ -87,7 +83,7 @@ export default defineStore("Queue", {
}, },
playPause() { playPause() {
if (audio.src === "") { if (audio.src === "") {
this.play(this.current); this.play(this.currentindex);
} else if (audio.paused) { } else if (audio.paused) {
audio.play(); audio.play();
this.playing = true; this.playing = true;
@@ -97,10 +93,10 @@ export default defineStore("Queue", {
} }
}, },
playNext() { playNext() {
this.play(this.next); this.play(this.nextindex);
}, },
playPrev() { playPrev() {
this.play(this.prev); this.play(this.previndex);
}, },
seek(pos: number) { seek(pos: number) {
try { try {
@@ -120,35 +116,6 @@ export default defineStore("Queue", {
this.tracklist = parsed.tracks; this.tracklist = parsed.tracks;
} }
}, },
updateCurrent(index: number) {
this.setCurrent(index);
this.updateNext(index);
this.updatePrev(index);
},
updateNext(index: number) {
if (index == this.tracklist.length - 1) {
this.next = 0;
return;
}
this.next = index + 1;
},
updatePrev(index: number) {
if (index === 0) {
this.prev = this.tracklist.length - 1;
return;
}
this.prev = index - 1;
},
setCurrent(index: number) {
const track = this.tracklist[index];
this.currenttrack = track;
this.current = index;
this.currentid = track?.trackid || null;
this.duration.full = track?.length || 0;
},
setNewQueue(tracklist: Track[]) { setNewQueue(tracklist: Track[]) {
if (this.tracklist !== tracklist) { if (this.tracklist !== tracklist) {
this.tracklist = []; this.tracklist = [];
@@ -197,13 +164,11 @@ export default defineStore("Queue", {
}, },
addTrackToQueue(track: Track) { addTrackToQueue(track: Track) {
this.tracklist.push(track); this.tracklist.push(track);
// writeQueue(this.from, this.tracklist);
this.updateNext(this.current);
}, },
playTrackNext(track: Track) { playTrackNext(track: Track) {
const Toast = useNotifStore(); const Toast = useNotifStore();
const nextindex = this.current + 1; const nextindex = this.currentindex + 1;
const next: Track = this.tracklist[nextindex]; const next: Track = this.tracklist[nextindex];
// if track is already next, skip // if track is already next, skip
@@ -214,14 +179,13 @@ export default defineStore("Queue", {
// if tracklist is empty or current track is last, push track // if tracklist is empty or current track is last, push track
// else insert track after current track // else insert track after current track
if (this.current == this.tracklist.length - 1) { if (this.currentindex == this.tracklist.length - 1) {
this.tracklist.push(track); this.tracklist.push(track);
} else { } else {
this.tracklist.splice(this.current + 1, 0, track); this.tracklist.splice(this.currentindex + 1, 0, track);
} }
// save queue // save queue
this.updateNext(this.current);
Toast.showNotification( Toast.showNotification(
`Added ${track.title} to queue`, `Added ${track.title} to queue`,
NotifType.Success NotifType.Success
@@ -230,7 +194,7 @@ export default defineStore("Queue", {
clearQueue() { clearQueue() {
this.tracklist = [] as Track[]; this.tracklist = [] as Track[];
this.currentid = ""; this.currentid = "";
this.current, this.next, (this.prev = 0); this.currentindex = 0;
this.from = <From>{}; this.from = <From>{};
}, },
shuffleQueue() { shuffleQueue() {
@@ -243,34 +207,42 @@ export default defineStore("Queue", {
const shuffled = shuffle(this.tracklist); const shuffled = shuffle(this.tracklist);
this.tracklist = shuffled; this.tracklist = shuffled;
this.current = 0; this.currentindex = 0;
this.play(this.current); this.play(this.currentindex);
this.currentid = shuffled[0].trackid; this.currentid = shuffled[0].trackid;
this.next = 1;
this.prev = this.tracklist.length - 1;
}, },
removeFromQueue(index: number = 0) { removeFromQueue(index: number = 0) {
this.tracklist.splice(index, 1); this.tracklist.splice(index, 1);
}, },
}, },
getters: { getters: {
getNextTrack(): Track { next(): Track {
if (this.current == this.tracklist.length - 1) { if (this.currentindex == this.tracklist.length - 1) {
return this.tracklist[0]; return this.tracklist[0];
} else { } else {
return this.tracklist[this.current + 1]; return this.tracklist[this.currentindex + 1];
} }
}, },
getPrevTrack(): Track { prev(): Track {
if (this.current === 0) { if (this.currentindex === 0) {
return this.tracklist[this.tracklist.length - 1]; return this.tracklist[this.tracklist.length - 1];
} else { } else {
return this.tracklist[this.current - 1]; return this.tracklist[this.currentindex - 1];
} }
}, },
getCurrentTrack(): Track { currenttrack(): Track {
return this.tracklist[this.current]; return this.tracklist[this.currentindex];
},
previndex(): number {
return this.currentindex === 0
? this.tracklist.length - 1
: this.currentindex - 1;
},
nextindex(): number {
return this.currentindex === this.tracklist.length - 1
? 0
: this.currentindex + 1;
}, },
}, },
persist: { persist: {