diff --git a/src/components/structures/FilePanel.js b/src/components/structures/FilePanel.js index 71e8143f0a..c96f8770ad 100644 --- a/src/components/structures/FilePanel.js +++ b/src/components/structures/FilePanel.js @@ -98,7 +98,7 @@ const FilePanel = createReactClass({ if (client.isRoomEncrypted(roomId) && eventIndex !== null) { const timeline = timelineSet.getLiveTimeline(); - await eventIndex.populateFileTimeline(timelineSet, timeline, room, 1); + await eventIndex.populateFileTimeline(timelineSet, timeline, room, 10); } this.setState({ timelineSet: timelineSet }); diff --git a/src/indexing/EventIndex.js b/src/indexing/EventIndex.js index c081440233..93c640cf8e 100644 --- a/src/indexing/EventIndex.js +++ b/src/indexing/EventIndex.js @@ -476,6 +476,16 @@ export default class EventIndex { fromEvent = null, direction = EventTimeline.BACKWARDS) { const matrixEvents = await this.loadFileEvents(room, limit, fromEvent, direction); + // If this is a normal fill request, not a pagination request, we need + // to get our events in the BACKWARDS direction but populate them in the + // forwards direction. + // This needs to happen because a fill request might come with an + // exisitng timeline e.g. if you close and re-open the FilePanel. + if (fromEvent === null) { + matrixEvents.reverse(); + direction = direction == EventTimeline.BACKWARDS ? EventTimeline.FORWARDS: EventTimeline.BACKWARDS; + } + // Add the events to the live timeline of the file panel. matrixEvents.forEach(e => { if (!timelineSet.eventIdToTimeline(e.getId())) {