Dismiss loose toasts when cleaning up games

This commit is contained in:
kramo
2023-08-15 21:32:24 +02:00
parent 5551756111
commit b466eb7ab2
2 changed files with 11 additions and 1 deletions

View File

@@ -324,9 +324,12 @@ class Importer(ErrorProducer):
shared.store[game_id].update()
shared.store[game_id].save()
self.imported_game_ids = set()
self.removed_game_ids = set()
self.summary_toast.dismiss()
logging.info("Import undone")
def create_summary_toast(self):
"""N games imported, removed toast"""

View File

@@ -91,7 +91,7 @@ class Store:
self.pipeline_managers.discard(self.managers[manager_type])
def cleanup_game(self, game: Game) -> None:
"""Remove a game's files"""
"""Remove a game's files, dismiss any loose toasts"""
for path in (
shared.games_dir / f"{game.game_id}.json",
shared.covers_dir / f"{game.game_id}.tiff",
@@ -99,6 +99,13 @@ class Store:
):
path.unlink(missing_ok=True)
# TODO: don't run this if the state is startup
for undo in ("remove", "hide"):
try:
shared.win.toasts[(game, undo)].dismiss()
except KeyError:
pass
def add_game(
self, game: Game, additional_data: dict, run_pipeline=True
) -> Pipeline | None: