Fixed crashing issue with disposing composing page.
This commit is contained in:
@@ -214,7 +214,7 @@ namespace Wino.Mail.ViewModels
|
|||||||
IncludedAttachments.Add(viewModel);
|
IncludedAttachments.Add(viewModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task UpdateMimeChangesAsync()
|
public async Task UpdateMimeChangesAsync()
|
||||||
{
|
{
|
||||||
if (isUpdatingMimeBlocked || CurrentMimeMessage == null || ComposingAccount == null || CurrentMailDraftItem == null) return;
|
if (isUpdatingMimeBlocked || CurrentMimeMessage == null || ComposingAccount == null || CurrentMailDraftItem == null) return;
|
||||||
|
|
||||||
@@ -338,13 +338,12 @@ namespace Wino.Mail.ViewModels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async void OnNavigatedFrom(NavigationMode mode, object parameters)
|
public override void OnNavigatedFrom(NavigationMode mode, object parameters)
|
||||||
{
|
{
|
||||||
base.OnNavigatedFrom(mode, parameters);
|
base.OnNavigatedFrom(mode, parameters);
|
||||||
|
|
||||||
await UpdateMimeChangesAsync().ConfigureAwait(false);
|
/// Do not put any code here.
|
||||||
|
/// Make sure to use Page's OnNavigatedTo instead.
|
||||||
Messenger.Send(new KillChromiumRequested());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async void OnNavigatedTo(NavigationMode mode, object parameters)
|
public override async void OnNavigatedTo(NavigationMode mode, object parameters)
|
||||||
|
|||||||
@@ -39,8 +39,7 @@ namespace Wino.Views
|
|||||||
public sealed partial class ComposePage : ComposePageAbstract,
|
public sealed partial class ComposePage : ComposePageAbstract,
|
||||||
IRecipient<NavigationPaneModeChanged>,
|
IRecipient<NavigationPaneModeChanged>,
|
||||||
IRecipient<CreateNewComposeMailRequested>,
|
IRecipient<CreateNewComposeMailRequested>,
|
||||||
IRecipient<ApplicationThemeChanged>,
|
IRecipient<ApplicationThemeChanged>
|
||||||
IRecipient<KillChromiumRequested>
|
|
||||||
{
|
{
|
||||||
public bool IsComposerDarkMode
|
public bool IsComposerDarkMode
|
||||||
{
|
{
|
||||||
@@ -415,7 +414,6 @@ namespace Wino.Views
|
|||||||
return await ExecuteScriptFunctionAsync("initializeJodit", fonts, composerFont, composerFontSize, readerFont, readerFontSize);
|
return await ExecuteScriptFunctionAsync("initializeJodit", fonts, composerFont, composerFontSize, readerFont, readerFontSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void DisposeWebView2()
|
private void DisposeWebView2()
|
||||||
{
|
{
|
||||||
if (Chromium == null) return;
|
if (Chromium == null) return;
|
||||||
@@ -451,6 +449,7 @@ namespace Wino.Views
|
|||||||
Disposables.Add(GetSuggestionBoxDisposable(CCBox));
|
Disposables.Add(GetSuggestionBoxDisposable(CCBox));
|
||||||
Disposables.Add(GetSuggestionBoxDisposable(BccBox));
|
Disposables.Add(GetSuggestionBoxDisposable(BccBox));
|
||||||
|
|
||||||
|
Chromium.Unloaded += Chromium_Unloaded;
|
||||||
Chromium.CoreWebView2Initialized -= ChromiumInitialized;
|
Chromium.CoreWebView2Initialized -= ChromiumInitialized;
|
||||||
Chromium.CoreWebView2Initialized += ChromiumInitialized;
|
Chromium.CoreWebView2Initialized += ChromiumInitialized;
|
||||||
|
|
||||||
@@ -468,6 +467,11 @@ namespace Wino.Views
|
|||||||
IsComposerDarkMode = underlyingThemeService.IsUnderlyingThemeDark();
|
IsComposerDarkMode = underlyingThemeService.IsUnderlyingThemeDark();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Chromium_Unloaded(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private async void ChromiumInitialized(Microsoft.UI.Xaml.Controls.WebView2 sender, Microsoft.UI.Xaml.Controls.CoreWebView2InitializedEventArgs args)
|
private async void ChromiumInitialized(Microsoft.UI.Xaml.Controls.WebView2 sender, Microsoft.UI.Xaml.Controls.CoreWebView2InitializedEventArgs args)
|
||||||
{
|
{
|
||||||
var editorBundlePath = (await ViewModel.NativeAppService.GetEditorBundlePathAsync()).Replace("editor.html", string.Empty);
|
var editorBundlePath = (await ViewModel.NativeAppService.GetEditorBundlePathAsync()).Replace("editor.html", string.Empty);
|
||||||
@@ -692,8 +696,12 @@ namespace Wino.Views
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Receive(KillChromiumRequested message)
|
protected override async void OnNavigatingFrom(NavigatingCancelEventArgs e)
|
||||||
{
|
{
|
||||||
|
base.OnNavigatingFrom(e);
|
||||||
|
|
||||||
|
await ViewModel.UpdateMimeChangesAsync();
|
||||||
|
|
||||||
DisposeDisposables();
|
DisposeDisposables();
|
||||||
DisposeWebView2();
|
DisposeWebView2();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
namespace Wino.Messaging.Client.Mails
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Terminates all chromum instances.
|
|
||||||
/// </summary>
|
|
||||||
public record KillChromiumRequested;
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user