-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Splits & moves abstract node classes to new files
- Loading branch information
Showing
77 changed files
with
1,115 additions
and
1,044 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import type { TreeViewNodeTypes } from '../../../constants'; | ||
import { debug } from '../../../system/decorators/log'; | ||
import type { View } from '../../viewBase'; | ||
import { disposeChildren } from '../../viewBase'; | ||
import { ViewNode } from './viewNode'; | ||
|
||
export abstract class CacheableChildrenViewNode< | ||
Type extends TreeViewNodeTypes = TreeViewNodeTypes, | ||
TView extends View = View, | ||
TChild extends ViewNode = ViewNode, | ||
State extends object = any, | ||
> extends ViewNode<Type, TView, State> { | ||
private _children: TChild[] | undefined; | ||
protected get children(): TChild[] | undefined { | ||
return this._children; | ||
} | ||
protected set children(value: TChild[] | undefined) { | ||
if (this._children === value) return; | ||
|
||
disposeChildren(this._children, value); | ||
this._children = value; | ||
} | ||
|
||
@debug() | ||
override dispose() { | ||
super.dispose(); | ||
this.children = undefined; | ||
} | ||
|
||
@debug() | ||
override refresh(reset: boolean = false) { | ||
if (reset) { | ||
this.children = undefined; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { Disposable } from 'vscode'; | ||
import type { RepositoriesChangeEvent } from '../../../git/gitProviderService'; | ||
import { unknownGitUri } from '../../../git/gitUri'; | ||
import type { SubscriptionChangeEvent } from '../../../plus/subscription/subscriptionService'; | ||
import { debug } from '../../../system/decorators/log'; | ||
import { weakEvent } from '../../../system/event'; | ||
import { szudzikPairing } from '../../../system/function'; | ||
import type { View } from '../../viewBase'; | ||
import { SubscribeableViewNode } from './subscribeableViewNode'; | ||
import type { ViewNode } from './viewNode'; | ||
|
||
export abstract class RepositoriesSubscribeableNode< | ||
TView extends View = View, | ||
TChild extends ViewNode = ViewNode, | ||
> extends SubscribeableViewNode<'repositories', TView, TChild> { | ||
protected override splatted = true; | ||
|
||
constructor(view: TView) { | ||
super('repositories', unknownGitUri, view); | ||
} | ||
|
||
override async getSplattedChild() { | ||
if (this.children == null) { | ||
await this.getChildren(); | ||
} | ||
|
||
return this.children?.length === 1 ? this.children[0] : undefined; | ||
} | ||
|
||
protected override etag(): number { | ||
return szudzikPairing(this.view.container.git.etag, this.view.container.subscription.etag); | ||
} | ||
|
||
@debug() | ||
protected subscribe(): Disposable | Promise<Disposable> { | ||
return Disposable.from( | ||
weakEvent(this.view.container.git.onDidChangeRepositories, this.onRepositoriesChanged, this), | ||
weakEvent(this.view.container.subscription.onDidChange, this.onSubscriptionChanged, this), | ||
); | ||
} | ||
|
||
private onRepositoriesChanged(_e: RepositoriesChangeEvent) { | ||
void this.triggerChange(true); | ||
} | ||
|
||
private onSubscriptionChanged(e: SubscriptionChangeEvent) { | ||
if (e.current.plan !== e.previous.plan) { | ||
void this.triggerChange(true); | ||
} | ||
} | ||
} |
Oops, something went wrong.