Skip to content

Commit 899f821

Browse files
committed
fix(quota-view): Refresh the view when opened
1 parent f135688 commit 899f821

File tree

1 file changed

+7
-28
lines changed

1 file changed

+7
-28
lines changed

src/ggshield-webview/gitguardian-quota-webview.ts

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,12 @@ export class GitGuardianQuotaWebviewProvider
2525
_token: vscode.CancellationToken
2626
) {
2727
this._view = webviewView;
28+
this.refresh();
2829

29-
webviewView.webview.options = {
30-
enableScripts: true,
31-
localResourceRoots: [
32-
vscode.Uri.joinPath(this._extensionUri, "media"),
33-
vscode.Uri.joinPath(this._extensionUri, "images"),
34-
],
35-
};
36-
37-
this.updateWebViewContent(webviewView);
38-
39-
webviewView.webview.onDidReceiveMessage(async (data) => {
40-
if (data.type === "authenticate") {
41-
vscode.commands.executeCommand("gitguardian.authenticate");
30+
webviewView.onDidChangeVisibility(() => {
31+
if (webviewView.visible) {
32+
// Refresh the quota when the view becomes visible (e.g., after being collapsed and reopened)
33+
this.refresh();
4234
}
4335
});
4436
}
@@ -55,24 +47,11 @@ export class GitGuardianQuotaWebviewProvider
5547

5648
private updateWebViewContent(webviewView?: vscode.WebviewView) {
5749
if (webviewView) {
58-
webviewView.webview.html = this.getHtmlForWebview(webviewView.webview);
50+
webviewView.webview.html = this.getHtmlForWebview();
5951
}
6052
}
6153

62-
private getHtmlForWebview(webview: vscode.Webview): string {
63-
const styleUri = webview.asWebviewUri(
64-
vscode.Uri.joinPath(this._extensionUri, "media", "main.css")
65-
);
66-
const logoUri = webview.asWebviewUri(
67-
vscode.Uri.joinPath(
68-
this._extensionUri,
69-
"images",
70-
"gitguardian-icon-primary700-background.svg"
71-
)
72-
);
73-
74-
this.updateQuota();
75-
54+
private getHtmlForWebview(): string {
7655
if (this.isLoading) {
7756
return `
7857
<!DOCTYPE html>

0 commit comments

Comments
 (0)