implement favoriting artists

This commit is contained in:
geoffrey45
2022-12-27 20:16:02 +03:00
committed by Mungai Njoroge
parent f7a054d569
commit a0cf95024c
8 changed files with 68 additions and 30 deletions
+26 -2
View File
@@ -31,7 +31,7 @@
</section>
<div class="buttons">
<PlayBtnRect :source="playSources.artist" :store="useArtistPageStore" />
<HeartSvg />
<HeartSvg @handleFav="handleFav" :state="is_fav" />
</div>
</div>
<div class="artist-img no-select">
@@ -56,10 +56,34 @@ import PlayBtnRect from "../shared/PlayBtnRect.vue";
import formatSeconds from "@/utils/useFormatSeconds";
import { isLight } from "@/composables/colors/album";
import { paths } from "@/config";
import { playSources } from "@/composables/enums";
import { favType, playSources } from "@/composables/enums";
import HeartSvg from "@/components/shared/HeartSvg.vue";
import { ref } from "vue";
import { addFavorite, removeFavorite } from "@/composables/fetch/favorite";
const artist = useArtistPageStore();
const is_fav = ref(artist.info.is_favorite);
async function handleFav() {
if (is_fav.value) {
const removed = await removeFavorite(
favType.artist,
artist.info.artisthash
);
if (removed) {
is_fav.value = false;
}
return;
}
const added = await addFavorite(favType.artist, artist.info.artisthash);
if (added) {
is_fav.value = true;
}
}
</script>
<style lang="scss">