Simplifies timeline paging options

This commit is contained in:
Eric Amodio 2020-03-23 13:49:35 -04:00
parent 763516c445
commit 5391a481bc
5 changed files with 7 additions and 18 deletions

View file

@ -136,10 +136,8 @@ export class GitTimelineProvider implements TimelineProvider {
// sortByAuthorDate: true
});
const more = limit === undefined ? false : commits.length >= limit;
const paging = commits.length ? {
more: more,
cursor: more ? commits[commits.length - 1]?.hash : undefined
cursor: limit === undefined ? undefined : (commits.length >= limit ? commits[commits.length - 1]?.hash : undefined)
} : undefined;
// If we asked for an extra commit, strip it off

View file

@ -1895,13 +1895,9 @@ declare module 'vscode' {
readonly paging?: {
/**
* A provider-defined cursor specifing the starting point of timeline items which are after the ones returned.
* Use `undefined` to signal that there are no more items to be returned.
*/
readonly cursor?: string
/**
* A flag which indicates whether there are more items that weren't returned.
*/
readonly more?: boolean;
readonly cursor: string | undefined;
}
/**

View file

@ -88,7 +88,6 @@ class TimelineAggregate {
this.source = timeline.source;
this.items = timeline.items;
this._cursor = timeline.paging?.cursor;
this._more = timeline.paging?.more ?? false;
this.lastRenderedIndex = -1;
}
@ -97,9 +96,8 @@ class TimelineAggregate {
return this._cursor;
}
private _more: boolean;
get more(): boolean {
return this._more;
return this._cursor !== undefined;
}
get newest(): TimelineItem | undefined {
@ -150,7 +148,6 @@ class TimelineAggregate {
}
this._cursor = timeline.paging?.cursor;
this._more = timeline.paging?.more ?? false;
if (updated) {
this.items.sort(

View file

@ -54,8 +54,7 @@ export interface Timeline {
items: TimelineItem[];
paging?: {
cursor?: string
more?: boolean;
cursor: string | undefined;
}
}

View file

@ -58,8 +58,7 @@ export class TimelineService implements ITimelineService {
// }
// ],
// paging: {
// cursor: 'next',
// more: true
// cursor: 'next'
// }
// });
// }
@ -84,7 +83,7 @@ export class TimelineService implements ITimelineService {
// }
// ],
// paging: {
// more: false
// cursor: undefined
// }
// });
// },