Libraries: refresh the list after any sync that changes it
Only syncs started from the UI updated the list. One started in the backend, such as the sync after creating a library, left it stale: the new library kept saying it wasn't on the server yet, and Main stayed undeletable until the app reloaded. A sync that changes the libraries now emits an event the app refreshes on.
This commit is contained in:
@@ -47,7 +47,7 @@ use mtgc_core::sync::remote::{
|
||||
};
|
||||
use mtgc_core::sync::{self as core_sync, LibraryDoc, MergeReport};
|
||||
use serde::Serialize;
|
||||
use tauri::{AppHandle, Manager};
|
||||
use tauri::{AppHandle, Emitter, Manager};
|
||||
|
||||
use crate::state::{AppState, LocalLibrary, SyncAccount};
|
||||
|
||||
@@ -585,6 +585,11 @@ async fn run_sync(app: AppHandle, choice: Option<FirstSync>) -> Result<Option<Sy
|
||||
Err(e) => s.sync_error = Some(e.clone()),
|
||||
}
|
||||
drop(s);
|
||||
// An event rather than the report alone: many syncs start here in the
|
||||
// backend, with nothing in the UI waiting on their result.
|
||||
if result.as_ref().is_ok_and(|r| r.libraries_changed) {
|
||||
let _ = app.emit("libraries-changed", ());
|
||||
}
|
||||
crate::logged("sync_now", result).map(Some)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user