feat(favorites): wire album favorite button to Qobuz API
- Add album id to AlbumDetail interface and conversion - Add artist id to enable artist navigation from album view - Wire heart button in AlbumDetailView to call add_favorite/remove_favorite - Fix artist click to use actual artist id instead of hardcoded 0
This commit is contained in:
1 parent
ddbe6b5706
commit
af44e14b0b
2 files changed
+29
-3
No files matched your search
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { invoke } from '@tauri-apps/api/core';
|
||||
import { ArrowLeft, Play, Shuffle, Heart, Plus, MoreHorizontal } from 'lucide-svelte';
|
||||
import TrackRow from '../TrackRow.svelte';
|
||||
|
||||
@@ -17,6 +18,7 @@
|
||||
|
||||
interface Props {
|
||||
album: {
|
||||
id: string;
|
||||
artwork: string;
|
||||
title: string;
|
||||
artist: string;
|
||||
@@ -40,7 +42,27 @@
|
||||
|
||||
let currentTrack = $state<number | null>(null);
|
||||
let isFavorite = $state(false);
|
||||
let isFavoriteLoading = $state(false);
|
||||
let playBtnHovered = $state(false);
|
||||
|
||||
async function toggleFavorite() {
|
||||
if (isFavoriteLoading) return;
|
||||
|
||||
isFavoriteLoading = true;
|
||||
try {
|
||||
if (isFavorite) {
|
||||
await invoke('remove_favorite', { favType: 'album', itemId: album.id });
|
||||
isFavorite = false;
|
||||
} else {
|
||||
await invoke('add_favorite', { favType: 'album', itemId: album.id });
|
||||
isFavorite = true;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Failed to toggle favorite:', err);
|
||||
} finally {
|
||||
isFavoriteLoading = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="album-detail">
|
||||
@@ -83,7 +105,7 @@
|
||||
<Shuffle size={18} />
|
||||
<span>Shuffle</span>
|
||||
</button>
|
||||
<button class="icon-btn" onclick={() => (isFavorite = !isFavorite)}>
|
||||
<button class="icon-btn" onclick={toggleFavorite} disabled={isFavoriteLoading}>
|
||||
<Heart
|
||||
size={20}
|
||||
color={isFavorite ? 'var(--accent-primary)' : 'white'}
|
||||
|
||||
Reference in new issue
Block a user