瀏覽代碼

Always shows badges

main
Eric Amodio 1 年之前
父節點
當前提交
26e4c5709b
共有 2 個文件被更改,包括 9 次插入47 次删除
  1. +7
    -26
      src/views/workspacesView.ts
  2. +2
    -21
      src/views/worktreesView.ts

+ 7
- 26
src/views/workspacesView.ts 查看文件

@ -1,4 +1,4 @@
import type { Disposable, TreeViewVisibilityChangeEvent } from 'vscode';
import type { Disposable } from 'vscode';
import { ProgressLocation, window } from 'vscode';
import type { WorkspacesViewConfig } from '../config';
import { Commands } from '../constants';
@ -7,7 +7,6 @@ import { unknownGitUri } from '../git/gitUri';
import type { Repository } from '../git/models/repository';
import { ensurePlusFeaturesEnabled } from '../plus/subscription/utils';
import { WorkspaceType } from '../plus/workspaces/models';
import { SubscriptionState } from '../subscription';
import { executeCommand } from '../system/command';
import { openWorkspace, OpenWorkspaceLocation } from '../system/utils';
import type { RepositoriesNode } from './nodes/repositoriesNode';
@ -20,32 +19,19 @@ import { registerViewCommand } from './viewCommands';
export class WorkspacesView extends ViewBase<'workspaces', WorkspacesViewNode, WorkspacesViewConfig> {
protected readonly configKey = 'repositories';
private _workspacesChangedDisposable: Disposable;
private _visibleDisposable: Disposable | undefined;
private _disposable: Disposable;
constructor(container: Container) {
super(container, 'workspaces', 'Workspaces', 'workspaceView');
this._workspacesChangedDisposable = this.container.workspaces.onDidChangeWorkspaces(() => {
void this.ensureRoot().triggerChange(true);
});
}
protected override onVisibilityChanged(e: TreeViewVisibilityChangeEvent): void {
if (e.visible) {
void this.updateDescription();
this._visibleDisposable?.dispose();
this._visibleDisposable = this.container.subscription.onDidChange(() => void this.updateDescription());
} else {
this._visibleDisposable?.dispose();
this._visibleDisposable = undefined;
}
super.onVisibilityChanged(e);
this._disposable = this.container.workspaces.onDidChangeWorkspaces(
() => void this.ensureRoot().triggerChange(true),
);
this.description = `PREVIEW ☁️`;
}
override dispose() {
this._workspacesChangedDisposable.dispose();
this._visibleDisposable?.dispose();
this._disposable.dispose();
super.dispose();
}
@ -62,11 +48,6 @@ export class WorkspacesView extends ViewBase<'workspaces', WorkspacesViewNode, W
return super.show(options);
}
private async updateDescription() {
const subscription = await this.container.subscription.getSubscription();
this.description = `PREVIEW ${subscription.state === SubscriptionState.Paid ? '' : '☁️'}`;
}
override get canReveal(): boolean {
return false;
}

+ 2
- 21
src/views/worktreesView.ts 查看文件

@ -1,4 +1,4 @@
import type { CancellationToken, ConfigurationChangeEvent, Disposable, TreeViewVisibilityChangeEvent } from 'vscode';
import type { CancellationToken, ConfigurationChangeEvent, Disposable } from 'vscode';
import { ProgressLocation, ThemeColor, TreeItem, TreeItemCollapsibleState, window } from 'vscode';
import type { WorktreesViewConfig } from '../config';
import { ViewFilesLayout, ViewShowBranchComparison } from '../config';
@ -11,7 +11,6 @@ import type { RepositoryChangeEvent } from '../git/models/repository';
import { RepositoryChange, RepositoryChangeComparisonMode } from '../git/models/repository';
import type { GitWorktree } from '../git/models/worktree';
import { ensurePlusFeaturesEnabled } from '../plus/subscription/utils';
import { SubscriptionState } from '../subscription';
import { executeCommand } from '../system/command';
import { configuration } from '../system/configuration';
import { gate } from '../system/decorators/gate';
@ -119,6 +118,7 @@ export class WorktreesView extends ViewBase<'worktrees', WorktreesViewNode, Work
},
}),
);
this.description = '✨';
}
override get canReveal(): boolean {
@ -130,25 +130,6 @@ export class WorktreesView extends ViewBase<'worktrees', WorktreesViewNode, Work
return super.show(options);
}
private _visibleDisposable: Disposable | undefined;
protected override onVisibilityChanged(e: TreeViewVisibilityChangeEvent): void {
if (e.visible) {
void this.updateDescription();
this._visibleDisposable?.dispose();
this._visibleDisposable = this.container.subscription.onDidChange(() => void this.updateDescription());
} else {
this._visibleDisposable?.dispose();
this._visibleDisposable = undefined;
}
super.onVisibilityChanged(e);
}
private async updateDescription() {
const subscription = await this.container.subscription.getSubscription();
this.description = subscription.state === SubscriptionState.Paid ? undefined : '✨';
}
protected getRoot() {
return new WorktreesViewNode(this);
}

Loading…
取消
儲存