Skip to content

Commit 2a4f594

Browse files
msivasubramaniaandatho7561
authored andcommitted
fixed the issue of second time opening the webview
Signed-off-by: msivasubramaniaan <msivasub@redhat.com>
1 parent 7f8e01e commit 2a4f594

File tree

2 files changed

+21
-23
lines changed

2 files changed

+21
-23
lines changed

src/webview/helm-chart/app/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,5 @@
4747
<body>
4848
<div class="box" id="root"></div>
4949
<script src="%SCRIPT%" ></script>
50-
<link rel="stylesheet" href="%STYLE%"></link>
5150
</body>
5251
</html>

src/webview/helm-chart/helmChartLoader.ts

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,12 @@ function helmChartMessageListener(event: any): void {
134134
}
135135

136136
export default class HelmChartLoader {
137-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
137+
138138
static get extensionPath() {
139139
return vscode.extensions.getExtension(ExtensionID).extensionPath
140140
}
141141

142-
// eslint-disable-next-line @typescript-eslint/require-await
143-
static async loadView(title: string, url?: string): Promise<vscode.WebviewPanel> {
142+
static async loadView(title: string): Promise<vscode.WebviewPanel> {
144143
const localResourceRoot = vscode.Uri.file(path.join(HelmChartLoader.extensionPath, 'out', 'helmChartViewer'));
145144
if (panel) {
146145
// If we already have a panel, show it in the target column
@@ -154,10 +153,11 @@ export default class HelmChartLoader {
154153
});
155154
panel.iconPath = vscode.Uri.file(path.join(HelmChartLoader.extensionPath, 'images/helm/helm.svg'));
156155
panel.webview.html = await loadWebviewHtml('helmChartViewer', panel);
156+
const messageDisposable = panel.webview.onDidReceiveMessage(helmChartMessageListener);
157157
panel.onDidDispose(() => {
158+
messageDisposable.dispose();
158159
panel = undefined;
159160
});
160-
panel.webview.onDidReceiveMessage(helmChartMessageListener);
161161
}
162162
await getHelmCharts();
163163
return panel;
@@ -170,25 +170,24 @@ export default class HelmChartLoader {
170170
}
171171

172172
async function getHelmCharts(): Promise<void> {
173-
if (helmCharts.length === 0) {
174-
const cliData = await Helm.getHelmRepos();
175-
if (!cliData.error && !cliData.stderr) {
176-
const helmRepos = JSON.parse(cliData.stdout) as HelmRepo[];
177-
void panel?.webview.postMessage(
178-
{
179-
action: 'getHelmRepos',
180-
data: {
181-
helmRepos
182-
}
173+
helmCharts.length = 0;
174+
const cliData = await Helm.getHelmRepos();
175+
if (!cliData.error && !cliData.stderr) {
176+
const helmRepos = JSON.parse(cliData.stdout) as HelmRepo[];
177+
void panel?.webview.postMessage(
178+
{
179+
action: 'getHelmRepos',
180+
data: {
181+
helmRepos
183182
}
184-
);
185-
helmRepos.forEach((helmRepo: HelmRepo) => {
186-
let url = helmRepo.url;
187-
url = url.endsWith('/') ? url : url.concat('/');
188-
url = url.concat('index.yaml');
189-
void fetchURL(helmRepo, url);
190-
});
191-
}
183+
}
184+
);
185+
helmRepos.forEach((helmRepo: HelmRepo) => {
186+
let url = helmRepo.url;
187+
url = url.endsWith('/') ? url : url.concat('/');
188+
url = url.concat('index.yaml');
189+
void fetchURL(helmRepo, url);
190+
});
192191
}
193192
}
194193

0 commit comments

Comments
 (0)