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)