android: a playlist's cover from a photo on the phone

The storage plugin gains pick_image — the document picker limited to
images, the picked content copied into the app's cache so the Rust side
gets a plain path. playlist_cover_set(id, path) is the desktop pick's
install step split out and shared (squared, the master cover, the row's
revision moved). A playlist's sheet offers Choose cover photo and Remove
custom cover; the mock walk exercises both.
This commit is contained in:
KeelrLeek committed 2026-09-13 21:20:11 -05:00
1 parent d95c3f48d1
commit b50577fc81
15 files changed
+188 -12

No files matched your search

+1
View File
@@ -259,6 +259,7 @@ pub fn run() {
playlists::playlist_relink_item,
playlists::playlist_cover,
playlists::playlist_cover_pick,
playlists::playlist_cover_set,
playlists::playlist_cover_clear,
playlists::playlist_import_probe,
playlists::playlist_import_folder,
+26 -3
View File
@@ -399,7 +399,18 @@ pub async fn playlist_cover_pick(
let Some(source) = rx.await.unwrap_or(None) else {
return Ok(None);
};
let dir = covers_dir(&app)?;
install_cover(&app, &lib, id, source).await.map(Some)
}
/// A picked image — the desktop's dialog, or a photo the phone copied into
/// its cache — squared, written as the playlist's master cover, recorded.
async fn install_cover(
app: &tauri::AppHandle,
lib: &LibraryState,
id: i64,
source: String,
) -> Result<String, String> {
let dir = covers_dir(app)?;
let target = dir.join(format!("{id}.jpg"));
let jpeg = tauri::async_runtime::spawn_blocking(move || -> Result<Vec<u8>, String> {
let bytes = std::fs::read(&source).map_err(|e| e.to_string())?;
@@ -422,8 +433,20 @@ pub async fn playlist_cover_pick(
.await
.map_err(|e| e.to_string())?
.map_err(|e| e.to_string())?;
changed(&app);
Ok(Some(data_url_jpeg(&jpeg)))
changed(app);
Ok(data_url_jpeg(&jpeg))
}
/// The phone's door: a photo already on disk (the storage plugin copied it
/// into the app's cache) becomes the playlist's cover.
#[tauri::command]
pub async fn playlist_cover_set(
app: tauri::AppHandle,
lib: State<'_, LibraryState>,
id: i64,
path: String,
) -> Result<String, String> {
install_cover(&app, &lib, id, path).await
}
#[tauri::command]