From 6c37c9e78667869a6f464e83ae48870273d8fd1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Kaan=20K=C3=B6se?= Date: Sat, 25 Oct 2025 10:22:35 +0200 Subject: [PATCH] Misc fixes. --- Wino.Core.ViewModels/CoreBaseViewModel.cs | 24 ++---- Wino.Core.WinUI/Wino.Core.WinUI.csproj | 27 ------- Wino.Mail.ViewModels/AppShellViewModel.cs | 98 +++++++++++++---------- Wino.Mail.WinUI/Package.appxmanifest | 2 +- Wino.Mail.WinUI/Wino.Mail.WinUI.csproj | 8 ++ WinoMail.slnx | 2 +- 6 files changed, 69 insertions(+), 92 deletions(-) diff --git a/Wino.Core.ViewModels/CoreBaseViewModel.cs b/Wino.Core.ViewModels/CoreBaseViewModel.cs index 764b4235..4c3ec6c4 100644 --- a/Wino.Core.ViewModels/CoreBaseViewModel.cs +++ b/Wino.Core.ViewModels/CoreBaseViewModel.cs @@ -2,18 +2,12 @@ using System.Threading.Tasks; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Messaging; -using Wino.Core.Domain.Entities.Shared; using Wino.Core.Domain.Interfaces; using Wino.Core.Domain.Models.Navigation; -using Wino.Messaging.UI; namespace Wino.Core.ViewModels; -public class CoreBaseViewModel : ObservableRecipient, - INavigationAware, - IRecipient, - IRecipient, - IRecipient +public class CoreBaseViewModel : ObservableRecipient, INavigationAware { private IDispatcher _dispatcher; public IDispatcher Dispatcher @@ -33,13 +27,13 @@ public class CoreBaseViewModel : ObservableRecipient, } } - public virtual void OnNavigatedTo(NavigationMode mode, object parameters) - { + public virtual void OnNavigatedTo(NavigationMode mode, object parameters) + { RegisterRecipients(); } - public virtual void OnNavigatedFrom(NavigationMode mode, object parameters) - { + public virtual void OnNavigatedFrom(NavigationMode mode, object parameters) + { UnregisterRecipients(); } @@ -59,12 +53,4 @@ public class CoreBaseViewModel : ObservableRecipient, /// Unregister message recipients for this view model. Override to unregister specific message types. /// protected virtual void UnregisterRecipients() { } - - protected virtual void OnAccountCreated(MailAccount createdAccount) { } - protected virtual void OnAccountRemoved(MailAccount removedAccount) { } - protected virtual void OnAccountUpdated(MailAccount updatedAccount) { } - - void IRecipient.Receive(AccountCreatedMessage message) => OnAccountCreated(message.Account); - void IRecipient.Receive(AccountRemovedMessage message) => OnAccountRemoved(message.Account); - void IRecipient.Receive(AccountUpdatedMessage message) => OnAccountUpdated(message.Account); } diff --git a/Wino.Core.WinUI/Wino.Core.WinUI.csproj b/Wino.Core.WinUI/Wino.Core.WinUI.csproj index 8398273b..b53a4f76 100644 --- a/Wino.Core.WinUI/Wino.Core.WinUI.csproj +++ b/Wino.Core.WinUI/Wino.Core.WinUI.csproj @@ -8,33 +8,6 @@ true - - MSBuild:Compile - - - MSBuild:Compile - - - MSBuild:Compile - - - MSBuild:Compile - - - MSBuild:Compile - - - MSBuild:Compile - - - MSBuild:Compile - - - MSBuild:Compile - - - MSBuild:Compile - diff --git a/Wino.Mail.ViewModels/AppShellViewModel.cs b/Wino.Mail.ViewModels/AppShellViewModel.cs index 6862b4ba..5fc8edb1 100644 --- a/Wino.Mail.ViewModels/AppShellViewModel.cs +++ b/Wino.Mail.ViewModels/AppShellViewModel.cs @@ -37,7 +37,10 @@ public partial class AppShellViewModel : MailBaseViewModel, IRecipient, IRecipient, IRecipient, - IRecipient + IRecipient, + IRecipient, + IRecipient, + IRecipient { #region Menu Items @@ -835,48 +838,7 @@ public partial class AppShellViewModel : MailBaseViewModel, await _winoRequestDelegator.ExecuteAsync(draftPreparationRequest); } - protected override async void OnAccountUpdated(MailAccount updatedAccount) - { - await ExecuteUIThread(() => - { - if (MenuItems.TryGetAccountMenuItem(updatedAccount.Id, out IAccountMenuItem foundAccountMenuItem)) - { - foundAccountMenuItem.UpdateAccount(updatedAccount); - } - }); - } - protected override void OnAccountRemoved(MailAccount removedAccount) - => Messenger.Send(new AccountsMenuRefreshRequested(false)); - - protected override async void OnAccountCreated(MailAccount createdAccount) - { - latestSelectedAccountMenuItem = null; - - await RecreateMenuItemsAsync(); - - if (!MenuItems.TryGetAccountMenuItem(createdAccount.Id, out IAccountMenuItem createdMenuItem)) return; - - await ChangeLoadedAccountAsync(createdMenuItem); - - // Each created account should start a new synchronization automatically. - var options = new MailSynchronizationOptions() - { - AccountId = createdAccount.Id, - Type = MailSynchronizationType.FullFolders, - }; - - Messenger.Send(new NewMailSynchronizationRequested(options)); - - try - { - await _nativeAppService.PinAppToTaskbarAsync(); - } - catch (Exception ex) - { - Log.Error(ex, "Failed to pin Wino to taskbar."); - } - } // TODO: Handle by messaging. private async Task SetAccountAttentionAsync(Guid accountId, AccountAttentionReason reason) @@ -1041,7 +1003,10 @@ public partial class AppShellViewModel : MailBaseViewModel, protected override void RegisterRecipients() { base.RegisterRecipients(); - + + Messenger.Register(this); + Messenger.Register(this); + Messenger.Register(this); Messenger.Register(this); Messenger.Register(this); Messenger.Register(this); @@ -1057,7 +1022,7 @@ public partial class AppShellViewModel : MailBaseViewModel, protected override void UnregisterRecipients() { base.UnregisterRecipients(); - + Messenger.Unregister(this); Messenger.Unregister(this); Messenger.Unregister(this); @@ -1069,4 +1034,49 @@ public partial class AppShellViewModel : MailBaseViewModel, Messenger.Unregister(this); Messenger.Unregister(this); } + + public void Receive(AccountRemovedMessage message) => Messenger.Send(new AccountsMenuRefreshRequested(false)); + + public async void Receive(AccountCreatedMessage message) + { + var createdAccount = message.Account; + latestSelectedAccountMenuItem = null; + + await RecreateMenuItemsAsync(); + + if (!MenuItems.TryGetAccountMenuItem(createdAccount.Id, out IAccountMenuItem createdMenuItem)) return; + + await ChangeLoadedAccountAsync(createdMenuItem); + + // Each created account should start a new synchronization automatically. + var options = new MailSynchronizationOptions() + { + AccountId = createdAccount.Id, + Type = MailSynchronizationType.FullFolders, + }; + + Messenger.Send(new NewMailSynchronizationRequested(options)); + + try + { + await _nativeAppService.PinAppToTaskbarAsync(); + } + catch (Exception ex) + { + Log.Error(ex, "Failed to pin Wino to taskbar."); + } + } + + public async void Receive(AccountUpdatedMessage message) + { + var updatedAccount = message.Account; + + await ExecuteUIThread(() => + { + if (MenuItems.TryGetAccountMenuItem(updatedAccount.Id, out IAccountMenuItem foundAccountMenuItem)) + { + foundAccountMenuItem.UpdateAccount(updatedAccount); + } + }); + } } diff --git a/Wino.Mail.WinUI/Package.appxmanifest b/Wino.Mail.WinUI/Package.appxmanifest index bfd12303..6df5b884 100644 --- a/Wino.Mail.WinUI/Package.appxmanifest +++ b/Wino.Mail.WinUI/Package.appxmanifest @@ -20,7 +20,7 @@ + Version="0.0.3.0" /> diff --git a/Wino.Mail.WinUI/Wino.Mail.WinUI.csproj b/Wino.Mail.WinUI/Wino.Mail.WinUI.csproj index 8f262f1d..f1f7acd4 100644 --- a/Wino.Mail.WinUI/Wino.Mail.WinUI.csproj +++ b/Wino.Mail.WinUI/Wino.Mail.WinUI.csproj @@ -252,5 +252,13 @@ False True True + False + False + SHA256 + True + True + Always + x64 + 0 \ No newline at end of file diff --git a/WinoMail.slnx b/WinoMail.slnx index 33651ef0..e632e793 100644 --- a/WinoMail.slnx +++ b/WinoMail.slnx @@ -29,7 +29,7 @@ - +