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

Commit 9fa58e4

Browse files
authored
Strictify Timeline Panel (#11165)
* Get initial fix working * add a couple of union types to tidy up a bit
1 parent 3930f1a commit 9fa58e4

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/components/structures/TimelinePanel.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,8 @@ class TimelinePanel extends React.Component<IProps, IState> {
591591
const dir = backwards ? EventTimeline.BACKWARDS : EventTimeline.FORWARDS;
592592
const canPaginateKey = backwards ? "canBackPaginate" : "canForwardPaginate";
593593
const paginatingKey = backwards ? "backPaginating" : "forwardPaginating";
594+
type CanPaginateKey = typeof canPaginateKey;
595+
type PaginatingKey = typeof paginatingKey;
594596

595597
if (!this.state[canPaginateKey]) {
596598
debuglog("have given up", dir, "paginating this timeline");
@@ -599,7 +601,7 @@ class TimelinePanel extends React.Component<IProps, IState> {
599601

600602
if (!this.timelineWindow?.canPaginate(dir)) {
601603
debuglog("can't", dir, "paginate any further");
602-
this.setState({ [canPaginateKey]: false } as Pick<IState, typeof canPaginateKey>);
604+
this.setState({ [canPaginateKey]: false } as Pick<IState, CanPaginateKey>);
603605
return Promise.resolve(false);
604606
}
605607

@@ -609,7 +611,7 @@ class TimelinePanel extends React.Component<IProps, IState> {
609611
}
610612

611613
debuglog("Initiating paginate; backwards:" + backwards);
612-
this.setState({ [paginatingKey]: true } as Pick<IState, typeof paginatingKey>);
614+
this.setState({ [paginatingKey]: true } as Pick<IState, PaginatingKey>);
613615

614616
return this.onPaginationRequest(this.timelineWindow, dir, PAGINATE_SIZE).then(async (r) => {
615617
if (this.unmounted) {
@@ -624,13 +626,13 @@ class TimelinePanel extends React.Component<IProps, IState> {
624626

625627
const { events, liveEvents, firstVisibleEventIndex } = this.getEvents();
626628
this.buildLegacyCallEventGroupers(events);
627-
const newState: Partial<IState> = {
629+
const newState = {
628630
[paginatingKey]: false,
629631
[canPaginateKey]: r,
630632
events,
631633
liveEvents,
632634
firstVisibleEventIndex,
633-
};
635+
} as Pick<IState, PaginatingKey | CanPaginateKey | "events" | "liveEvents" | "firstVisibleEventIndex">;
634636

635637
// moving the window in this direction may mean that we can now
636638
// paginate in the other where we previously could not.
@@ -647,7 +649,7 @@ class TimelinePanel extends React.Component<IProps, IState> {
647649
// has in memory because we never gave the component a chance to scroll
648650
// itself into the right place
649651
return new Promise((resolve) => {
650-
this.setState<null>(newState, () => {
652+
this.setState(newState, () => {
651653
// we can continue paginating in the given direction if:
652654
// - timelineWindow.paginate says we can
653655
// - we're paginating forwards, or we won't be trying to

0 commit comments

Comments
 (0)