Skip to content

Commit

Permalink
Always shows badges
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio authored and pull[bot] committed Aug 27, 2024
1 parent f80ec5f commit c2172ed
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 47 deletions.
33 changes: 7 additions & 26 deletions src/views/workspacesView.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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';
Expand All @@ -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();
}

Expand All @@ -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;
}
Expand Down
23 changes: 2 additions & 21 deletions src/views/worktreesView.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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';
Expand Down Expand Up @@ -119,6 +118,7 @@ export class WorktreesView extends ViewBase<'worktrees', WorktreesViewNode, Work
},
}),
);
this.description = '✨';
}

override get canReveal(): boolean {
Expand All @@ -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);
}
Expand Down

0 comments on commit c2172ed

Please sign in to comment.