mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-03 20:13:02 +00:00
fix slow folder page
~ stabilize props: move isCurrent check to inside SongItem component
This commit is contained in:
committed by
Mungai Njoroge
parent
90dd1a1fe8
commit
0b24974a63
@@ -6,8 +6,6 @@
|
||||
v-for="(song, index) in artist.tracks"
|
||||
:track="song"
|
||||
:index="index + 1"
|
||||
:isCurrent="false"
|
||||
:isCurrentPlaying="false"
|
||||
/>
|
||||
</div>
|
||||
<div class="error" v-if="!artist.tracks.length">No tracks</div>
|
||||
|
||||
@@ -27,8 +27,6 @@
|
||||
: index + 1
|
||||
"
|
||||
@playThis="updateQueue(track.index !== undefined ? track.index : index)"
|
||||
:isCurrentPlaying="queue.playing"
|
||||
:isCurrent="queue.currenttrackhash == track.trackhash"
|
||||
/>
|
||||
</div>
|
||||
<div class="copyright" v-if="copyright && copyright">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div
|
||||
class="songlist-item rounded-sm"
|
||||
:class="[{ current: isCurrent }, { contexton: context_menu_showing }]"
|
||||
:class="[{ current: isCurrent() }, { contexton: context_menu_showing }]"
|
||||
@dblclick.prevent="emitUpdate"
|
||||
@contextmenu.prevent="showMenu"
|
||||
>
|
||||
@@ -16,20 +16,16 @@
|
||||
<img :src="imguri + track.image" class="album-art image rounded-sm" />
|
||||
<div
|
||||
class="now-playing-track-indicator image"
|
||||
v-if="isCurrent"
|
||||
:class="{ last_played: !isCurrentPlaying }"
|
||||
v-if="isCurrent()"
|
||||
:class="{ last_played: !isCurrentPlaying() }"
|
||||
></div>
|
||||
</div>
|
||||
<div v-tooltip class="song-title">
|
||||
<div class="with-flag">
|
||||
<span
|
||||
class="title ellip"
|
||||
@click.prevent="emitUpdate"
|
||||
ref="artisttitle"
|
||||
>
|
||||
<div class="with-flag" @click.prevent="emitUpdate">
|
||||
<span class="title ellip" ref="artisttitle">
|
||||
{{ track.title }}
|
||||
</span>
|
||||
<span v-if="(track.bitrate > 1024)" class="master-flag"><b>M</b> </span>
|
||||
<span v-if="track.bitrate > 1024" class="master-flag"><b>M</b> </span>
|
||||
</div>
|
||||
<div class="isSmallArtists" style="display: none">
|
||||
<ArtistName
|
||||
@@ -78,16 +74,17 @@ import HeartSvg from "@/assets/icons/heart.svg";
|
||||
import OptionSvg from "@/assets/icons/more.svg";
|
||||
import ArtistName from "./ArtistName.vue";
|
||||
|
||||
import useQueueStore from "@/stores/queue";
|
||||
|
||||
const imguri = paths.images.thumb.small;
|
||||
const context_menu_showing = ref(false);
|
||||
const queue = useQueueStore();
|
||||
|
||||
const artisttitle = ref<HTMLElement | null>(null);
|
||||
|
||||
const props = defineProps<{
|
||||
track: Track;
|
||||
index: Number | String;
|
||||
isCurrent: Boolean;
|
||||
isCurrentPlaying: Boolean;
|
||||
hide_album?: Boolean;
|
||||
}>();
|
||||
|
||||
@@ -102,6 +99,14 @@ function emitUpdate() {
|
||||
function showMenu(e: MouseEvent) {
|
||||
showContext(e, props.track, context_menu_showing);
|
||||
}
|
||||
|
||||
function isCurrent() {
|
||||
return queue.currenttrackhash == props.track.trackhash;
|
||||
}
|
||||
|
||||
function isCurrentPlaying() {
|
||||
return isCurrent() && queue.playing;
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
@@ -128,7 +133,7 @@ function showMenu(e: MouseEvent) {
|
||||
color: rgb(255, 153, 0);
|
||||
padding: 2px 5px;
|
||||
border-radius: 5px;
|
||||
opacity: .75;
|
||||
opacity: 0.75;
|
||||
}
|
||||
|
||||
cursor: pointer;
|
||||
|
||||
@@ -50,10 +50,6 @@
|
||||
? t.data.index + 1
|
||||
: t.index + 1
|
||||
"
|
||||
:isCurrent="queue.currenttrackhash === t.data.trackhash"
|
||||
:isCurrentPlaying="
|
||||
queue.currenttrackhash === t.data.trackhash && queue.playing
|
||||
"
|
||||
@playThis="
|
||||
updateQueue(
|
||||
t.data.index !== undefined
|
||||
|
||||
@@ -5,8 +5,5 @@ export default function createTrackProps(track: Track) {
|
||||
return {
|
||||
track,
|
||||
index: track.index + 1,
|
||||
isCurrent: queue().currenttrackhash === track.trackhash,
|
||||
isCurrentPlaying:
|
||||
queue().currenttrackhash === track.trackhash && queue().playing,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ import useQueueStore from "@/stores/queue";
|
||||
|
||||
import FolderList from "@/components/FolderView/FolderList.vue";
|
||||
import SongItem from "@/components/shared/SongItem.vue";
|
||||
import { createTrackProps } from "@/utils";
|
||||
|
||||
const loader = useLoaderStore();
|
||||
const folder = useFolderStore();
|
||||
@@ -59,13 +60,7 @@ class songItem {
|
||||
|
||||
constructor(track: Track) {
|
||||
this.id = Math.random();
|
||||
this.props = {
|
||||
track,
|
||||
index: track.index + 1,
|
||||
isCurrent: queue.currenttrackhash === track.trackhash,
|
||||
isCurrentPlaying:
|
||||
queue.currenttrackhash === track.trackhash && queue.playing,
|
||||
};
|
||||
this.props = createTrackProps(track)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,6 @@ const playlist = usePlaylistStore();
|
||||
interface ScrollerItem {
|
||||
id: string | number;
|
||||
component: typeof Header | typeof SongItem;
|
||||
// props: Record<string, unknown>;
|
||||
size: number;
|
||||
}
|
||||
|
||||
@@ -58,8 +57,6 @@ const scrollerItems = computed(() => {
|
||||
props: {
|
||||
track: track,
|
||||
index: track.index + 1,
|
||||
isCurrent: queue.currenttrackhash === track.trackhash,
|
||||
isCurrentPlaying: queue.currenttrackhash === track.trackhash && queue.playing,
|
||||
},
|
||||
size: 64,
|
||||
};
|
||||
|
||||
@@ -16,10 +16,6 @@
|
||||
<SongItem
|
||||
:track="item.track"
|
||||
:index="index + 1"
|
||||
:isCurrent="queue.currenttrackhash === item.track.trackhash"
|
||||
:isCurrentPlaying="
|
||||
queue.currenttrackhash === item.track.trackhash && queue.playing
|
||||
"
|
||||
@playThis="playFromQueue(index)"
|
||||
/>
|
||||
</RecycleScroller>
|
||||
|
||||
Reference in New Issue
Block a user