fix(playlist): correct with_db result check in favorite toggle
with_db flattens the inner Result to Option<()> (so callers can .unwrap_or_default()), so the favorite-revert guard must test ok.is_none() rather than matches!(ok, Some(Ok(()))). Caught by cargo check -p qbz; the whole bin now compiles clean. cc
This commit is contained in:
1 file changed
+4
-1
@@ -9072,10 +9072,13 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
w.global::<PlaylistState>().set_is_favorite(new_fav);
|
||||
let weak2 = weak.clone();
|
||||
handle.spawn_blocking(move || {
|
||||
// with_db flattens the inner Result to Option<()>
|
||||
// (None = no db OR the write failed) -> revert the
|
||||
// optimistic heart on failure.
|
||||
let ok = crate::library_db::with_db(|db| {
|
||||
db.set_playlist_favorite(pid_u64, new_fav)
|
||||
});
|
||||
if !matches!(ok, Some(Ok(()))) {
|
||||
if ok.is_none() {
|
||||
log::error!("[qbz-slint] toggle playlist favorite failed");
|
||||
let _ = weak2.upgrade_in_event_loop(move |w| {
|
||||
w.global::<PlaylistState>().set_is_favorite(was_fav);
|
||||
|
||||
Reference in new issue
Block a user