You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-26 17:03:12 +03:00
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.
This commit is contained in:
@@ -201,11 +201,11 @@ InteractiveAuth.prototype = {
|
|||||||
* @param {object} authData new auth dict to send to the server. Should
|
* @param {object} authData new auth dict to send to the server. Should
|
||||||
* include a `type` propterty denoting the login type, as well as any
|
* include a `type` propterty denoting the login type, as well as any
|
||||||
* other params for that stage.
|
* 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
|
* 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.
|
* for requests that just poll to see if auth has been completed elsewhere.
|
||||||
*/
|
*/
|
||||||
submitAuthDict: function(authData, ignoreFailure) {
|
submitAuthDict: function(authData, background) {
|
||||||
if (!this._completionDeferred) {
|
if (!this._completionDeferred) {
|
||||||
throw new Error("submitAuthDict() called before attemptAuth()");
|
throw new Error("submitAuthDict() called before attemptAuth()");
|
||||||
}
|
}
|
||||||
@@ -216,7 +216,7 @@ InteractiveAuth.prototype = {
|
|||||||
};
|
};
|
||||||
utils.extend(auth, authData);
|
utils.extend(auth, authData);
|
||||||
|
|
||||||
this._doRequest(auth, ignoreFailure);
|
this._doRequest(auth, background);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -247,11 +247,12 @@ InteractiveAuth.prototype = {
|
|||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {object?} auth new auth dict, including session id
|
* @param {object?} auth new auth dict, including session id
|
||||||
* @param {bool?} ignoreFailure If true, this request failing will not result
|
* @param {bool?} background If true, this request is a background poll, so it
|
||||||
* in the attemptAuth promise being rejected. This can be set to true
|
* failing will not result in the attemptAuth promise being rejected.
|
||||||
* for requests that just poll to see if auth has been completed elsewhere.
|
* 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;
|
const self = this;
|
||||||
|
|
||||||
// hackery to make sure that synchronous exceptions end up in the catch
|
// hackery to make sure that synchronous exceptions end up in the catch
|
||||||
@@ -259,7 +260,7 @@ InteractiveAuth.prototype = {
|
|||||||
// extra q().then)
|
// extra q().then)
|
||||||
let prom;
|
let prom;
|
||||||
try {
|
try {
|
||||||
prom = this._requestCallback(auth);
|
prom = this._requestCallback(auth, background);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
prom = q.reject(e);
|
prom = q.reject(e);
|
||||||
}
|
}
|
||||||
@@ -290,7 +291,7 @@ InteractiveAuth.prototype = {
|
|||||||
self._startNextAuthStage();
|
self._startNextAuthStage();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
if (!ignoreFailure) {
|
if (!background) {
|
||||||
prom = prom.catch(this._completionDeferred.reject);
|
prom = prom.catch(this._completionDeferred.reject);
|
||||||
} else {
|
} else {
|
||||||
// We ignore all failures here (even non-UI auth related ones)
|
// We ignore all failures here (even non-UI auth related ones)
|
||||||
|
|||||||
Reference in New Issue
Block a user