Stop polling if OAuth popup closed

This commit is contained in:
JonnyWong16 2018-09-05 17:44:04 -07:00
parent 4944ce1ca0
commit 1e68a81fe1

View file

@ -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);