Skip to content

Fix/issues #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 21, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
cleanup webview dispose
  • Loading branch information
ShMcK committed Jul 20, 2019
commit e02c0e28f25c4bceb919d3a1434c3e07e8c7bf52
15 changes: 5 additions & 10 deletions src/editor/ReactWebView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ReactWebView {

// Listen for when the panel is disposed
// This happens when the user closes the panel or when the panel is closed programatically
this.panel.onDidDispose(() => this.dispose(), null, this.disposables)
this.panel.onDidDispose(this.dispose, this, this.disposables)

// Handle messages from the webview
const onReceive = (action: string | CR.Action) => {
Expand Down Expand Up @@ -91,16 +91,10 @@ class ReactWebView {
}
}

public dispose(): void {
private async dispose(): Promise<void> {
// Clean up our resources
this.panel.dispose()

while (this.disposables.length) {
const x = this.disposables.pop()
if (x) {
x.dispose()
}
}
Promise.all(this.disposables.map((x) => x.dispose()))
}

private createWebviewPanel(column: number): vscode.WebviewPanel {
Expand Down Expand Up @@ -153,14 +147,15 @@ class ReactWebView {
<meta name='theme-color' content='#000000'>
<title>React App</title>
<link rel='manifest' href='./manifest.json' />

<!-- TODO: load styles through package -->
<link rel='stylesheet' href='https://unpkg.com/@alifd/next/dist/next.css' />
<link rel='stylesheet' type='text/css' href='${styleUri}'>

<meta http-equiv='Content-Security-Policy' content="font-src *; img-src vscode-resource: https:; script-src 'nonce-${n1}' 'nonce-${n2}' 'nonce-${n3}'; style-src vscode-resource: 'unsafe-inline' http: https: data:;">
<base href='${vscode.Uri.file(path.join(this.extensionPath, 'build')).with({
scheme: 'vscode-resource',
})}/'>
<style></style>
</head>

<body>
Expand Down