Procházet zdrojové kódy

Always shows badges

main
Eric Amodio před 1 rokem
rodič
revize
26e4c5709b
2 změnil soubory, kde provedl 9 přidání a 47 odebrání
  1. +7
    -26
      src/views/workspacesView.ts
  2. +2
    -21
      src/views/worktreesView.ts

+ 7
- 26
src/views/workspacesView.ts Zobrazit soubor

@ -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 Zobrazit soubor

@ -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);
}

Načítá se…
Zrušit
Uložit