From cf486aedbda76857ce171b06e7395c0088c76150 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 21 Mar 2017 18:37:08 +0000 Subject: [PATCH] Extend 'ignoreFailure' to be 'background' This allows us to also use it to decide whether or not to show the app as busy in the UI. We pass this flag up into the makeRequest callback so it can use it as such. --- src/interactive-auth.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/interactive-auth.js b/src/interactive-auth.js index 117e7047c..c40b8f513 100644 --- a/src/interactive-auth.js +++ b/src/interactive-auth.js @@ -201,11 +201,11 @@ InteractiveAuth.prototype = { * @param {object} authData new auth dict to send to the server. Should * include a `type` propterty denoting the login type, as well as any * other params for that stage. - * @param {bool} ignoreFailure If true, this request failing will not result + * @param {bool} background If true, this request failing will not result * in the attemptAuth promise being rejected. This can be set to true * for requests that just poll to see if auth has been completed elsewhere. */ - submitAuthDict: function(authData, ignoreFailure) { + submitAuthDict: function(authData, background) { if (!this._completionDeferred) { throw new Error("submitAuthDict() called before attemptAuth()"); } @@ -216,7 +216,7 @@ InteractiveAuth.prototype = { }; utils.extend(auth, authData); - this._doRequest(auth, ignoreFailure); + this._doRequest(auth, background); }, /** @@ -247,11 +247,12 @@ InteractiveAuth.prototype = { * * @private * @param {object?} auth new auth dict, including session id - * @param {bool?} ignoreFailure If true, this request failing will not result - * in the attemptAuth promise being rejected. This can be set to true - * for requests that just poll to see if auth has been completed elsewhere. + * @param {bool?} background If true, this request is a background poll, so it + * failing will not result in the attemptAuth promise being rejected. + * This can be set to true for requests that just poll to see if auth has + * been completed elsewhere. */ - _doRequest: function(auth, ignoreFailure) { + _doRequest: function(auth, background) { const self = this; // hackery to make sure that synchronous exceptions end up in the catch @@ -259,7 +260,7 @@ InteractiveAuth.prototype = { // extra q().then) let prom; try { - prom = this._requestCallback(auth); + prom = this._requestCallback(auth, background); } catch (e) { prom = q.reject(e); } @@ -290,7 +291,7 @@ InteractiveAuth.prototype = { self._startNextAuthStage(); }, ); - if (!ignoreFailure) { + if (!background) { prom = prom.catch(this._completionDeferred.reject); } else { // We ignore all failures here (even non-UI auth related ones)