Make undoing the hide action more consistent

This commit is contained in:
kramo
2023-04-03 10:56:56 +02:00
parent e373534e41
commit b1cb2d679a
2 changed files with 5 additions and 4 deletions

View File

@@ -157,8 +157,9 @@ class CartridgesApplication(Adw.Application):
if self.win.stack.get_visible_child() == self.win.overview:
self.win.show_overview(None, self.win.active_game_id)
def on_hide_game_action(self, _widget, _callback=None):
game_id = self.win.active_game_id
def on_hide_game_action(self, _widget, _callback=None, game_id=None):
if not game_id:
game_id = self.win.active_game_id
if self.win.stack.get_visible_child() == self.win.overview:
self.win.on_go_back_action(None, None)

View File

@@ -426,14 +426,14 @@ class CartridgesWindow(Adw.ApplicationWindow):
return
if undo == "hide":
self.games[game_id].toggle_hidden()
self.get_application().on_hide_game_action(None, game_id=game_id)
elif undo == "remove":
data = get_games(self, [game_id])[game_id]
data.pop("removed", None)
save_game(self, data)
self.update_games([game_id])
self.update_games([game_id])
self.toasts[(game_id, undo)].dismiss()
self.toasts.pop((game_id, undo))