feat(favorites): add bulk make-offline action to track selection bar

Add CloudDownload button to BulkActionBar for downloading selected
tracks for offline use. Fires v2_cache_favorite_track for each
selected track.

Closes #231

cc
This commit is contained in:
victorrhgap committed 2026-03-31 14:05:10 -06:00
1 parent 93374080a0
commit 759149f32b
2 files changed
+19 -1

No files matched your search

+10 -1
View File
@@ -1,5 +1,5 @@
<script lang="ts">
import { ListPlus, ListEnd, ListMusic, Heart, HeartOff, Trash2, X, ChevronDown } from 'lucide-svelte';
import { ListPlus, ListEnd, ListMusic, Heart, HeartOff, Trash2, X, ChevronDown, CloudDownload } from 'lucide-svelte';
import { t } from 'svelte-i18n';
interface Props {
@@ -10,6 +10,7 @@
onAddFavorites?: () => void;
onRemoveFavorites?: () => void;
onRemoveFromPlaylist?: () => void;
onMakeOffline?: () => void;
onClearSelection: () => void;
placement?: 'top' | 'bottom';
}
@@ -22,6 +23,7 @@
onAddFavorites,
onRemoveFavorites,
onRemoveFromPlaylist,
onMakeOffline,
onClearSelection,
placement = 'bottom',
}: Props = $props();
@@ -92,6 +94,13 @@
<span>{$t('actions.addToPlaylist')}</span>
</button>
{#if onMakeOffline}
<button class="action-btn" onclick={onMakeOffline} title={$t('actions.makeAvailableOffline')}>
<CloudDownload size={15} />
<span>{$t('actions.makeAvailableOffline')}</span>
</button>
{/if}
{#if onAddFavorites}
<button class="action-btn" onclick={onAddFavorites} title={$t('actions.addToFavorites')}>
<Heart size={15} />
@@ -301,6 +301,14 @@
selectedTrackIds = new Set();
}
async function handleBulkMakeOffline() {
for (const id of selectedTrackIds) {
invoke('v2_cache_favorite_track', { trackId: id }).catch(() => {});
}
trackSelectMode = false;
selectedTrackIds = new Set();
}
let albumViewMode = $state<'grid' | 'list'>('grid');
type AlbumGroupMode = 'alpha' | 'artist';
let albumGroupMode = $state<AlbumGroupMode>('alpha');
@@ -1724,6 +1732,7 @@
onPlayNext={handleBulkPlayNext}
onPlayLater={handleBulkPlayLater}
onAddToPlaylist={handleBulkAddToPlaylist}
onMakeOffline={handleBulkMakeOffline}
onRemoveFavorites={handleBulkRemoveFavorites}
onClearSelection={() => { selectedTrackIds = new Set(); }}
/>