|
|
@ -146,26 +146,31 @@ export abstract class PagerNode extends ViewNode { |
|
|
|
parent: ViewNode & PageableViewNode, |
|
|
|
protected readonly message: string, |
|
|
|
protected readonly previousNode?: ViewNode, |
|
|
|
protected readonly pageSize: number = Container.instance.config.views.pageItemLimit, |
|
|
|
protected readonly countFn?: () => Promise<number | undefined>, |
|
|
|
protected readonly options?: { |
|
|
|
context?: Record<string, unknown>; |
|
|
|
pageSize?: number; |
|
|
|
getCount?: () => Promise<number | undefined>; |
|
|
|
}, // protected readonly pageSize: number = Container.instance.config.views.pageItemLimit, // protected readonly countFn?: () => Promise<number | undefined>, // protected readonly context?: Record<string, unknown>, // protected readonly beforeLoadCallback?: (mode: 'all' | 'more') => void,
|
|
|
|
) { |
|
|
|
super(GitUri.unknown, view, parent); |
|
|
|
} |
|
|
|
|
|
|
|
async loadAll() { |
|
|
|
const count = (await this.countFn?.()) ?? 0; |
|
|
|
const count = (await this.options?.getCount?.()) ?? 0; |
|
|
|
return this.view.loadMoreNodeChildren( |
|
|
|
this.parent! as ViewNode & PageableViewNode, |
|
|
|
count > 5000 ? 5000 : 0, |
|
|
|
this.previousNode, |
|
|
|
this.options?.context, |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
loadMore() { |
|
|
|
return this.view.loadMoreNodeChildren( |
|
|
|
this.parent! as ViewNode & PageableViewNode, |
|
|
|
this.pageSize, |
|
|
|
this.options?.pageSize ?? Container.instance.config.views.pageItemLimit, |
|
|
|
this.previousNode, |
|
|
|
this.options?.context, |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
@ -194,18 +199,22 @@ export class LoadMoreNode extends PagerNode { |
|
|
|
view: View, |
|
|
|
parent: ViewNode & PageableViewNode, |
|
|
|
previousNode: ViewNode, |
|
|
|
pageSize?: number, |
|
|
|
countFn?: () => Promise<number | undefined>, |
|
|
|
options?: { |
|
|
|
context?: Record<string, unknown>; |
|
|
|
getCount?: () => Promise<number | undefined>; |
|
|
|
message?: string; |
|
|
|
pageSize?: number; |
|
|
|
}, |
|
|
|
) { |
|
|
|
super( |
|
|
|
view, |
|
|
|
parent, |
|
|
|
pageSize === 0 |
|
|
|
? `Load all ${GlyphChars.Space}${GlyphChars.Dash}${GlyphChars.Space} this may take a while` |
|
|
|
: 'Load more', |
|
|
|
options?.message ?? |
|
|
|
(options?.pageSize === 0 |
|
|
|
? `Load all ${GlyphChars.Space}${GlyphChars.Dash}${GlyphChars.Space} this may take a while` |
|
|
|
: 'Load more'), |
|
|
|
previousNode, |
|
|
|
pageSize, |
|
|
|
countFn, |
|
|
|
options, |
|
|
|
); |
|
|
|
} |
|
|
|
} |