Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 422d5c0

Browse files
authored
Merge pull request #567 from matrix-org/luke/fix-agressive-unpagination
Make the unpagination process less aggressive
2 parents 06f12b9 + 8a6ed1d commit 422d5c0

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/components/structures/ScrollPanel.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ var DEBUG_SCROLL = false;
2525

2626
// The amount of extra scroll distance to allow prior to unfilling.
2727
// See _getExcessHeight.
28-
const UNPAGINATION_PADDING = 500;
28+
const UNPAGINATION_PADDING = 1500;
29+
// The number of milliseconds to debounce calls to onUnfillRequest, to prevent
30+
// many scroll events causing many unfilling requests.
31+
const UNFILL_REQUEST_DEBOUNCE_MS = 200;
2932

3033
if (DEBUG_SCROLL) {
3134
// using bind means that we get to keep useful line numbers in the console
@@ -361,7 +364,15 @@ module.exports = React.createClass({
361364
}
362365

363366
if (markerScrollToken) {
364-
this.props.onUnfillRequest(backwards, markerScrollToken);
367+
// Use a debouncer to prevent multiple unfill calls in quick succession
368+
// This is to make the unfilling process less aggressive
369+
if (this._unfillDebouncer) {
370+
clearTimeout(this._unfillDebouncer);
371+
}
372+
this._unfillDebouncer = setTimeout(() => {
373+
this._unfillDebouncer = null;
374+
this.props.onUnfillRequest(backwards, markerScrollToken);
375+
}, UNFILL_REQUEST_DEBOUNCE_MS);
365376
}
366377
},
367378

test/components/structures/TimelinePanel-test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,9 @@ describe('TimelinePanel', function() {
341341
var events = scryEventTiles(panel);
342342
expect(events[0].props.mxEvent).toBe(timeline.getEvents()[0]);
343343

344-
// Expect to be able to paginate forwards, having unpaginated a few events
345-
expect(panel.state.canForwardPaginate).toBe(true);
344+
// At this point, we make no assumption that unpagination has happened. This doesn't
345+
// mean that we shouldn't be able to scroll all the way down to the bottom to see the
346+
// most recent event in the timeline.
346347

347348
// scroll all the way to the bottom
348349
return scrollDown();

0 commit comments

Comments
 (0)