feat: refresh views on all playlist mutations
- Add EV_PLAYLIST_TRACK_ADDED (22) — emitted when a track is successfully added to a playlist - If the currently-open playlist is the one modified, re-fetch it so the track appears in the list immediately - After creating a playlist, open it automatically so the user lands in the new (empty) playlist view right away - Sidebar already refreshes on create/delete; this ensures the track list view also stays in sync Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -31,8 +31,9 @@ enum QobuzEvent {
|
||||
EV_TRACK_URL_OK = 17,
|
||||
EV_TRACK_URL_ERR = 18,
|
||||
EV_GENERIC_ERR = 19,
|
||||
EV_PLAYLIST_CREATED = 20,
|
||||
EV_PLAYLIST_DELETED = 21,
|
||||
EV_PLAYLIST_CREATED = 20,
|
||||
EV_PLAYLIST_DELETED = 21,
|
||||
EV_PLAYLIST_TRACK_ADDED = 22,
|
||||
};
|
||||
|
||||
// Callback signature
|
||||
|
||||
@@ -562,6 +562,7 @@ pub unsafe extern "C" fn qobuz_backend_remove_fav_album(ptr: *mut Backend, album
|
||||
|
||||
pub const EV_PLAYLIST_CREATED: c_int = 20;
|
||||
pub const EV_PLAYLIST_DELETED: c_int = 21;
|
||||
pub const EV_PLAYLIST_TRACK_ADDED: c_int = 22;
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn qobuz_backend_create_playlist(ptr: *mut Backend, name: *const c_char) {
|
||||
@@ -601,8 +602,10 @@ pub unsafe extern "C" fn qobuz_backend_add_track_to_playlist(
|
||||
let client = inner.client.clone();
|
||||
let cb = inner.cb; let ud = inner.ud;
|
||||
spawn(inner, async move {
|
||||
if let Err(e) = client.lock().await.add_track_to_playlist(playlist_id, track_id).await {
|
||||
call_cb(cb, ud, EV_GENERIC_ERR, &err_json(&e.to_string()));
|
||||
match client.lock().await.add_track_to_playlist(playlist_id, track_id).await {
|
||||
Ok(()) => call_cb(cb, ud, EV_PLAYLIST_TRACK_ADDED,
|
||||
&serde_json::json!({"playlist_id": playlist_id}).to_string()),
|
||||
Err(e) => call_cb(cb, ud, EV_GENERIC_ERR, &err_json(&e.to_string())),
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user