diff --git a/src/components/structures/TimelinePanel.js b/src/components/structures/TimelinePanel.js index 3e59a5aae4..862c3f46d0 100644 --- a/src/components/structures/TimelinePanel.js +++ b/src/components/structures/TimelinePanel.js @@ -344,9 +344,16 @@ var TimelinePanel = React.createClass({ newState[canPaginateOtherWayKey] = true; } - this.setState(newState); - - return r; + // Don't resolve until the setState has completed: we need to let + // the component update before we consider the pagination completed, + // 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 + // itself into the right place + return new Promise((resolve) => { + this.setState(newState, () => { + resolve(r); + }); + }); }); },