feat(library): Reactive library updating

Signed-off-by: quexeky <git@quexeky.dev>
This commit is contained in:
quexeky
2025-02-12 09:29:03 +11:00
parent 316a3742eb
commit d9c4f7aa75
6 changed files with 57 additions and 45 deletions

View File

@ -38,7 +38,6 @@ pub fn uninstall_game(game_id: String, app_handle: AppHandle) -> Result<(), Libr
Some(data) => data,
None => return Err(LibraryError::MetaNotFound(game_id)),
};
println!("{:?}", meta);
uninstall_game_logic(meta, &app_handle);
Ok(())

View File

@ -103,7 +103,6 @@ pub fn fetch_library_logic(
drop(db_handle);
cache_object("library", &games)?;
Ok(games)
}
pub fn fetch_library_logic_offline(
@ -137,8 +136,7 @@ pub fn fetch_game_logic(
status,
};
cache_object(id, &data)?;
cache_object(id, &data)?;
return Ok(data);
}
@ -261,8 +259,6 @@ pub fn uninstall_game_logic(meta: DownloadableMetadata, app_handle: &AppHandle)
.entry(meta.clone())
.and_modify(|v| *v = ApplicationTransientStatus::Uninstalling {});
db_handle.applications.installed_game_version.remove(&meta.id);
drop(db_handle);
let app_handle = app_handle.clone();
@ -273,6 +269,10 @@ pub fn uninstall_game_logic(meta: DownloadableMetadata, app_handle: &AppHandle)
Ok(_) => {
let mut db_handle = borrow_db_mut_checked();
db_handle.applications.transient_statuses.remove(&meta);
db_handle
.applications
.installed_game_version
.remove(&meta.id);
db_handle
.applications
.game_statuses
@ -282,6 +282,7 @@ pub fn uninstall_game_logic(meta: DownloadableMetadata, app_handle: &AppHandle)
save_db();
debug!("uninstalled game id {}", &meta.id);
app_handle.emit("update_library", {}).unwrap();
push_game_update(
&app_handle,