Fix infinite loop when there are a lot of invisible events (#554)

Instead of using a window of a fixed number of events, unpaginate based on the distance of the viewport from the end of the scroll range.

The ScrollPanel uses the scrollTokens to convey to its parent (the TimelinePanel, in this case) the point to unpaginate up to. The TimelinePanel then takes a chunk of events off the front or back of `this.state.events` using `timelineWindow.unpaginate`.

Fixes https://github.com/vector-im/vector-web/issues/2020
This commit is contained in:
Luke Barnard 2016-11-16 14:25:52 +00:00 committed by Richard van der Hoff
parent 6ccc825f0d
commit b718f1542c
4 changed files with 137 additions and 6 deletions

View file

@ -321,7 +321,7 @@ describe('TimelinePanel', function() {
expect(messagePanel.props.suppressFirstDateSeparator).toBe(false);
var events = scryEventTiles(panel);
expect(events[0].props.mxEvent).toBe(timeline.getEvents()[0]);
expect(events.length).toEqual(TIMELINE_CAP);
expect(events.length).toBeLessThanOrEqualTo(TIMELINE_CAP);
// we should now be able to scroll down, and paginate in the other
// direction.
@ -339,7 +339,7 @@ describe('TimelinePanel', function() {
expect(messagePanel.props.suppressFirstDateSeparator).toBe(true);
var events = scryEventTiles(panel);
expect(events.length).toEqual(TIMELINE_CAP);
expect(events.length).toBeLessThanOrEqualTo(TIMELINE_CAP);
// we don't really know what the first event tile will be, since that
// depends on how much the timelinepanel decides to paginate.