feat: simplify API udpate signals

This commit is contained in:
aclist 2026-08-16 12:45:26 +09:00
parent dfd6850d6d
commit 69cba3460d
3 changed files with 12 additions and 7 deletions

View File

@ -145,6 +145,10 @@ class Emitter(GObject.GObject):
def api_change_failed(self) -> None:
pass
@GObject.Signal(flags=GObject.SignalFlags.RUN_LAST, arg_types=())
def api_change_successful(self) -> None:
pass
@GObject.Signal(flags=GObject.SignalFlags.RUN_LAST, arg_types=())
def already_saved_server(self) -> None:
pass

View File

@ -301,8 +301,8 @@ class Controller(GObject.GObject):
dialog = ExceptionDialog(self, str(e))
dialog.run()
def update_api_key(self, key: Preferences, text: str) -> None:
self.config_man.update_api_key(key, text)
def update_steam_api_key(self, text: str) -> None:
self.config_man.update_steam_api_key(text)
def set_resolution(self, window: "OuterWindow") -> None:
self.config_man.set_resolution(window)

View File

@ -98,12 +98,13 @@ class ConfigManager:
logger.critical(e)
raise e
@call_on_thread(dialogs.checking_api)
def update_api_key(self, key: Preferences, text: str) -> None:
if key is Preferences.STEAM:
res = test_steam_api(text)
@call_on_thread(dialogs.checking_api, show_dialog=False)
def update_steam_api_key(self, text: str) -> None:
res = test_steam_api(text)
if res is True:
self.update_config(key, text)
self.update_config(Preferences.STEAM, text)
func = StoredFunc(lambda: self.emitter.emit("api_change_successful"))
self.thread_man.set_cleanup_func(func)
else:
self.thread_man.set_cleanup_func(
StoredFunc(lambda: self.emitter.emit("api_change_failed"))