From 12f6ae05673be1a15f07a0d131645afc6cf12d35 Mon Sep 17 00:00:00 2001 From: kramo <93832451+kra-mo@users.noreply.github.com> Date: Sun, 16 Apr 2023 01:18:46 +0200 Subject: [PATCH] Fix play button flickering when launching game --- src/main.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main.py b/src/main.py index 1ca88b5..7639ee7 100644 --- a/src/main.py +++ b/src/main.py @@ -152,21 +152,27 @@ class CartridgesApplication(Adw.Application): # Launch the game and update the last played value game_id = self.win.active_game_id + last_played = int(time.time()) data = get_games(self.win, [game_id])[game_id] - data["last_played"] = int(time.time()) + data["last_played"] = last_played save_game(self.win, data) self.win.games[game_id].launch() + # Update state + self.win.games[game_id].last_played = last_played + self.win.library.invalidate_sort() + self.win.hidden_library.invalidate_sort() + if self.win.stack.get_visible_child() == self.win.details_view: + self.win.show_details_view(None, game_id) + title = self.win.games[game_id].name # The variable is the title of the game toast = Adw.Toast.new(_("{} launched").format(title)) toast.set_priority(Adw.ToastPriority.HIGH) self.win.toast_overlay.add_toast(toast) - self.win.update_games([game_id]) - def on_hide_game_action(self, _widget, _callback=None, game_id=None, toast=True): if not game_id: game_id = self.win.active_game_id