diff --git a/src/importer/importer.py b/src/importer/importer.py index 52ce79f..5d9808c 100644 --- a/src/importer/importer.py +++ b/src/importer/importer.py @@ -41,7 +41,7 @@ class Importer(ErrorProducer): progressbar: Gtk.ProgressBar import_statuspage: Adw.StatusPage import_dialog: Adw.MessageDialog - summary_toast: Adw.Toast + summary_toast: Optional[Adw.Toast] = None sources: set[Source] @@ -103,6 +103,9 @@ class Importer(ErrorProducer): def run(self) -> None: """Use several Gio.Task to import games from added sources""" + if Importer.summary_toast: + Importer.summary_toast.dismiss() + shared.win.get_application().lookup_action("import").set_enabled(False) self.create_dialog() @@ -263,7 +266,7 @@ class Importer(ErrorProducer): shared.store.new_game_ids = set() shared.store.duplicate_game_ids = set() self.import_dialog.close() - self.summary_toast = self.create_summary_toast() + Importer.summary_toast = self.create_summary_toast() self.create_error_dialog() shared.win.get_application().lookup_action("import").set_enabled(True) @@ -332,7 +335,8 @@ class Importer(ErrorProducer): self.imported_game_ids = set() self.removed_game_ids = set() - self.summary_toast.dismiss() + if Importer.summary_toast: + Importer.summary_toast.dismiss() logging.info("Import undone") @@ -388,7 +392,8 @@ class Importer(ErrorProducer): def timeout_toast(self, *_args: Any) -> None: """Manually timeout the toast after the user has dismissed all warnings""" - GLib.timeout_add_seconds(5, self.summary_toast.dismiss) + if Importer.summary_toast: + GLib.timeout_add_seconds(5, Importer.summary_toast.dismiss) def dialog_response_callback(self, _widget: Any, response: str, *args: Any) -> None: """Handle after-import dialogs callback"""