From 82edd774a0c07262d29d83fd6202572eaaf9f55f Mon Sep 17 00:00:00 2001 From: Eroax Date: Tue, 9 Apr 2024 06:00:49 +0000 Subject: [PATCH] Extra fixes to NoTwitch Cache handling (#136) Reviewed-on: https://codeberg.org/StreamGraph/StreamGraph/pulls/136 Co-authored-by: Eroax Co-committed-by: Eroax --- graph_node_renderer/twitch_setup_dialog.gd | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/graph_node_renderer/twitch_setup_dialog.gd b/graph_node_renderer/twitch_setup_dialog.gd index 2d3033a..cf71287 100644 --- a/graph_node_renderer/twitch_setup_dialog.gd +++ b/graph_node_renderer/twitch_setup_dialog.gd @@ -11,10 +11,13 @@ func _ready(): #confirmed.connect(connect_to_chat) %Join_Chat.pressed.connect(connect_to_chat) -func authenticate_twitch(): +func authenticate_twitch(skip_load = false): # Temporary setup for loading credentials - var loaded_creds = Connections.load_credentials("twitch") + var loaded_creds = null + + if !skip_load: + loaded_creds = Connections.load_credentials("twitch") if loaded_creds != null: @@ -26,25 +29,22 @@ func authenticate_twitch(): Connections.twitch.cache_user_data() # Binds invalid auth to call No_Twitch.authenticate_with_twitch, handles if the cache of auth is invalid. - Connections.twitch.invalid_auth.connect(func(): - - var url = Connections.twitch.authenticate_with_twitch(%Client_ID.text) - OS.shell_open(url) - ) + Util.safe_connect(Connections.twitch.invalid_auth,authenticate_twitch.bind(true)) connect_to_chat() return # Handles first authentication/invalid cached authentication. - Connections.twitch.token_received.connect(func(token): - - Connections.save_credentials({"token" : token}, "twitch") - ) + Util.safe_connect(Connections.twitch.token_received, save_twitch_token) var url = Connections.twitch.authenticate_with_twitch(%Client_ID.text) OS.shell_open(url) +func save_twitch_token(token): + + Connections.save_credentials({"token" : token}, "twitch") + func copy_auth_link(): var url = Connections.twitch.authenticate_with_twitch(%Client_ID.text)