From 88db6e06e5e1462bb6735768f4d0083adc3914c6 Mon Sep 17 00:00:00 2001 From: Daniel Banck Date: Wed, 11 Oct 2023 11:27:08 +0200 Subject: [PATCH] Clear cache on refresh --- package.json | 2 +- src/providers/tfc/runProvider.ts | 2 +- src/providers/tfc/workspaceProvider.ts | 14 +++++++++----- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index d8c04588e5..3e76c51763 100644 --- a/package.json +++ b/package.json @@ -610,7 +610,7 @@ }, { "command": "terraform.cloud.workspaces.viewInBrowser", - "when": "view == terraform.cloud.workspaces", + "when": "view == terraform.cloud.workspaces && viewItem =~ /hasLink/", "group": "inline" }, { diff --git a/src/providers/tfc/runProvider.ts b/src/providers/tfc/runProvider.ts index fa8702d57a..4ee3278e2f 100644 --- a/src/providers/tfc/runProvider.ts +++ b/src/providers/tfc/runProvider.ts @@ -107,7 +107,7 @@ export class RunTreeDataProvider implements vscode.TreeDataProvider(); public readonly onDidChangeTreeData = this.didChangeTreeData.event; private projectFilter: string | undefined; - private pageSize = 10; // TODO! increase + private pageSize = 50; private cache: vscode.TreeItem[] = []; private totalWorkspaceCount = -1; @@ -35,12 +35,14 @@ export class WorkspaceTreeDataProvider implements vscode.TreeDataProvider { this.reporter.sendTelemetryEvent('tfc-workspaces-refresh'); + this.cache = []; this.refresh(); this.runDataProvider.refresh(workspaceItem); }), vscode.commands.registerCommand('terraform.cloud.workspaces.resetProjectFilter', () => { this.reporter.sendTelemetryEvent('tfc-workspaces-filter-reset'); this.projectFilter = undefined; + this.cache = []; this.refresh(); }), vscode.commands.registerCommand( @@ -65,6 +67,7 @@ export class WorkspaceTreeDataProvider implements vscode.TreeDataProvider this.cache.length) { - x.push(new LoadMoreTreeItem()); + items.push(new LoadMoreTreeItem()); } - return x; + return items; } private async getWorkspaces(): Promise { @@ -284,7 +288,6 @@ export class LoadMoreTreeItem extends vscode.TreeItem { constructor() { super('Load more...', vscode.TreeItemCollapsibleState.None); - this.description = 'Load more workspaces'; this.iconPath = new vscode.ThemeIcon('ellipsis', new vscode.ThemeColor('charts.gray')); this.command = { command: 'terraform.cloud.workspaces.loadMore', @@ -311,6 +314,7 @@ export class WorkspaceTreeItem extends vscode.TreeItem { this.description = `[${this.projectName}]`; this.iconPath = GetRunStatusIcon(this.lastRun?.status); + this.contextValue = 'hasLink'; const lockedTxt = this.attributes.locked ? '$(lock) Locked' : '$(unlock) Unlocked'; const vscText =