diff --git a/src/components/structures/TimelinePanel.tsx b/src/components/structures/TimelinePanel.tsx index 061aa9d10e..14c4b952b7 100644 --- a/src/components/structures/TimelinePanel.tsx +++ b/src/components/structures/TimelinePanel.tsx @@ -591,6 +591,8 @@ class TimelinePanel extends React.Component { const dir = backwards ? EventTimeline.BACKWARDS : EventTimeline.FORWARDS; const canPaginateKey = backwards ? "canBackPaginate" : "canForwardPaginate"; const paginatingKey = backwards ? "backPaginating" : "forwardPaginating"; + type CanPaginateKey = typeof canPaginateKey; + type PaginatingKey = typeof paginatingKey; if (!this.state[canPaginateKey]) { debuglog("have given up", dir, "paginating this timeline"); @@ -599,7 +601,7 @@ class TimelinePanel extends React.Component { if (!this.timelineWindow?.canPaginate(dir)) { debuglog("can't", dir, "paginate any further"); - this.setState({ [canPaginateKey]: false } as Pick); + this.setState({ [canPaginateKey]: false } as Pick); return Promise.resolve(false); } @@ -609,7 +611,7 @@ class TimelinePanel extends React.Component { } debuglog("Initiating paginate; backwards:" + backwards); - this.setState({ [paginatingKey]: true } as Pick); + this.setState({ [paginatingKey]: true } as Pick); return this.onPaginationRequest(this.timelineWindow, dir, PAGINATE_SIZE).then(async (r) => { if (this.unmounted) { @@ -624,13 +626,13 @@ class TimelinePanel extends React.Component { const { events, liveEvents, firstVisibleEventIndex } = this.getEvents(); this.buildLegacyCallEventGroupers(events); - const newState: Partial = { + const newState = { [paginatingKey]: false, [canPaginateKey]: r, events, liveEvents, firstVisibleEventIndex, - }; + } as Pick; // moving the window in this direction may mean that we can now // paginate in the other where we previously could not. @@ -647,7 +649,7 @@ class TimelinePanel extends React.Component { // 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, () => { + this.setState(newState, () => { // we can continue paginating in the given direction if: // - timelineWindow.paginate says we can // - we're paginating forwards, or we won't be trying to