From 1e68a81fe1a7a5cee88575ac83d2cdf8368a78fd Mon Sep 17 00:00:00 2001 From: JonnyWong16 Date: Wed, 5 Sep 2018 17:44:04 -0700 Subject: [PATCH] Stop polling if OAuth popup closed --- data/interfaces/default/js/script.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/data/interfaces/default/js/script.js b/data/interfaces/default/js/script.js index 4ec78bb8..56986e22 100644 --- a/data/interfaces/default/js/script.js +++ b/data/interfaces/default/js/script.js @@ -568,7 +568,6 @@ getPlexOAuthPin = function () { type: 'POST', headers: x_plex_headers, success: function(data) { - plex_oauth_window.location = 'https://app.plex.tv/auth/#!?clientID=' + x_plex_headers['X-Plex-Client-Identifier'] + '&code=' + data.code; deferred.resolve({pin: data.id, code: data.code}); }, error: function() { @@ -595,6 +594,8 @@ function PlexOAuth(success, error, pre) { const code = data.code; var keep_polling = true; + plex_oauth_window.location = 'https://app.plex.tv/auth/#!?clientID=' + x_plex_headers['X-Plex-Client-Identifier'] + '&code=' + code; + (function poll() { polling = setTimeout(function () { $.ajax({ @@ -618,7 +619,7 @@ function PlexOAuth(success, error, pre) { } }, complete: function () { - if (keep_polling){ + if (keep_polling && !plex_oauth_window.closed){ poll(); } else { clearTimeout(polling);