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