feat(qbz-nix): Phase 6.2 - CoreBridge and V2 commands
Add bridge layer connecting QbzCore to Tauri and example V2 commands. New files: - core_bridge.rs: CoreBridge wraps QbzCore for Tauri integration - commands_v2.rs: Example commands using new architecture V2 commands implemented: - v2_is_logged_in, v2_login, v2_logout (auth) - v2_get_queue_state, v2_set_repeat_mode, v2_toggle_shuffle, v2_clear_queue These coexist with old commands during migration. Frontend can gradually switch to V2 commands as they're tested.
This commit is contained in:
1 parent
d0e46aca05
commit
f59f0e1b87
3 files changed
+192
-1
No files matched your search
@@ -0,0 +1,82 @@
|
||||
//! V2 Commands - Using the new multi-crate architecture
|
||||
//!
|
||||
//! These commands use QbzCore via CoreBridge instead of the old AppState.
|
||||
//! They coexist with the old commands during migration.
|
||||
|
||||
use tauri::State;
|
||||
|
||||
use qbz_models::{QueueState, RepeatMode, UserSession};
|
||||
|
||||
use crate::core_bridge::CoreBridgeState;
|
||||
|
||||
// ==================== Auth Commands (V2) ====================
|
||||
|
||||
/// Check if user is logged in (V2 - uses QbzCore)
|
||||
#[tauri::command]
|
||||
pub async fn v2_is_logged_in(
|
||||
bridge: State<'_, CoreBridgeState>,
|
||||
) -> Result<bool, String> {
|
||||
let bridge = bridge.get().await;
|
||||
Ok(bridge.is_logged_in().await)
|
||||
}
|
||||
|
||||
/// Login with email and password (V2 - uses QbzCore)
|
||||
#[tauri::command]
|
||||
pub async fn v2_login(
|
||||
email: String,
|
||||
password: String,
|
||||
bridge: State<'_, CoreBridgeState>,
|
||||
) -> Result<UserSession, String> {
|
||||
let bridge = bridge.get().await;
|
||||
bridge.login(&email, &password).await
|
||||
}
|
||||
|
||||
/// Logout current user (V2 - uses QbzCore)
|
||||
#[tauri::command]
|
||||
pub async fn v2_logout(
|
||||
bridge: State<'_, CoreBridgeState>,
|
||||
) -> Result<(), String> {
|
||||
let bridge = bridge.get().await;
|
||||
bridge.logout().await
|
||||
}
|
||||
|
||||
// ==================== Queue Commands (V2) ====================
|
||||
|
||||
/// Get current queue state (V2 - uses QbzCore)
|
||||
#[tauri::command]
|
||||
pub async fn v2_get_queue_state(
|
||||
bridge: State<'_, CoreBridgeState>,
|
||||
) -> Result<QueueState, String> {
|
||||
let bridge = bridge.get().await;
|
||||
Ok(bridge.get_queue_state().await)
|
||||
}
|
||||
|
||||
/// Set repeat mode (V2 - uses QbzCore)
|
||||
#[tauri::command]
|
||||
pub async fn v2_set_repeat_mode(
|
||||
mode: RepeatMode,
|
||||
bridge: State<'_, CoreBridgeState>,
|
||||
) -> Result<(), String> {
|
||||
let bridge = bridge.get().await;
|
||||
bridge.set_repeat_mode(mode).await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Toggle shuffle (V2 - uses QbzCore)
|
||||
#[tauri::command]
|
||||
pub async fn v2_toggle_shuffle(
|
||||
bridge: State<'_, CoreBridgeState>,
|
||||
) -> Result<bool, String> {
|
||||
let bridge = bridge.get().await;
|
||||
Ok(bridge.toggle_shuffle().await)
|
||||
}
|
||||
|
||||
/// Clear the queue (V2 - uses QbzCore)
|
||||
#[tauri::command]
|
||||
pub async fn v2_clear_queue(
|
||||
bridge: State<'_, CoreBridgeState>,
|
||||
) -> Result<(), String> {
|
||||
let bridge = bridge.get().await;
|
||||
bridge.clear_queue().await;
|
||||
Ok(())
|
||||
}
|
||||
Reference in new issue
Block a user