|
2 | 2 | import { Command, Disposable, Event, TreeItem, TreeItemCollapsibleState, TreeViewVisibilityChangeEvent } from 'vscode'; |
3 | 3 | import { GitUri } from '../../git/gitService'; |
4 | 4 | import { Logger } from '../../logger'; |
5 | | -import { debug, gate, logName } from '../../system'; |
| 5 | +import { debug, Functions, gate, logName } from '../../system'; |
6 | 6 | import { TreeViewNodeStateChangeEvent, View } from '../viewBase'; |
7 | 7 |
|
8 | 8 | export enum ResourceType { |
@@ -118,16 +118,16 @@ export interface PageableViewNode { |
118 | 118 | maxCount: number | undefined; |
119 | 119 | } |
120 | 120 |
|
121 | | -export function isPageable( |
122 | | - node: ViewNode |
123 | | -): node is ViewNode & { supportsPaging: boolean; maxCount: number | undefined } { |
124 | | - return Boolean((node as ViewNode & { supportsPaging: boolean }).supportsPaging); |
| 121 | +export function isPageable(node: ViewNode): node is ViewNode & PageableViewNode { |
| 122 | + return Functions.is<ViewNode & PageableViewNode>(node, 'supportsPaging', true); |
125 | 123 | } |
126 | 124 |
|
127 | | -export function supportsAutoRefresh( |
128 | | - view: View |
129 | | -): view is View & { autoRefresh: boolean; onDidChangeAutoRefresh: Event<void> } { |
130 | | - return (view as View & { onDidChangeAutoRefresh: Event<void> }).onDidChangeAutoRefresh !== undefined; |
| 125 | +interface AutoRefreshableView { |
| 126 | + autoRefresh: boolean; |
| 127 | + onDidChangeAutoRefresh: Event<void>; |
| 128 | +} |
| 129 | +export function supportsAutoRefresh(view: View): view is View & AutoRefreshableView { |
| 130 | + return Functions.is<View & AutoRefreshableView>(view, 'onDidChangeAutoRefresh'); |
131 | 131 | } |
132 | 132 |
|
133 | 133 | export abstract class SubscribeableViewNode<TView extends View = View> extends ViewNode<TView> { |
|
0 commit comments