mirror of https://github.com/vector-im/riot-web
Strictify Timeline Panel (#11165)
* Get initial fix working * add a couple of union types to tidy up a bitpull/28217/head
parent
3930f1a10b
commit
9fa58e4e90
|
@ -591,6 +591,8 @@ class TimelinePanel extends React.Component<IProps, IState> {
|
|||
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<IProps, IState> {
|
|||
|
||||
if (!this.timelineWindow?.canPaginate(dir)) {
|
||||
debuglog("can't", dir, "paginate any further");
|
||||
this.setState({ [canPaginateKey]: false } as Pick<IState, typeof canPaginateKey>);
|
||||
this.setState({ [canPaginateKey]: false } as Pick<IState, CanPaginateKey>);
|
||||
return Promise.resolve(false);
|
||||
}
|
||||
|
||||
|
@ -609,7 +611,7 @@ class TimelinePanel extends React.Component<IProps, IState> {
|
|||
}
|
||||
|
||||
debuglog("Initiating paginate; backwards:" + backwards);
|
||||
this.setState({ [paginatingKey]: true } as Pick<IState, typeof paginatingKey>);
|
||||
this.setState({ [paginatingKey]: true } as Pick<IState, PaginatingKey>);
|
||||
|
||||
return this.onPaginationRequest(this.timelineWindow, dir, PAGINATE_SIZE).then(async (r) => {
|
||||
if (this.unmounted) {
|
||||
|
@ -624,13 +626,13 @@ class TimelinePanel extends React.Component<IProps, IState> {
|
|||
|
||||
const { events, liveEvents, firstVisibleEventIndex } = this.getEvents();
|
||||
this.buildLegacyCallEventGroupers(events);
|
||||
const newState: Partial<IState> = {
|
||||
const newState = {
|
||||
[paginatingKey]: false,
|
||||
[canPaginateKey]: r,
|
||||
events,
|
||||
liveEvents,
|
||||
firstVisibleEventIndex,
|
||||
};
|
||||
} as Pick<IState, PaginatingKey | CanPaginateKey | "events" | "liveEvents" | "firstVisibleEventIndex">;
|
||||
|
||||
// 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<IProps, IState> {
|
|||
// has in memory because we never gave the component a chance to scroll
|
||||
// itself into the right place
|
||||
return new Promise((resolve) => {
|
||||
this.setState<null>(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
|
||||
|
|
Loading…
Reference in New Issue