Strictify Timeline Panel (#11165)
* Get initial fix working * add a couple of union types to tidy up a bitpull/28788/head^2
parent
3930f1a10b
commit
9fa58e4e90
|
@ -591,6 +591,8 @@ class TimelinePanel extends React.Component<IProps, IState> {
|
||||||
const dir = backwards ? EventTimeline.BACKWARDS : EventTimeline.FORWARDS;
|
const dir = backwards ? EventTimeline.BACKWARDS : EventTimeline.FORWARDS;
|
||||||
const canPaginateKey = backwards ? "canBackPaginate" : "canForwardPaginate";
|
const canPaginateKey = backwards ? "canBackPaginate" : "canForwardPaginate";
|
||||||
const paginatingKey = backwards ? "backPaginating" : "forwardPaginating";
|
const paginatingKey = backwards ? "backPaginating" : "forwardPaginating";
|
||||||
|
type CanPaginateKey = typeof canPaginateKey;
|
||||||
|
type PaginatingKey = typeof paginatingKey;
|
||||||
|
|
||||||
if (!this.state[canPaginateKey]) {
|
if (!this.state[canPaginateKey]) {
|
||||||
debuglog("have given up", dir, "paginating this timeline");
|
debuglog("have given up", dir, "paginating this timeline");
|
||||||
|
@ -599,7 +601,7 @@ class TimelinePanel extends React.Component<IProps, IState> {
|
||||||
|
|
||||||
if (!this.timelineWindow?.canPaginate(dir)) {
|
if (!this.timelineWindow?.canPaginate(dir)) {
|
||||||
debuglog("can't", dir, "paginate any further");
|
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);
|
return Promise.resolve(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -609,7 +611,7 @@ class TimelinePanel extends React.Component<IProps, IState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
debuglog("Initiating paginate; backwards:" + backwards);
|
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) => {
|
return this.onPaginationRequest(this.timelineWindow, dir, PAGINATE_SIZE).then(async (r) => {
|
||||||
if (this.unmounted) {
|
if (this.unmounted) {
|
||||||
|
@ -624,13 +626,13 @@ class TimelinePanel extends React.Component<IProps, IState> {
|
||||||
|
|
||||||
const { events, liveEvents, firstVisibleEventIndex } = this.getEvents();
|
const { events, liveEvents, firstVisibleEventIndex } = this.getEvents();
|
||||||
this.buildLegacyCallEventGroupers(events);
|
this.buildLegacyCallEventGroupers(events);
|
||||||
const newState: Partial<IState> = {
|
const newState = {
|
||||||
[paginatingKey]: false,
|
[paginatingKey]: false,
|
||||||
[canPaginateKey]: r,
|
[canPaginateKey]: r,
|
||||||
events,
|
events,
|
||||||
liveEvents,
|
liveEvents,
|
||||||
firstVisibleEventIndex,
|
firstVisibleEventIndex,
|
||||||
};
|
} as Pick<IState, PaginatingKey | CanPaginateKey | "events" | "liveEvents" | "firstVisibleEventIndex">;
|
||||||
|
|
||||||
// moving the window in this direction may mean that we can now
|
// moving the window in this direction may mean that we can now
|
||||||
// paginate in the other where we previously could not.
|
// 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
|
// has in memory because we never gave the component a chance to scroll
|
||||||
// itself into the right place
|
// itself into the right place
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
this.setState<null>(newState, () => {
|
this.setState(newState, () => {
|
||||||
// we can continue paginating in the given direction if:
|
// we can continue paginating in the given direction if:
|
||||||
// - timelineWindow.paginate says we can
|
// - timelineWindow.paginate says we can
|
||||||
// - we're paginating forwards, or we won't be trying to
|
// - we're paginating forwards, or we won't be trying to
|
||||||
|
|
Loading…
Reference in New Issue