From ce84a36875a38406e1725a816e4b0da63994f4f2 Mon Sep 17 00:00:00 2001 From: Jimmy Z Date: Wed, 9 Mar 2016 22:37:51 +0800 Subject: [PATCH 1/2] do not try default config if we have cookie and fixed some wrong variable names --- js/services/rpc/rpc.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/js/services/rpc/rpc.js b/js/services/rpc/rpc.js index b1300fb..549b55b 100644 --- a/js/services/rpc/rpc.js +++ b/js/services/rpc/rpc.js @@ -6,10 +6,10 @@ angular .factory('$rpc', [ '$syscall', '$globalTimeout', '$alerts', '$utils', '$rootScope', '$location', '$authconf', -function(syscall, time, alerts, utils, rootScope, uri, authconf) { +function(syscall, globalTimeout, alerts, utils, rootScope, uri, authconf) { var subscriptions = [] - , configurations = [authconf] + , configurations , currentConf = {} , currentToken , timeout = null @@ -18,7 +18,7 @@ function(syscall, time, alerts, utils, rootScope, uri, authconf) { var cookieConf = utils.getCookie('aria2conf'); // try at the start, so that it is presistant even when default authconf works - if (cookieConf) configurations.push(cookieConf); + configurations = [cookieConf ? cookieConf : authconf]; if (['http', 'https'].indexOf(uri.protocol()) != -1 && uri.host() != 'localhost') { console.log(uri.host()); @@ -95,7 +95,7 @@ function(syscall, time, alerts, utils, rootScope, uri, authconf) { } else { alerts.addAlert('Oh Snap! Could not connect to the aria2 RPC server. Will retry in 10 secs. You might want to check the connection settings by going to Settings > Connection Settings', 'error'); - timeout = setTimeout(update, $globalTimeout); + timeout = setTimeout(update, globalTimeout); } }; @@ -109,7 +109,7 @@ function(syscall, time, alerts, utils, rootScope, uri, authconf) { if (failed) { alerts.addAlert('Oh Snap! Authentication failed while connecting to Aria2 RPC server. Will retry in 10 secs. You might want to confirm your authentication details by going to Settings > Connection Settings', 'error'); - timeout = setTimeout(update, $globalTimeout); + timeout = setTimeout(update, globalTimeout); return; } @@ -153,7 +153,7 @@ function(syscall, time, alerts, utils, rootScope, uri, authconf) { timeout = setTimeout(update, 0); } else { - timeout = setTimeout(update, time); + timeout = setTimeout(update, globalTimeout); } }, error: error @@ -161,7 +161,7 @@ function(syscall, time, alerts, utils, rootScope, uri, authconf) { }; // initiate the update loop - timeout = setTimeout(update, time); + timeout = setTimeout(update, globalTimeout); return { // conf can be configuration or array of configurations, From dab552c255e2b9cac8a2d199f4b43ebe517e4a4f Mon Sep 17 00:00:00 2001 From: Jimmy Z Date: Thu, 10 Mar 2016 14:55:29 +0800 Subject: [PATCH 2/2] will still try default if cookie config failed --- js/services/rpc/rpc.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/js/services/rpc/rpc.js b/js/services/rpc/rpc.js index 549b55b..df40545 100644 --- a/js/services/rpc/rpc.js +++ b/js/services/rpc/rpc.js @@ -9,16 +9,15 @@ angular function(syscall, globalTimeout, alerts, utils, rootScope, uri, authconf) { var subscriptions = [] - , configurations + , configurations = [authconf] , currentConf = {} , currentToken , timeout = null , forceNextUpdate = false; var cookieConf = utils.getCookie('aria2conf'); - // try at the start, so that it is presistant even when default authconf works - configurations = [cookieConf ? cookieConf : authconf]; + if(cookieConf) configurations.unshift(cookieConf); if (['http', 'https'].indexOf(uri.protocol()) != -1 && uri.host() != 'localhost') { console.log(uri.host());