Connected Devices: fixed rplaylist sync
This commit is contained in:
+7
-2
@@ -481,15 +481,20 @@ fn perform_effect(state: &mut AppState, runtime: &mut Runtime, effect: Effect) {
|
||||
Effect::RemoveFromPlaylist {
|
||||
playlist_id,
|
||||
track_ids,
|
||||
content_ids,
|
||||
} => {
|
||||
let library = Arc::clone(&runtime.library);
|
||||
let devices = Arc::clone(&runtime.devices);
|
||||
let tx = runtime.event_tx.clone();
|
||||
tokio::task::spawn_blocking(move || {
|
||||
let event = match library.remove_tracks_from_playlist(playlist_id, &track_ids) {
|
||||
let event = match library
|
||||
.remove_tracks_from_playlist(playlist_id, &track_ids)
|
||||
.and_then(|()| {
|
||||
library.remove_content_ids_from_playlist(playlist_id, &content_ids)
|
||||
}) {
|
||||
Ok(()) => {
|
||||
if let Err(err) =
|
||||
devices.record_playlist_tracks_removed(playlist_id, &track_ids)
|
||||
devices.record_playlist_content_removed(playlist_id, &content_ids)
|
||||
{
|
||||
tracing::warn!(%err, playlist_id, "recording synced playlist removal failed");
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ pub enum Effect {
|
||||
RemoveFromPlaylist {
|
||||
playlist_id: i64,
|
||||
track_ids: Vec<i64>,
|
||||
content_ids: Vec<String>,
|
||||
},
|
||||
RemoveQueueIndices {
|
||||
indices: Vec<usize>,
|
||||
@@ -607,6 +608,15 @@ fn delete_selected(state: &mut AppState) -> Option<Effect> {
|
||||
return None;
|
||||
}
|
||||
let track_ids: Vec<i64> = tracks.iter().map(|track| track.id).collect();
|
||||
let content_ids: Vec<String> = tracks
|
||||
.iter()
|
||||
.filter_map(|track| {
|
||||
track
|
||||
.content_id
|
||||
.as_deref()
|
||||
.and_then(music_dht::normalize_content_id)
|
||||
})
|
||||
.collect();
|
||||
state.track_selection.clear();
|
||||
if opened.id == super::state::LIKES_PLAYLIST_ID {
|
||||
let liked: Vec<i64> = track_ids
|
||||
@@ -626,6 +636,7 @@ fn delete_selected(state: &mut AppState) -> Option<Effect> {
|
||||
return Some(Effect::RemoveFromPlaylist {
|
||||
playlist_id: opened.id,
|
||||
track_ids,
|
||||
content_ids,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user