update track interface to follow server updates

+ add search debounce time
This commit is contained in:
geoffrey45
2022-09-11 20:37:29 +03:00
parent 47fc7fd705
commit f5b6791d4b
14 changed files with 50 additions and 43 deletions
+4 -4
View File
@@ -21,7 +21,7 @@
:track="track" :track="track"
:index=" :index="
on_album_page on_album_page
? track.tracknumber ? track.track
: track.index !== undefined : track.index !== undefined
? track.index + 1 ? track.index + 1
: index + 1 : index + 1
@@ -43,9 +43,9 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref } from "vue";
import { useElementSize } from "@vueuse/core";
import { computed } from "@vue/reactivity"; import { computed } from "@vue/reactivity";
import { useElementSize } from "@vueuse/core";
import { ref } from "vue";
import SongItem from "../shared/SongItem.vue"; import SongItem from "../shared/SongItem.vue";
@@ -90,7 +90,7 @@ function updateQueue(index: number) {
function getTrackList() { function getTrackList() {
if (props.on_album_page) { if (props.on_album_page) {
const tracks = props.tracks.map((track) => { const tracks = props.tracks.map((track) => {
track.index = track.tracknumber; track.index = track.track;
return track; return track;
}); });
+1 -1
View File
@@ -9,7 +9,7 @@
@change="seek()" @change="seek()"
:style="{ :style="{
backgroundSize: `${ backgroundSize: `${
(time.current / (q.currenttrack?.length || 0)) * 100 (time.current / (q.currenttrack?.duration || 0)) * 100
}% 100%`, }% 100%`,
}" }"
/> />
+6 -6
View File
@@ -16,18 +16,17 @@
loading="lazy" loading="lazy"
/> />
<div id="bitrate" v-if="track?.bitrate"> <div id="bitrate" v-if="track?.bitrate">
<span v-if="track.bitrate > 1500">MASTER</span> {{ track.filetype }} {{ track.bitrate }}
<span v-else-if="track.bitrate > 330">FLAC</span>
<span v-else>MP3</span>
{{ track.bitrate }}
</div> </div>
</div> </div>
</router-link> </router-link>
<div class="bottom"> <div class="bottom">
<div class="title ellip t-center">{{ props.track?.title || '♥ Hello ♥' }}</div> <div class="title ellip t-center">
{{ props.track?.title || "♥ Hello ♥" }}
</div>
<ArtistName <ArtistName
:artists="track?.artists || []" :artists="track?.artist || []"
:albumartist="track?.albumartist || 'Play something'" :albumartist="track?.albumartist || 'Play something'"
class="artists" class="artists"
/> />
@@ -74,6 +73,7 @@ const imguri = paths.images.thumb;
background-color: $black; background-color: $black;
border-radius: $smaller; border-radius: $smaller;
box-shadow: 0rem 0rem 1rem rgba(0, 0, 0, 0.438); box-shadow: 0rem 0rem 1rem rgba(0, 0, 0, 0.438);
text-transform: uppercase;
} }
} }
@@ -10,7 +10,7 @@
<div class="np-artist ellip"> <div class="np-artist ellip">
<span <span
v-for="artist in putCommas( v-for="artist in putCommas(
queue.currenttrack?.artists || ['♥ Hello ♥'] queue.currenttrack?.artist || ['♥ Hello ♥']
)" )"
> >
{{ artist }} {{ artist }}
+1 -1
View File
@@ -10,7 +10,7 @@
<div class="tags"> <div class="tags">
<div class="title ellip">{{ track?.title || "Don't click here" }}</div> <div class="title ellip">{{ track?.title || "Don't click here" }}</div>
<div class="artist ellip" v-if="track"> <div class="artist ellip" v-if="track">
<span v-for="artist in putCommas(track.artists)" :key="artist">{{ <span v-for="artist in putCommas(track.artist)" :key="artist">{{
artist artist
}}</span> }}</span>
</div> </div>
+4 -4
View File
@@ -30,10 +30,10 @@
<script setup lang="ts"> <script setup lang="ts">
import { onMounted } from "vue"; import { onMounted } from "vue";
import QueueSvg from "../../assets/icons/queue.svg"; import QueueSvg from "@/assets/icons/queue.svg";
import SearchSvg from "../../assets/icons/search.svg"; import SearchSvg from "@/assets/icons/search.svg";
import useSearchStore from "../../stores/search"; import useSearchStore from "@/stores/search";
import useTabStore from "../../stores/tabs"; import useTabStore from "@/stores/tabs";
const search = useSearchStore(); const search = useSearchStore();
const tabs = useTabStore(); const tabs = useTabStore();
+10 -4
View File
@@ -2,7 +2,11 @@
<div v-tooltip="returnArtists()" style="width: auto"> <div v-tooltip="returnArtists()" style="width: auto">
<div <div
class="ellip" class="ellip"
v-if="artists.length === 0 || (artists[0] === '' && artists.length === 1)" v-if="
artists === null ||
artists.length === 0 ||
(artists[0] === '' && artists.length === 1)
"
> >
<span>{{ albumartist }}</span> <span>{{ albumartist }}</span>
</div> </div>
@@ -18,15 +22,17 @@
import { putCommas } from "@/utils"; import { putCommas } from "@/utils";
const props = defineProps<{ const props = defineProps<{
artists: string[]; artists: string[] | null;
albumartist: string | undefined; albumartist: string | undefined;
}>(); }>();
function returnArtists() { function returnArtists() {
if (props.artists === null) return props.albumartist;
if (props.artists[0] !== "" && props.artists.length > 1) { if (props.artists[0] !== "" && props.artists.length > 1) {
return props.artists.join(", "); return props.artists.join(", ");
} else {
return props.albumartist;
} }
return props.albumartist;
} }
</script> </script>
+5 -5
View File
@@ -28,14 +28,14 @@
</div> </div>
<div class="isSmallArtists" style="display: none"> <div class="isSmallArtists" style="display: none">
<ArtistName <ArtistName
:artists="track.artists" :artists="track.artist"
:albumartist="track.albumartist" :albumartist="track.albumartist"
/> />
</div> </div>
</div> </div>
</div> </div>
<div class="song-artists"> <div class="song-artists">
<ArtistName :artists="track.artists" :albumartist="track.albumartist" /> <ArtistName :artists="track.artist" :albumartist="track.albumartist" />
</div> </div>
<router-link <router-link
class="song-album ellip" class="song-album ellip"
@@ -43,14 +43,14 @@
:to="{ :to="{
name: 'AlbumView', name: 'AlbumView',
params: { params: {
hash: track.albumhash, hash: track.albumhash || 'Unknown',
}, },
}" }"
> >
{{ track.album }} {{ track.album }}
</router-link> </router-link>
<div class="song-duration"> <div class="song-duration">
<div class="text ellip">{{ formatSeconds(track.length) }}</div> <div class="text ellip">{{ formatSeconds(track.duration) }}</div>
</div> </div>
<div <div
class="options-icon circular" class="options-icon circular"
@@ -82,7 +82,7 @@ const artisttitle = ref<HTMLElement | null>(null);
const props = defineProps<{ const props = defineProps<{
track: Track; track: Track;
index: number; index: number | string;
isPlaying: Boolean; isPlaying: Boolean;
isCurrent: Boolean; isCurrent: Boolean;
}>(); }>();
+1 -1
View File
@@ -24,7 +24,7 @@
</div> </div>
<hr /> <hr />
<div class="artist"> <div class="artist">
<ArtistName :artists="track.artists" :albumartist="track.albumartist" /> <ArtistName :artists="track.artist" :albumartist="track.albumartist" />
</div> </div>
</div> </div>
<div <div
+1 -1
View File
@@ -9,7 +9,7 @@ export default () => {
navigator.mediaSession.metadata = new window.MediaMetadata({ navigator.mediaSession.metadata = new window.MediaMetadata({
title: track.title, title: track.title,
artist: track.artists.join(", "), artist: track.artist.join(", "),
artwork: [ artwork: [
{ {
src: paths.images.thumb + track.image, src: paths.images.thumb + track.image,
+4 -4
View File
@@ -5,8 +5,8 @@ import { Option } from "../interfaces";
import Router from "../router"; import Router from "../router";
import { import {
addTrackToPlaylist, addTrackToPlaylist,
getAllPlaylists, getAllPlaylists
} from "../composables/fetch/playlists"; } from "../composables/fetch/playlists";
import useModalStore from "../stores/modal"; import useModalStore from "../stores/modal";
@@ -27,7 +27,7 @@ export default async (
type: "separator", type: "separator",
}; };
const single_artist = track.artists.length === 1; const single_artist = track.artist.length === 1;
let playlists = <Option[]>[]; let playlists = <Option[]>[];
const p = await getAllPlaylists(); const p = await getAllPlaylists();
@@ -46,7 +46,7 @@ export default async (
return false; return false;
} }
return track.artists.map((artist) => { return track.artist.map((artist) => {
return <Option>{ return <Option>{
label: artist, label: artist,
action: () => console.log("artist"), action: () => console.log("artist"),
+5 -4
View File
@@ -4,20 +4,21 @@ export interface Track {
trackid: string; trackid: string;
title: string; title: string;
album?: string; album?: string;
artists: string[]; artist: string[];
albumartist?: string; albumartist?: string;
albumhash?: string; albumhash?: string;
folder?: string; folder?: string;
filepath?: string; filepath?: string;
length?: number; duration?: number;
bitrate?: number; bitrate?: number;
genre?: string; genre?: string;
image: string; image: string;
tracknumber: number; track: string;
discnumber: number; disc: string;
index: number; index: number;
hash: string; hash: string;
copyright?: string; copyright?: string;
filetype: string
} }
export interface Folder { export interface Folder {
+6 -6
View File
@@ -4,14 +4,14 @@ import { ComputedRef } from "vue";
import { FuseTrackOptions } from "@/composables/enums"; import { FuseTrackOptions } from "@/composables/enums";
import { getAlbumBio, getAlbumTracks } from "../../composables/fetch/album"; import { getAlbumTracks } from "../../composables/fetch/album";
import { AlbumInfo, Artist, FuseResult, Track } from "../../interfaces"; import { AlbumInfo, Artist, FuseResult, Track } from "../../interfaces";
import { useNotifStore } from "../notification"; import { useNotifStore } from "../notification";
function sortTracks(tracks: Track[]) { function sortTracks(tracks: Track[]) {
return tracks.sort((a, b) => { return tracks.sort((a, b) => {
if (a.tracknumber && b.tracknumber) { if (a.track && b.track) {
return a.tracknumber - b.tracknumber; return a.track - b.track;
} }
return 0; return 0;
@@ -24,9 +24,9 @@ interface Discs {
function createDiscs(tracks: Track[]): Discs { function createDiscs(tracks: Track[]): Discs {
return tracks.reduce((group, track) => { return tracks.reduce((group, track) => {
const { discnumber } = track; const { disc } = track;
group[discnumber] = group[discnumber] ?? []; group[disc] = group[disc] ?? [];
group[discnumber].push(track); group[disc].push(track);
return group; return group;
}, {} as Discs); }, {} as Discs);
} }
+1 -1
View File
@@ -32,7 +32,7 @@ function scrollOnLoad() {
export default defineStore("search", () => { export default defineStore("search", () => {
// @ts-ignore // @ts-ignore
const query = ref(""); const query = ref("");
const debouncedQuery = useDebounce(query); const debouncedQuery = useDebounce(query, 500);
const { startLoading, stopLoading } = useLoaderStore(); const { startLoading, stopLoading } = useLoaderStore();
const route = useRoute(); const route = useRoute();