refactor(v2): inline playlist custom order and local copies delegates

Inlines bodies of playlist_get_custom_order, playlist_has_custom_order,
and playlist_get_tracks_with_local_copies from library/commands.rs
directly into the v2 wrappers in commands_v2/playlists.rs, mapping
LibraryError to RuntimeError::Internal as needed.

Deletes the corresponding legacy #[tauri::command] definitions and
removes their re-exports from library/mod.rs.

Step 8 of legacy cleanup, group F.

cc
This commit is contained in:
vicrodh committed 2026-04-26 20:21:22 -06:00
1 parent 7858c16b64
commit 7d18e6d3a8
3 files changed
+27 -64

No files matched your search

+27 -9
View File
@@ -327,9 +327,14 @@ pub async fn v2_playlist_get_custom_order(
.manager()
.check_requirements(CommandRequirement::RequiresUserSession)
.await?;
crate::library::playlist_get_custom_order(playlistId, library_state)
.await
.map_err(RuntimeError::Internal)
log::info!("Command: playlist_get_custom_order {}", playlistId);
let guard__ = library_state.db.lock().await;
let db = guard__
.as_ref()
.ok_or_else(|| RuntimeError::Internal("No active session - please log in".to_string()))?;
db.get_playlist_custom_order(playlistId)
.map_err(|e| RuntimeError::Internal(e.to_string()))
}
#[tauri::command]
@@ -343,9 +348,14 @@ pub async fn v2_playlist_has_custom_order(
.manager()
.check_requirements(CommandRequirement::RequiresUserSession)
.await?;
crate::library::playlist_has_custom_order(playlistId, library_state)
.await
.map_err(RuntimeError::Internal)
log::info!("Command: playlist_has_custom_order {}", playlistId);
let guard__ = library_state.db.lock().await;
let db = guard__
.as_ref()
.ok_or_else(|| RuntimeError::Internal("No active session - please log in".to_string()))?;
db.has_playlist_custom_order(playlistId)
.map_err(|e| RuntimeError::Internal(e.to_string()))
}
#[tauri::command]
@@ -359,9 +369,17 @@ pub async fn v2_playlist_get_tracks_with_local_copies(
.manager()
.check_requirements(CommandRequirement::RequiresUserSession)
.await?;
crate::library::playlist_get_tracks_with_local_copies(trackIds, library_state)
.await
.map_err(RuntimeError::Internal)
let guard__ = library_state.db.lock().await;
let db = guard__
.as_ref()
.ok_or_else(|| RuntimeError::Internal("No active session - please log in".to_string()))?;
let local_ids = db
.get_tracks_with_local_copies(&trackIds)
.map_err(|e| RuntimeError::Internal(e.to_string()))?;
Ok(local_ids.into_iter().collect())
}
/// Search playlists (V2 - uses QbzCore)
-52
View File
@@ -747,23 +747,6 @@ pub async fn playlist_increment_play_count(
// === Playlist Custom Track Order ===
/// Get custom track order for a playlist
/// Returns Vec of (track_id, is_local, position)
#[tauri::command]
pub async fn playlist_get_custom_order(
playlist_id: u64,
state: State<'_, LibraryState>,
) -> Result<Vec<(i64, bool, i32)>, String> {
log::info!("Command: playlist_get_custom_order {}", playlist_id);
let guard__ = state.db.lock().await;
let db = guard__
.as_ref()
.ok_or("No active session - please log in")?;
db.get_playlist_custom_order(playlist_id)
.map_err(|e| e.to_string())
}
/// Initialize custom order for a playlist from current track arrangement
#[tauri::command]
pub async fn playlist_init_custom_order(
@@ -830,22 +813,6 @@ pub async fn playlist_move_track(
.map_err(|e| e.to_string())
}
/// Check if a playlist has custom order defined
#[tauri::command]
pub async fn playlist_has_custom_order(
playlist_id: u64,
state: State<'_, LibraryState>,
) -> Result<bool, String> {
log::info!("Command: playlist_has_custom_order {}", playlist_id);
let guard__ = state.db.lock().await;
let db = guard__
.as_ref()
.ok_or("No active session - please log in")?;
db.has_playlist_custom_order(playlist_id)
.map_err(|e| e.to_string())
}
/// Clear custom order for a playlist
#[tauri::command]
pub async fn playlist_clear_custom_order(
@@ -1289,25 +1256,6 @@ pub async fn playlist_get_local_track_id(
.map_err(|e| e.to_string())
}
/// Batch check which tracks have local copies (for offline mode)
/// Returns a list of track IDs that have local versions
#[tauri::command]
pub async fn playlist_get_tracks_with_local_copies(
track_ids: Vec<u64>,
state: State<'_, LibraryState>,
) -> Result<Vec<u64>, String> {
let guard__ = state.db.lock().await;
let db = guard__
.as_ref()
.ok_or("No active session - please log in")?;
let local_ids = db
.get_tracks_with_local_copies(&track_ids)
.map_err(|e| e.to_string())?;
Ok(local_ids.into_iter().collect())
}
/// Get playlists that have local content (for offline mode filtering)
#[tauri::command]
pub async fn playlist_get_offline_available(
-3
View File
@@ -85,9 +85,6 @@ pub use state::{
BackfillReport, CleanupResult, LibraryAlbumMetadataUpdateRequest,
LibraryAlbumTrackMetadataUpdate, LibraryState,
};
pub use commands::{
playlist_get_custom_order, playlist_get_tracks_with_local_copies, playlist_has_custom_order,
};
use std::path::Path;
use std::sync::atomic::AtomicBool;