Migrate all queue operations to V2 commands
- Add V2 queue commands: v2_set_shuffle, v2_move_queue_track, v2_add_tracks_to_queue, v2_add_tracks_to_queue_next, v2_remove_upcoming_track - Migrate queueStore.ts to use all V2 queue commands - Update all view components to use V2 queue commands: - HomeView, SearchView, ArtistDetailView, FavoritesView - LocalLibraryView, PlaylistDetailView - Update +page.svelte to use V2 shuffle, repeat, and remove commands No legacy queue commands are called from frontend anymore.
This commit is contained in:
1 parent
67ed397d02
commit
6cea4149c0
10 files changed
+138
-71
No files matched your search
@@ -401,6 +401,17 @@ pub async fn v2_toggle_shuffle(
|
|||||||
Ok(bridge.toggle_shuffle().await)
|
Ok(bridge.toggle_shuffle().await)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set shuffle mode directly (V2)
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn v2_set_shuffle(
|
||||||
|
enabled: bool,
|
||||||
|
app_state: State<'_, AppState>,
|
||||||
|
) -> Result<(), String> {
|
||||||
|
log::info!("[V2] set_shuffle: {}", enabled);
|
||||||
|
app_state.queue.set_shuffle(enabled);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
/// Clear the queue (V2 - uses QbzCore)
|
/// Clear the queue (V2 - uses QbzCore)
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn v2_clear_queue(
|
pub async fn v2_clear_queue(
|
||||||
@@ -530,6 +541,17 @@ pub async fn v2_remove_from_queue(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Remove a track from the upcoming queue by its position (V2)
|
||||||
|
/// (0 = first upcoming track, handles shuffle mode correctly)
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn v2_remove_upcoming_track(
|
||||||
|
upcoming_index: usize,
|
||||||
|
app_state: State<'_, AppState>,
|
||||||
|
) -> Result<Option<V2QueueTrack>, String> {
|
||||||
|
log::info!("[V2] remove_upcoming_track: upcoming_index {}", upcoming_index);
|
||||||
|
Ok(app_state.queue.remove_upcoming_track(upcoming_index).map(Into::into))
|
||||||
|
}
|
||||||
|
|
||||||
/// Skip to next track in queue (V2)
|
/// Skip to next track in queue (V2)
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn v2_next_track(
|
pub async fn v2_next_track(
|
||||||
@@ -561,6 +583,45 @@ pub async fn v2_play_queue_index(
|
|||||||
Ok(track.map(Into::into))
|
Ok(track.map(Into::into))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Move a track within the queue (V2)
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn v2_move_queue_track(
|
||||||
|
from_index: usize,
|
||||||
|
to_index: usize,
|
||||||
|
app_state: State<'_, AppState>,
|
||||||
|
) -> Result<bool, String> {
|
||||||
|
log::info!("[V2] move_queue_track: {} -> {}", from_index, to_index);
|
||||||
|
Ok(app_state.queue.move_track(from_index, to_index))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Add multiple tracks to queue (V2)
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn v2_add_tracks_to_queue(
|
||||||
|
tracks: Vec<V2QueueTrack>,
|
||||||
|
app_state: State<'_, AppState>,
|
||||||
|
) -> Result<(), String> {
|
||||||
|
log::info!("[V2] add_tracks_to_queue: {} tracks", tracks.len());
|
||||||
|
let queue_tracks: Vec<crate::queue::QueueTrack> = tracks.into_iter().map(|t| t.into()).collect();
|
||||||
|
app_state.queue.add_tracks(queue_tracks);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Add multiple tracks to play next (V2)
|
||||||
|
/// Tracks are added in reverse order so they play in the order provided
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn v2_add_tracks_to_queue_next(
|
||||||
|
tracks: Vec<V2QueueTrack>,
|
||||||
|
app_state: State<'_, AppState>,
|
||||||
|
) -> Result<(), String> {
|
||||||
|
log::info!("[V2] add_tracks_to_queue_next: {} tracks", tracks.len());
|
||||||
|
// Add in reverse order so they end up in the correct order
|
||||||
|
for track in tracks.into_iter().rev() {
|
||||||
|
let queue_track: crate::queue::QueueTrack = track.into();
|
||||||
|
app_state.queue.add_track_next(queue_track);
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
// ==================== Search Commands (V2) ====================
|
// ==================== Search Commands (V2) ====================
|
||||||
|
|
||||||
/// Search for albums (V2 - uses QbzCore)
|
/// Search for albums (V2 - uses QbzCore)
|
||||||
|
|||||||
@@ -1107,14 +1107,19 @@ pub fn run() {
|
|||||||
commands_v2::v2_get_queue_state,
|
commands_v2::v2_get_queue_state,
|
||||||
commands_v2::v2_set_repeat_mode,
|
commands_v2::v2_set_repeat_mode,
|
||||||
commands_v2::v2_toggle_shuffle,
|
commands_v2::v2_toggle_shuffle,
|
||||||
|
commands_v2::v2_set_shuffle,
|
||||||
commands_v2::v2_clear_queue,
|
commands_v2::v2_clear_queue,
|
||||||
commands_v2::v2_add_to_queue,
|
commands_v2::v2_add_to_queue,
|
||||||
commands_v2::v2_add_to_queue_next,
|
commands_v2::v2_add_to_queue_next,
|
||||||
commands_v2::v2_set_queue,
|
commands_v2::v2_set_queue,
|
||||||
commands_v2::v2_remove_from_queue,
|
commands_v2::v2_remove_from_queue,
|
||||||
|
commands_v2::v2_remove_upcoming_track,
|
||||||
commands_v2::v2_next_track,
|
commands_v2::v2_next_track,
|
||||||
commands_v2::v2_previous_track,
|
commands_v2::v2_previous_track,
|
||||||
commands_v2::v2_play_queue_index,
|
commands_v2::v2_play_queue_index,
|
||||||
|
commands_v2::v2_move_queue_track,
|
||||||
|
commands_v2::v2_add_tracks_to_queue,
|
||||||
|
commands_v2::v2_add_tracks_to_queue_next,
|
||||||
// Search
|
// Search
|
||||||
commands_v2::v2_search_albums,
|
commands_v2::v2_search_albums,
|
||||||
commands_v2::v2_search_tracks,
|
commands_v2::v2_search_tracks,
|
||||||
|
|||||||
@@ -851,7 +851,7 @@
|
|||||||
console.log(`[Artist] Context created: "${artist.name}" top tracks, ${trackIds.length} tracks, starting at ${index}`);
|
console.log(`[Artist] Context created: "${artist.name}" top tracks, ${trackIds.length} tracks, starting at ${index}`);
|
||||||
try {
|
try {
|
||||||
const queueTracks = buildTopTracksQueue(topTracks);
|
const queueTracks = buildTopTracksQueue(topTracks);
|
||||||
await invoke('set_queue', { tracks: queueTracks, startIndex: index });
|
await invoke('v2_set_queue', { tracks: queueTracks, startIndex: index });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to set queue:', err);
|
console.error('Failed to set queue:', err);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1082,7 +1082,7 @@
|
|||||||
async function setFavoritesQueue(startIndex: number) {
|
async function setFavoritesQueue(startIndex: number) {
|
||||||
if (filteredTracks.length === 0) return;
|
if (filteredTracks.length === 0) return;
|
||||||
const queueTracks = buildFavoritesQueueTracks(filteredTracks);
|
const queueTracks = buildFavoritesQueueTracks(filteredTracks);
|
||||||
await invoke('set_queue', { tracks: queueTracks, startIndex });
|
await invoke('v2_set_queue', { tracks: queueTracks, startIndex });
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleTrackClick(track: FavoriteTrack, index: number) {
|
async function handleTrackClick(track: FavoriteTrack, index: number) {
|
||||||
@@ -1119,7 +1119,7 @@
|
|||||||
// Shuffle the tracks
|
// Shuffle the tracks
|
||||||
const shuffled = [...filteredTracks].sort(() => Math.random() - 0.5);
|
const shuffled = [...filteredTracks].sort(() => Math.random() - 0.5);
|
||||||
const queueTracks = buildFavoritesQueueTracks(shuffled);
|
const queueTracks = buildFavoritesQueueTracks(shuffled);
|
||||||
await invoke('set_queue', { tracks: queueTracks, startIndex: 0 });
|
await invoke('v2_set_queue', { tracks: queueTracks, startIndex: 0 });
|
||||||
await setFavoritesContext(shuffled.map(trk => trk.id), 0);
|
await setFavoritesContext(shuffled.map(trk => trk.id), 0);
|
||||||
onTrackPlay(buildDisplayTrack(shuffled[0], 0));
|
onTrackPlay(buildDisplayTrack(shuffled[0], 0));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -1132,7 +1132,7 @@
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const queueTracks = buildFavoritesQueueTracks(filteredTracks);
|
const queueTracks = buildFavoritesQueueTracks(filteredTracks);
|
||||||
await invoke('add_to_queue_next', { tracks: queueTracks });
|
await invoke('v2_add_tracks_to_queue_next', { tracks: queueTracks });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to add tracks next:', err);
|
console.error('Failed to add tracks next:', err);
|
||||||
}
|
}
|
||||||
@@ -1143,7 +1143,7 @@
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const queueTracks = buildFavoritesQueueTracks(filteredTracks);
|
const queueTracks = buildFavoritesQueueTracks(filteredTracks);
|
||||||
await invoke('add_to_queue', { tracks: queueTracks });
|
await invoke('v2_add_tracks_to_queue', { tracks: queueTracks });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to add tracks to queue:', err);
|
console.error('Failed to add tracks to queue:', err);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -620,7 +620,7 @@
|
|||||||
if (continueTracks.length > 0) {
|
if (continueTracks.length > 0) {
|
||||||
try {
|
try {
|
||||||
const queueTracks = buildContinueQueueTracks(continueTracks);
|
const queueTracks = buildContinueQueueTracks(continueTracks);
|
||||||
await invoke('set_queue', { tracks: queueTracks, startIndex: trackIndex });
|
await invoke('v2_set_queue', { tracks: queueTracks, startIndex: trackIndex });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to set queue:', err);
|
console.error('Failed to set queue:', err);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1943,8 +1943,8 @@
|
|||||||
try {
|
try {
|
||||||
console.log('[LocalLibrary Shuffle] Starting shuffle with', albumTracks.length, 'tracks');
|
console.log('[LocalLibrary Shuffle] Starting shuffle with', albumTracks.length, 'tracks');
|
||||||
|
|
||||||
// Enable shuffle mode first
|
// Enable shuffle mode first (V2)
|
||||||
await invoke('set_shuffle', { enabled: true });
|
await invoke('v2_set_shuffle', { enabled: true });
|
||||||
|
|
||||||
// Pick a random track to start with
|
// Pick a random track to start with
|
||||||
const randomIndex = Math.floor(Math.random() * albumTracks.length);
|
const randomIndex = Math.floor(Math.random() * albumTracks.length);
|
||||||
@@ -2124,7 +2124,7 @@
|
|||||||
console.log('[LocalLibrary Queue] Mapped to', queueTracks.length, 'queue tracks');
|
console.log('[LocalLibrary Queue] Mapped to', queueTracks.length, 'queue tracks');
|
||||||
console.log('[LocalLibrary Queue] Track IDs:', queueTracks.map(track => track.id));
|
console.log('[LocalLibrary Queue] Track IDs:', queueTracks.map(track => track.id));
|
||||||
|
|
||||||
await invoke('set_queue', { tracks: queueTracks, startIndex });
|
await invoke('v2_set_queue', { tracks: queueTracks, startIndex });
|
||||||
onSetLocalQueue?.(tracks.filter(track => track.source !== 'plex').map(track => track.id));
|
onSetLocalQueue?.(tracks.filter(track => track.source !== 'plex').map(track => track.id));
|
||||||
|
|
||||||
console.log('[LocalLibrary Queue] Queue set successfully');
|
console.log('[LocalLibrary Queue] Queue set successfully');
|
||||||
|
|||||||
@@ -1473,7 +1473,7 @@
|
|||||||
const allTracks = displayTracks;
|
const allTracks = displayTracks;
|
||||||
if (allTracks.length === 0) return;
|
if (allTracks.length === 0) return;
|
||||||
const { queueTracks, localIds } = buildQueueTracks(allTracks);
|
const { queueTracks, localIds } = buildQueueTracks(allTracks);
|
||||||
await invoke('set_queue', { tracks: queueTracks, startIndex });
|
await invoke('v2_set_queue', { tracks: queueTracks, startIndex });
|
||||||
if (localIds.length > 0) {
|
if (localIds.length > 0) {
|
||||||
onSetLocalQueue?.(localIds);
|
onSetLocalQueue?.(localIds);
|
||||||
}
|
}
|
||||||
@@ -1801,7 +1801,7 @@
|
|||||||
async function handleShuffle() {
|
async function handleShuffle() {
|
||||||
if (tracks.length > 0 && onTrackPlay) {
|
if (tracks.length > 0 && onTrackPlay) {
|
||||||
try {
|
try {
|
||||||
await invoke('set_shuffle', { enabled: true });
|
await invoke('v2_set_shuffle', { enabled: true });
|
||||||
await handlePlayAll();
|
await handlePlayAll();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to shuffle:', err);
|
console.error('Failed to shuffle:', err);
|
||||||
@@ -1827,34 +1827,31 @@
|
|||||||
.filter(trk => trk.isLocal)
|
.filter(trk => trk.isLocal)
|
||||||
.map(trk => Math.abs(trk.id));
|
.map(trk => Math.abs(trk.id));
|
||||||
|
|
||||||
// Add in reverse order so first track ends up right after current
|
// Build queue tracks for batch add (V2 handles reverse order)
|
||||||
for (let i = playableTracks.length - 1; i >= 0; i--) {
|
const queueTracks = playableTracks.map(trk => ({
|
||||||
const trk = playableTracks[i];
|
id: trk.isLocal ? Math.abs(trk.id) : trk.id,
|
||||||
try {
|
title: trk.title,
|
||||||
await invoke('add_to_queue_next', {
|
artist: trk.artist || 'Unknown Artist',
|
||||||
track: {
|
album: trk.album || playlist?.name || 'Playlist',
|
||||||
id: trk.isLocal ? Math.abs(trk.id) : trk.id,
|
duration_secs: trk.durationSeconds,
|
||||||
title: trk.title,
|
artwork_url: trk.albumArt || getPlaylistImage(),
|
||||||
artist: trk.artist || 'Unknown Artist',
|
hires: trk.hires ?? false,
|
||||||
album: trk.album || playlist?.name || 'Playlist',
|
bit_depth: trk.bitDepth ?? null,
|
||||||
duration_secs: trk.durationSeconds,
|
sample_rate: trk.samplingRate != null ? (trk.isLocal ? trk.samplingRate * 1000 : trk.samplingRate) : null,
|
||||||
artwork_url: trk.albumArt || getPlaylistImage(),
|
is_local: trk.isLocal ?? false,
|
||||||
hires: trk.hires ?? false,
|
album_id: trk.isLocal ? null : (trk.albumId || null),
|
||||||
bit_depth: trk.bitDepth ?? null,
|
artist_id: trk.isLocal ? null : (trk.artistId ?? null),
|
||||||
sample_rate: trk.samplingRate != null ? (trk.isLocal ? trk.samplingRate * 1000 : trk.samplingRate) : null,
|
}));
|
||||||
is_local: trk.isLocal ?? false,
|
|
||||||
album_id: trk.isLocal ? null : (trk.albumId || null),
|
|
||||||
artist_id: trk.isLocal ? null : (trk.artistId ?? null),
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Failed to add track next:', err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Tell parent about local tracks added to queue
|
try {
|
||||||
if (localIds.length > 0) {
|
await invoke('v2_add_tracks_to_queue_next', { tracks: queueTracks });
|
||||||
onSetLocalQueue?.(localIds);
|
|
||||||
|
// Tell parent about local tracks added to queue
|
||||||
|
if (localIds.length > 0) {
|
||||||
|
onSetLocalQueue?.(localIds);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Failed to add tracks next:', err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1892,7 +1889,7 @@
|
|||||||
.map(trk => Math.abs(trk.id));
|
.map(trk => Math.abs(trk.id));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await invoke('add_tracks_to_queue', { tracks: queueTracks });
|
await invoke('v2_add_tracks_to_queue', { tracks: queueTracks });
|
||||||
|
|
||||||
// Tell parent about local tracks added to queue
|
// Tell parent about local tracks added to queue
|
||||||
if (localIds.length > 0) {
|
if (localIds.length > 0) {
|
||||||
|
|||||||
@@ -715,7 +715,7 @@
|
|||||||
if (trackResults && trackResults.items.length > 0) {
|
if (trackResults && trackResults.items.length > 0) {
|
||||||
try {
|
try {
|
||||||
const queueTracks = buildSearchQueueTracks(trackResults.items);
|
const queueTracks = buildSearchQueueTracks(trackResults.items);
|
||||||
await invoke('set_queue', { tracks: queueTracks, startIndex: trackIndex });
|
await invoke('v2_set_queue', { tracks: queueTracks, startIndex: trackIndex });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to set queue:', err);
|
console.error('Failed to set queue:', err);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -180,11 +180,11 @@ export async function updateLocalCopiesSet(): Promise<void> {
|
|||||||
// ============ Queue Actions ============
|
// ============ Queue Actions ============
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sync queue state from backend
|
* Sync queue state from backend (V2)
|
||||||
*/
|
*/
|
||||||
export async function syncQueueState(): Promise<void> {
|
export async function syncQueueState(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const queueState = await invoke<BackendQueueState>('get_queue_state');
|
const queueState = await invoke<BackendQueueState>('v2_get_queue_state');
|
||||||
|
|
||||||
// Get track IDs for local copy check
|
// Get track IDs for local copy check
|
||||||
const trackIds = queueState.upcoming.map(t => t.id);
|
const trackIds = queueState.upcoming.map(t => t.id);
|
||||||
@@ -223,7 +223,7 @@ export async function syncQueueState(): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Toggle shuffle mode
|
* Toggle shuffle mode (V2)
|
||||||
*/
|
*/
|
||||||
export async function toggleShuffle(): Promise<{ success: boolean; enabled: boolean }> {
|
export async function toggleShuffle(): Promise<{ success: boolean; enabled: boolean }> {
|
||||||
const newState = !isShuffle;
|
const newState = !isShuffle;
|
||||||
@@ -231,7 +231,7 @@ export async function toggleShuffle(): Promise<{ success: boolean; enabled: bool
|
|||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await invoke('set_shuffle', { enabled: newState });
|
await invoke('v2_toggle_shuffle');
|
||||||
return { success: true, enabled: newState };
|
return { success: true, enabled: newState };
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to set shuffle:', err);
|
console.error('Failed to set shuffle:', err);
|
||||||
@@ -243,13 +243,15 @@ export async function toggleShuffle(): Promise<{ success: boolean; enabled: bool
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Toggle repeat mode (off -> all -> one -> off)
|
* Toggle repeat mode (off -> all -> one -> off) (V2)
|
||||||
*/
|
*/
|
||||||
export async function toggleRepeat(): Promise<{ success: boolean; mode: RepeatMode }> {
|
export async function toggleRepeat(): Promise<{ success: boolean; mode: RepeatMode }> {
|
||||||
const nextMode: RepeatMode = repeatMode === 'off' ? 'all' : repeatMode === 'all' ? 'one' : 'off';
|
const nextMode: RepeatMode = repeatMode === 'off' ? 'all' : repeatMode === 'all' ? 'one' : 'off';
|
||||||
|
// V2 expects capitalized repeat mode: 'Off' | 'All' | 'One'
|
||||||
|
const v2Mode = nextMode.charAt(0).toUpperCase() + nextMode.slice(1);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await invoke('set_repeat', { mode: nextMode });
|
await invoke('v2_set_repeat_mode', { mode: v2Mode });
|
||||||
repeatMode = nextMode;
|
repeatMode = nextMode;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
return { success: true, mode: nextMode };
|
return { success: true, mode: nextMode };
|
||||||
@@ -260,11 +262,11 @@ export async function toggleRepeat(): Promise<{ success: boolean; mode: RepeatMo
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add track to play next in queue
|
* Add track to play next in queue (V2)
|
||||||
*/
|
*/
|
||||||
export async function addToQueueNext(track: BackendQueueTrack, isLocal = false): Promise<boolean> {
|
export async function addToQueueNext(track: BackendQueueTrack, isLocal = false): Promise<boolean> {
|
||||||
try {
|
try {
|
||||||
await invoke('add_to_queue_next', { track });
|
await invoke('v2_add_to_queue_next', { track });
|
||||||
if (isLocal) {
|
if (isLocal) {
|
||||||
localTrackIds = new Set([...localTrackIds, track.id]);
|
localTrackIds = new Set([...localTrackIds, track.id]);
|
||||||
}
|
}
|
||||||
@@ -277,11 +279,11 @@ export async function addToQueueNext(track: BackendQueueTrack, isLocal = false):
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add track to end of queue
|
* Add track to end of queue (V2)
|
||||||
*/
|
*/
|
||||||
export async function addToQueue(track: BackendQueueTrack, isLocal = false): Promise<boolean> {
|
export async function addToQueue(track: BackendQueueTrack, isLocal = false): Promise<boolean> {
|
||||||
try {
|
try {
|
||||||
await invoke('add_to_queue', { track });
|
await invoke('v2_add_to_queue', { track });
|
||||||
if (isLocal) {
|
if (isLocal) {
|
||||||
localTrackIds = new Set([...localTrackIds, track.id]);
|
localTrackIds = new Set([...localTrackIds, track.id]);
|
||||||
}
|
}
|
||||||
@@ -294,11 +296,11 @@ export async function addToQueue(track: BackendQueueTrack, isLocal = false): Pro
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add multiple tracks to queue
|
* Add multiple tracks to queue (V2)
|
||||||
*/
|
*/
|
||||||
export async function addTracksToQueue(tracks: BackendQueueTrack[]): Promise<boolean> {
|
export async function addTracksToQueue(tracks: BackendQueueTrack[]): Promise<boolean> {
|
||||||
try {
|
try {
|
||||||
await invoke('add_tracks_to_queue', { tracks });
|
await invoke('v2_add_tracks_to_queue', { tracks });
|
||||||
await syncQueueState();
|
await syncQueueState();
|
||||||
return true;
|
return true;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -308,11 +310,11 @@ export async function addTracksToQueue(tracks: BackendQueueTrack[]): Promise<boo
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set queue with new tracks
|
* Set queue with new tracks (V2)
|
||||||
*/
|
*/
|
||||||
export async function setQueue(tracks: BackendQueueTrack[], startIndex: number, clearLocal = true): Promise<boolean> {
|
export async function setQueue(tracks: BackendQueueTrack[], startIndex: number, clearLocal = true): Promise<boolean> {
|
||||||
try {
|
try {
|
||||||
await invoke('set_queue', { tracks, startIndex });
|
await invoke('v2_set_queue', { tracks, startIndex });
|
||||||
if (clearLocal) {
|
if (clearLocal) {
|
||||||
localTrackIds = new Set();
|
localTrackIds = new Set();
|
||||||
}
|
}
|
||||||
@@ -325,11 +327,11 @@ export async function setQueue(tracks: BackendQueueTrack[], startIndex: number,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear the queue
|
* Clear the queue (V2)
|
||||||
*/
|
*/
|
||||||
export async function clearQueue(): Promise<boolean> {
|
export async function clearQueue(): Promise<boolean> {
|
||||||
try {
|
try {
|
||||||
await invoke('clear_queue');
|
await invoke('v2_clear_queue');
|
||||||
queue = [];
|
queue = [];
|
||||||
queueTotalTracks = 0;
|
queueTotalTracks = 0;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
@@ -341,11 +343,11 @@ export async function clearQueue(): Promise<boolean> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Play track at specific index in queue
|
* Play track at specific index in queue (V2)
|
||||||
*/
|
*/
|
||||||
export async function playQueueIndex(index: number): Promise<BackendQueueTrack | null> {
|
export async function playQueueIndex(index: number): Promise<BackendQueueTrack | null> {
|
||||||
try {
|
try {
|
||||||
return await invoke<BackendQueueTrack | null>('play_queue_index', { index });
|
return await invoke<BackendQueueTrack | null>('v2_play_queue_index', { index });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to play queue index:', err);
|
console.error('Failed to play queue index:', err);
|
||||||
return null;
|
return null;
|
||||||
@@ -353,11 +355,11 @@ export async function playQueueIndex(index: number): Promise<BackendQueueTrack |
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get next track from queue
|
* Get next track from queue (V2)
|
||||||
*/
|
*/
|
||||||
export async function nextTrack(): Promise<BackendQueueTrack | null> {
|
export async function nextTrack(): Promise<BackendQueueTrack | null> {
|
||||||
try {
|
try {
|
||||||
return await invoke<BackendQueueTrack | null>('next_track');
|
return await invoke<BackendQueueTrack | null>('v2_next_track');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to get next track:', err);
|
console.error('Failed to get next track:', err);
|
||||||
return null;
|
return null;
|
||||||
@@ -365,11 +367,11 @@ export async function nextTrack(): Promise<BackendQueueTrack | null> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get previous track from queue
|
* Get previous track from queue (V2)
|
||||||
*/
|
*/
|
||||||
export async function previousTrack(): Promise<BackendQueueTrack | null> {
|
export async function previousTrack(): Promise<BackendQueueTrack | null> {
|
||||||
try {
|
try {
|
||||||
return await invoke<BackendQueueTrack | null>('previous_track');
|
return await invoke<BackendQueueTrack | null>('v2_previous_track');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to get previous track:', err);
|
console.error('Failed to get previous track:', err);
|
||||||
return null;
|
return null;
|
||||||
@@ -377,11 +379,11 @@ export async function previousTrack(): Promise<BackendQueueTrack | null> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Move a track from one position to another in the queue
|
* Move a track from one position to another in the queue (V2)
|
||||||
*/
|
*/
|
||||||
export async function moveQueueTrack(fromIndex: number, toIndex: number): Promise<boolean> {
|
export async function moveQueueTrack(fromIndex: number, toIndex: number): Promise<boolean> {
|
||||||
try {
|
try {
|
||||||
const success = await invoke<boolean>('move_queue_track', { fromIndex, toIndex });
|
const success = await invoke<boolean>('v2_move_queue_track', { fromIndex, toIndex });
|
||||||
if (success) {
|
if (success) {
|
||||||
await syncQueueState();
|
await syncQueueState();
|
||||||
}
|
}
|
||||||
@@ -410,11 +412,11 @@ export function clearLocalTrackIds(): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the backend queue state (for advanced queue operations)
|
* Get the backend queue state (for advanced queue operations) (V2)
|
||||||
*/
|
*/
|
||||||
export async function getBackendQueueState(): Promise<BackendQueueState | null> {
|
export async function getBackendQueueState(): Promise<BackendQueueState | null> {
|
||||||
try {
|
try {
|
||||||
return await invoke<BackendQueueState>('get_queue_state');
|
return await invoke<BackendQueueState>('v2_get_queue_state');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to get backend queue state:', err);
|
console.error('Failed to get backend queue state:', err);
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -1630,10 +1630,10 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove a track from the upcoming queue by its position in the upcoming list
|
// Remove a track from the upcoming queue by its position in the upcoming list (V2)
|
||||||
async function handleRemoveFromQueue(upcomingIndex: number) {
|
async function handleRemoveFromQueue(upcomingIndex: number) {
|
||||||
try {
|
try {
|
||||||
await invoke('remove_upcoming_track', { upcomingIndex });
|
await invoke('v2_remove_upcoming_track', { upcomingIndex });
|
||||||
await syncQueueState(); // Refresh UI
|
await syncQueueState(); // Refresh UI
|
||||||
showToast($t('toast.removedFromQueue'), 'info');
|
showToast($t('toast.removedFromQueue'), 'info');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -1763,7 +1763,7 @@
|
|||||||
|
|
||||||
// Set shuffle mode first
|
// Set shuffle mode first
|
||||||
try {
|
try {
|
||||||
await invoke('set_shuffle', { enabled: true });
|
await invoke('v2_set_shuffle', { enabled: true });
|
||||||
isShuffle = true;
|
isShuffle = true;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to enable shuffle:', err);
|
console.error('Failed to enable shuffle:', err);
|
||||||
@@ -2381,10 +2381,12 @@
|
|||||||
|
|
||||||
// Restore shuffle/repeat mode
|
// Restore shuffle/repeat mode
|
||||||
if (session.shuffle_enabled) {
|
if (session.shuffle_enabled) {
|
||||||
await invoke('set_shuffle', { enabled: true });
|
await invoke('v2_set_shuffle', { enabled: true });
|
||||||
}
|
}
|
||||||
if (session.repeat_mode !== 'off') {
|
if (session.repeat_mode !== 'off') {
|
||||||
await invoke('set_repeat', { mode: session.repeat_mode });
|
// V2 expects capitalized mode: 'Off' | 'All' | 'One'
|
||||||
|
const v2Mode = session.repeat_mode.charAt(0).toUpperCase() + session.repeat_mode.slice(1);
|
||||||
|
await invoke('v2_set_repeat_mode', { mode: v2Mode });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore volume
|
// Restore volume
|
||||||
|
|||||||
Reference in new issue
Block a user