mirror of
https://github.com/element-hq/element-web.git
synced 2024-12-11 11:32:31 +03:00
Manual fixup for remaining q incantaions
* don't try to use `finally` as a static method * work around absence of `allSettled`
This commit is contained in:
parent
0d7cc59d99
commit
33f330d434
3 changed files with 27 additions and 17 deletions
|
@ -386,19 +386,12 @@ module.exports = React.createClass({
|
|||
debuglog("ScrollPanel: starting "+dir+" fill");
|
||||
|
||||
// onFillRequest can end up calling us recursively (via onScroll
|
||||
// events) so make sure we set this before firing off the call. That
|
||||
// does present the risk that we might not ever actually fire off the
|
||||
// fill request, so wrap it in a try/catch.
|
||||
// events) so make sure we set this before firing off the call.
|
||||
this._pendingFillRequests[dir] = true;
|
||||
var fillPromise;
|
||||
try {
|
||||
fillPromise = this.props.onFillRequest(backwards);
|
||||
} catch (e) {
|
||||
this._pendingFillRequests[dir] = false;
|
||||
throw e;
|
||||
}
|
||||
|
||||
q.finally(fillPromise, () => {
|
||||
Promise.try(() => {
|
||||
return this.props.onFillRequest(backwards);
|
||||
}).finally(() => {
|
||||
this._pendingFillRequests[dir] = false;
|
||||
}).then((hasMoreResults) => {
|
||||
if (this.unmounted) {
|
||||
|
|
|
@ -568,15 +568,16 @@ module.exports = React.createClass({
|
|||
});
|
||||
// reject the invites
|
||||
const promises = rooms.map((room) => {
|
||||
return MatrixClientPeg.get().leave(room.roomId);
|
||||
});
|
||||
return MatrixClientPeg.get().leave(room.roomId).catch((e) => {
|
||||
// purposefully drop errors to the floor: we'll just have a non-zero number on the UI
|
||||
// after trying to reject all the invites.
|
||||
q.allSettled(promises).then(() => {
|
||||
});
|
||||
});
|
||||
Promise.all(promises).then(() => {
|
||||
this.setState({
|
||||
rejectingInvites: false,
|
||||
});
|
||||
}).done();
|
||||
});
|
||||
},
|
||||
|
||||
_onExportE2eKeysClicked: function() {
|
||||
|
|
|
@ -183,6 +183,12 @@ module.exports = React.createClass({
|
|||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns a promise which resolves once all of the save operations have completed or failed.
|
||||
*
|
||||
* The result is a list of promise state snapshots, each with the form
|
||||
* `{ state: "fulfilled", value: v }` or `{ state: "rejected", reason: r }`.
|
||||
*/
|
||||
save: function() {
|
||||
var stateWasSetDefer = Promise.defer();
|
||||
// the caller may have JUST called setState on stuff, so we need to re-render before saving
|
||||
|
@ -194,8 +200,18 @@ module.exports = React.createClass({
|
|||
this.setState({ _loading: false});
|
||||
});
|
||||
|
||||
function mapPromiseToSnapshot(p) {
|
||||
return p.then((r) => {
|
||||
return { state: "fulfilled", value: r };
|
||||
}, (e) => {
|
||||
return { state: "rejected", reason: e };
|
||||
});
|
||||
}
|
||||
|
||||
return stateWasSetDefer.promise.then(() => {
|
||||
return q.allSettled(this._calcSavePromises());
|
||||
return Promise.all(
|
||||
this._calcSavePromises().map(mapPromiseToSnapshot),
|
||||
);
|
||||
});
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in a new issue