Files
qbz/crates/qbz-playlist-import/src/sink.rs
T
vicrodh 3689a5fda8 feat(slint): add-to-playlist duplicate modal + playlist importer port
Add-to-playlist (Slices 0-3):
- qbz-core: check_playlist_duplicates + pure compute_playlist_duplicates
  (reuses qbz_models::PlaylistDuplicateResult) + unit tests.
- PlaylistDuplicateConfirmModal (Add all / Add new only / Cancel); the
  duplicate check runs on the Qobuz->Qobuz picker branch only (local/Plex
  add directly, mirroring Tauri); the track-id Vec lives Rust-side in a
  stash, never in Slint.
- Inline create-and-add in the picker (online create_playlist, offline ->
  local playlist per D8) + client-side filter (Slint 1.16 has no string
  contains, routed through a Rust callback) + success toasts.

Playlist importer (1:1 Tauri port):
- New headless crate qbz-playlist-import (Spotify/Apple/Tidal/Deezer
  scrapers, Qobuz matcher, importer, progress sink, shared http client;
  copy-not-move from src-tauri, zero tauri deps; 40 unit tests green).
- PlaylistImportModal (two-step fetch-preview -> import with live progress
  bar / log / summary) + controller + sidebar PLAYLISTS menu entry point.

Reco logging staged behind TODO(reco-v1) markers (golden rule: playlist
recommendations ship in Slint v1 once the reco engine is extracted to a
shared crate).

cc
2026-06-11 22:03:46 -06:00

48 lines
1.6 KiB
Rust

//! Frontend-agnostic progress reporting.
//!
//! Replaces the Tauri `AppHandle::emit("import:phase" | "import:progress")`
//! sites. Emission is fire-and-forget and infallible — the Tauri emits were
//! all `let _ =`.
use serde::Serialize;
use crate::models::ImportProgress;
/// Import phase, mirroring the Tauri `import:phase` payloads
/// (`{"phase": "matching" | "creating" | "adding"}`).
///
/// `Creating` and `Adding` re-fire once per created playlist part.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
#[serde(rename_all = "lowercase")]
pub enum ImportPhase {
Matching,
Creating,
/// NOTE (owner decision, deliberate deviation from the Tauri UI):
/// frontends should render the status line during this phase as
/// "Adding tracks: {current} / {total}" — the Tauri modal reused the
/// "Matching tracks…" string here; do not carry that quirk.
Adding,
}
/// One event from the import pipeline, mirroring the two Tauri events.
#[derive(Debug, Clone, Serialize)]
pub enum ImportEvent {
Phase(ImportPhase),
/// Existing wire model, unchanged shape. While matching: one per track
/// (high frequency), `current_track` = "Artist - Title". While adding:
/// one per 50-track chunk (chunk counts, not tracks), `current_track` =
/// "Part i/n" iff multi-part.
Progress(ImportProgress),
}
/// Receives progress events from [`crate::import_public_playlist`].
pub trait ImportProgressSink: Send + Sync {
fn emit(&self, event: ImportEvent);
}
impl<F: Fn(ImportEvent) + Send + Sync> ImportProgressSink for F {
fn emit(&self, event: ImportEvent) {
self(event)
}
}