mirror of
https://github.com/aclist/dztui.git
synced 2026-08-25 17:32:36 +02:00
feat: simplify API udpate signals
This commit is contained in:
parent
dfd6850d6d
commit
69cba3460d
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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"))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user