mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-16 21:24:59 +08:00
Put setSate in the promise constructor
Avoids local variables. Also typo in comment.
This commit is contained in:
parent
225fe67586
commit
a2f2070966
@ -345,19 +345,15 @@ var TimelinePanel = React.createClass({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Don't resolve until the setState has completed: we need to let
|
// Don't resolve until the setState has completed: we need to let
|
||||||
// the component update before we consider the pagination commpleted,
|
// the component update before we consider the pagination completed,
|
||||||
// otherwise we'll end up paginating in all the history the js-sdk
|
// otherwise we'll end up paginating in all the history the js-sdk
|
||||||
// has in memory because we never gave the component a chance to scroll
|
// has in memory because we never gave the component a chance to scroll
|
||||||
// itself into the right place
|
// itself into the right place
|
||||||
let resolveSetStatePromise;
|
return new Promise((resolve) => {
|
||||||
const setStatePromise = new Promise(function(resolve) {
|
|
||||||
resolveSetStatePromise = resolve;
|
|
||||||
});
|
|
||||||
this.setState(newState, () => {
|
this.setState(newState, () => {
|
||||||
resolveSetStatePromise(r);
|
resolve(r);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
return setStatePromise;
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user