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 // sortByAuthorDate: true
}); });
const more = limit === undefined ? false : commits.length >= limit;
const paging = commits.length ? { const paging = commits.length ? {
more: more, cursor: limit === undefined ? undefined : (commits.length >= limit ? commits[commits.length - 1]?.hash : undefined)
cursor: more ? commits[commits.length - 1]?.hash : undefined
} : undefined; } : undefined;
// If we asked for an extra commit, strip it off // If we asked for an extra commit, strip it off

View file

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

View file

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

View file

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

View file

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