Skip to content

Commit

Permalink
guard with isInitialized
Browse files Browse the repository at this point in the history
  • Loading branch information
abeatrix committed Aug 13, 2024
1 parent 4b886b8 commit ca20f1a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Cody.UI/Controls/WebView2Dev.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public partial class WebView2Dev : UserControl

private static WebviewController _controller = new WebviewController();

private bool isInitialized = false;

public WebView2Dev()
{
Expand All @@ -37,8 +38,12 @@ public static WebviewController InitializeController(string themeScript)

private async Task InitializeWebView()
{
var env = await CreateWebView2Environment();
await webView.EnsureCoreWebView2Async(env);
if (isInitialized != true)
{
var env = await CreateWebView2Environment();
await webView.EnsureCoreWebView2Async(env);
isInitialized = true;
}

_controller.WebViewMessageReceived += (sender, message) => SendMessage?.Execute(message);

Expand Down

0 comments on commit ca20f1a

Please sign in to comment.