mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-03 20:13:02 +00:00
fix heart button reactivity on songitem
This commit is contained in:
committed by
Mungai Njoroge
parent
9709a62fea
commit
31312d1754
@@ -14,7 +14,7 @@
|
||||
{{ index }}
|
||||
</div>
|
||||
<div class="heart-icon">
|
||||
<HeartFillSvg v-if="props.track.is_favorite" />
|
||||
<HeartFillSvg v-if="is_fav" />
|
||||
<HeartSvg v-else />
|
||||
</div>
|
||||
</div>
|
||||
@@ -29,7 +29,7 @@
|
||||
</div>
|
||||
<div v-tooltip class="song-title">
|
||||
<div class="with-flag" @click.prevent="emitUpdate">
|
||||
<span class="title ellip" ref="artisttitle">
|
||||
<span class="title ellip">
|
||||
{{ track.title }}
|
||||
</span>
|
||||
<MasterFlag v-if="track.bitrate > 1024" />
|
||||
@@ -70,7 +70,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import { onBeforeUpdate, onUpdated, ref, toRef, watch } from "vue";
|
||||
|
||||
import { showTrackContextMenu as showContext } from "@/composables/context";
|
||||
import { paths } from "@/config";
|
||||
@@ -92,14 +92,14 @@ 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;
|
||||
hide_album?: Boolean;
|
||||
}>();
|
||||
|
||||
const is_fav = ref(props.track.is_favorite);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: "playThis"): void;
|
||||
}>();
|
||||
@@ -120,17 +120,22 @@ function isCurrentPlaying() {
|
||||
return isCurrent() && queue.playing;
|
||||
}
|
||||
|
||||
// const is_fav = ref(props.track.is_favorite);
|
||||
|
||||
function addToFav(trackhash: string) {
|
||||
favoriteHandler(
|
||||
props.track.is_favorite,
|
||||
is_fav.value,
|
||||
favType.track,
|
||||
trackhash,
|
||||
() => (props.track.is_favorite = true),
|
||||
() => (props.track.is_favorite = false)
|
||||
() => (is_fav.value = true),
|
||||
() => (is_fav.value = false)
|
||||
);
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.track.is_favorite,
|
||||
(newValue) => {
|
||||
is_fav.value = newValue;
|
||||
}
|
||||
);
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Track } from "@/interfaces";
|
||||
import queue from "@/stores/queue";
|
||||
import { toRef } from "vue";
|
||||
|
||||
export default function createTrackProps(track: Track) {
|
||||
return {
|
||||
|
||||
@@ -23,7 +23,6 @@ import { computed } from "@vue/reactivity";
|
||||
import { onBeforeRouteLeave, onBeforeRouteUpdate } from "vue-router";
|
||||
|
||||
import { Track } from "@/interfaces";
|
||||
import { createTrackProps } from "@/utils";
|
||||
|
||||
import useAlbumStore from "@/stores/pages/album";
|
||||
import useQueueStore from "@/stores/queue";
|
||||
@@ -61,7 +60,7 @@ class songItem {
|
||||
this.id = Math.random();
|
||||
this.props = track.is_album_disc_number
|
||||
? { album_disc: track }
|
||||
: { ...createTrackProps(track), hide_album: true, index: track.track };
|
||||
: { track, hide_album: true, index: track.track };
|
||||
this.component = track.is_album_disc_number ? AlbumDiscBar : SongItem;
|
||||
}
|
||||
}
|
||||
@@ -94,7 +93,7 @@ function getArtistAlbumComponents(): ScrollerItem[] {
|
||||
albums: ar.albums,
|
||||
title: `More from ${artistname}`,
|
||||
albumType: discographyAlbumTypes.all,
|
||||
route: `/artists/${artisthash}/discography`
|
||||
route: `/artists/${artisthash}/discography`,
|
||||
},
|
||||
size: 20 * 16,
|
||||
};
|
||||
@@ -117,7 +116,7 @@ const scrollerItems = computed(() => {
|
||||
});
|
||||
|
||||
function playFromAlbum(index: number) {
|
||||
const { title, albumartists, albumhash } = album.info;
|
||||
const { title, albumhash } = album.info;
|
||||
queue.playFromAlbum(title, albumhash, album.srcTracks);
|
||||
queue.play(index);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user