Misc fixes.
This commit is contained in:
@@ -2,18 +2,12 @@
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using CommunityToolkit.Mvvm.Messaging;
|
using CommunityToolkit.Mvvm.Messaging;
|
||||||
using Wino.Core.Domain.Entities.Shared;
|
|
||||||
using Wino.Core.Domain.Interfaces;
|
using Wino.Core.Domain.Interfaces;
|
||||||
using Wino.Core.Domain.Models.Navigation;
|
using Wino.Core.Domain.Models.Navigation;
|
||||||
using Wino.Messaging.UI;
|
|
||||||
|
|
||||||
namespace Wino.Core.ViewModels;
|
namespace Wino.Core.ViewModels;
|
||||||
|
|
||||||
public class CoreBaseViewModel : ObservableRecipient,
|
public class CoreBaseViewModel : ObservableRecipient, INavigationAware
|
||||||
INavigationAware,
|
|
||||||
IRecipient<AccountCreatedMessage>,
|
|
||||||
IRecipient<AccountRemovedMessage>,
|
|
||||||
IRecipient<AccountUpdatedMessage>
|
|
||||||
{
|
{
|
||||||
private IDispatcher _dispatcher;
|
private IDispatcher _dispatcher;
|
||||||
public 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();
|
RegisterRecipients();
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void OnNavigatedFrom(NavigationMode mode, object parameters)
|
public virtual void OnNavigatedFrom(NavigationMode mode, object parameters)
|
||||||
{
|
{
|
||||||
UnregisterRecipients();
|
UnregisterRecipients();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,12 +53,4 @@ public class CoreBaseViewModel : ObservableRecipient,
|
|||||||
/// Unregister message recipients for this view model. Override to unregister specific message types.
|
/// Unregister message recipients for this view model. Override to unregister specific message types.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected virtual void UnregisterRecipients() { }
|
protected virtual void UnregisterRecipients() { }
|
||||||
|
|
||||||
protected virtual void OnAccountCreated(MailAccount createdAccount) { }
|
|
||||||
protected virtual void OnAccountRemoved(MailAccount removedAccount) { }
|
|
||||||
protected virtual void OnAccountUpdated(MailAccount updatedAccount) { }
|
|
||||||
|
|
||||||
void IRecipient<AccountCreatedMessage>.Receive(AccountCreatedMessage message) => OnAccountCreated(message.Account);
|
|
||||||
void IRecipient<AccountRemovedMessage>.Receive(AccountRemovedMessage message) => OnAccountRemoved(message.Account);
|
|
||||||
void IRecipient<AccountUpdatedMessage>.Receive(AccountUpdatedMessage message) => OnAccountUpdated(message.Account);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,33 +8,6 @@
|
|||||||
<UseWinUI>true</UseWinUI>
|
<UseWinUI>true</UseWinUI>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="AppThemes\Acrylic.xaml">
|
|
||||||
<Generator>MSBuild:Compile</Generator>
|
|
||||||
</Content>
|
|
||||||
<Content Include="AppThemes\Clouds.xaml">
|
|
||||||
<Generator>MSBuild:Compile</Generator>
|
|
||||||
</Content>
|
|
||||||
<Content Include="AppThemes\Custom.xaml">
|
|
||||||
<Generator>MSBuild:Compile</Generator>
|
|
||||||
</Content>
|
|
||||||
<Content Include="AppThemes\Forest.xaml">
|
|
||||||
<Generator>MSBuild:Compile</Generator>
|
|
||||||
</Content>
|
|
||||||
<Content Include="AppThemes\Garden.xaml">
|
|
||||||
<Generator>MSBuild:Compile</Generator>
|
|
||||||
</Content>
|
|
||||||
<Content Include="AppThemes\Default.xaml">
|
|
||||||
<Generator>MSBuild:Compile</Generator>
|
|
||||||
</Content>
|
|
||||||
<Content Include="AppThemes\Nighty.xaml">
|
|
||||||
<Generator>MSBuild:Compile</Generator>
|
|
||||||
</Content>
|
|
||||||
<Content Include="AppThemes\Snowflake.xaml">
|
|
||||||
<Generator>MSBuild:Compile</Generator>
|
|
||||||
</Content>
|
|
||||||
<Content Include="AppThemes\TestTheme.xaml">
|
|
||||||
<Generator>MSBuild:Compile</Generator>
|
|
||||||
</Content>
|
|
||||||
<Content Include="Assets\FileTypes\type_archive.png" />
|
<Content Include="Assets\FileTypes\type_archive.png" />
|
||||||
<Content Include="Assets\FileTypes\type_audio.png" />
|
<Content Include="Assets\FileTypes\type_audio.png" />
|
||||||
<Content Include="Assets\FileTypes\type_executable.png" />
|
<Content Include="Assets\FileTypes\type_executable.png" />
|
||||||
|
|||||||
@@ -37,7 +37,10 @@ public partial class AppShellViewModel : MailBaseViewModel,
|
|||||||
IRecipient<AccountMenuItemsReordered>,
|
IRecipient<AccountMenuItemsReordered>,
|
||||||
IRecipient<AccountSynchronizationProgressUpdatedMessage>,
|
IRecipient<AccountSynchronizationProgressUpdatedMessage>,
|
||||||
IRecipient<NavigateAppPreferencesRequested>,
|
IRecipient<NavigateAppPreferencesRequested>,
|
||||||
IRecipient<AccountFolderConfigurationUpdated>
|
IRecipient<AccountFolderConfigurationUpdated>,
|
||||||
|
IRecipient<AccountRemovedMessage>,
|
||||||
|
IRecipient<AccountUpdatedMessage>,
|
||||||
|
IRecipient<AccountCreatedMessage>
|
||||||
{
|
{
|
||||||
#region Menu Items
|
#region Menu Items
|
||||||
|
|
||||||
@@ -835,48 +838,7 @@ public partial class AppShellViewModel : MailBaseViewModel,
|
|||||||
await _winoRequestDelegator.ExecuteAsync(draftPreparationRequest);
|
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.
|
// TODO: Handle by messaging.
|
||||||
private async Task SetAccountAttentionAsync(Guid accountId, AccountAttentionReason reason)
|
private async Task SetAccountAttentionAsync(Guid accountId, AccountAttentionReason reason)
|
||||||
@@ -1041,7 +1003,10 @@ public partial class AppShellViewModel : MailBaseViewModel,
|
|||||||
protected override void RegisterRecipients()
|
protected override void RegisterRecipients()
|
||||||
{
|
{
|
||||||
base.RegisterRecipients();
|
base.RegisterRecipients();
|
||||||
|
|
||||||
|
Messenger.Register<AccountCreatedMessage>(this);
|
||||||
|
Messenger.Register<AccountRemovedMessage>(this);
|
||||||
|
Messenger.Register<AccountUpdatedMessage>(this);
|
||||||
Messenger.Register<NavigateManageAccountsRequested>(this);
|
Messenger.Register<NavigateManageAccountsRequested>(this);
|
||||||
Messenger.Register<MailtoProtocolMessageRequested>(this);
|
Messenger.Register<MailtoProtocolMessageRequested>(this);
|
||||||
Messenger.Register<RefreshUnreadCountsMessage>(this);
|
Messenger.Register<RefreshUnreadCountsMessage>(this);
|
||||||
@@ -1057,7 +1022,7 @@ public partial class AppShellViewModel : MailBaseViewModel,
|
|||||||
protected override void UnregisterRecipients()
|
protected override void UnregisterRecipients()
|
||||||
{
|
{
|
||||||
base.UnregisterRecipients();
|
base.UnregisterRecipients();
|
||||||
|
|
||||||
Messenger.Unregister<NavigateManageAccountsRequested>(this);
|
Messenger.Unregister<NavigateManageAccountsRequested>(this);
|
||||||
Messenger.Unregister<MailtoProtocolMessageRequested>(this);
|
Messenger.Unregister<MailtoProtocolMessageRequested>(this);
|
||||||
Messenger.Unregister<RefreshUnreadCountsMessage>(this);
|
Messenger.Unregister<RefreshUnreadCountsMessage>(this);
|
||||||
@@ -1069,4 +1034,49 @@ public partial class AppShellViewModel : MailBaseViewModel,
|
|||||||
Messenger.Unregister<NavigateAppPreferencesRequested>(this);
|
Messenger.Unregister<NavigateAppPreferencesRequested>(this);
|
||||||
Messenger.Unregister<AccountFolderConfigurationUpdated>(this);
|
Messenger.Unregister<AccountFolderConfigurationUpdated>(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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
<Identity
|
<Identity
|
||||||
Name="58272BurakKSE.WinoMailPreview"
|
Name="58272BurakKSE.WinoMailPreview"
|
||||||
Publisher="CN=51FBDAF3-E212-4149-89A2-A2636B3BC911"
|
Publisher="CN=51FBDAF3-E212-4149-89A2-A2636B3BC911"
|
||||||
Version="0.0.1.0" />
|
Version="0.0.3.0" />
|
||||||
|
|
||||||
<mp:PhoneIdentity PhoneProductId="3879fcfb-a561-4599-9103-e0c9b35a271f" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
|
<mp:PhoneIdentity PhoneProductId="3879fcfb-a561-4599-9103-e0c9b35a271f" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
|
||||||
|
|
||||||
|
|||||||
@@ -252,5 +252,13 @@
|
|||||||
<PublishTrimmed Condition="'$(Configuration)' == 'Debug'">False</PublishTrimmed>
|
<PublishTrimmed Condition="'$(Configuration)' == 'Debug'">False</PublishTrimmed>
|
||||||
<PublishTrimmed Condition="'$(Configuration)' != 'Debug'">True</PublishTrimmed>
|
<PublishTrimmed Condition="'$(Configuration)' != 'Debug'">True</PublishTrimmed>
|
||||||
<GenerateTemporaryStoreCertificate>True</GenerateTemporaryStoreCertificate>
|
<GenerateTemporaryStoreCertificate>True</GenerateTemporaryStoreCertificate>
|
||||||
|
<GenerateAppInstallerFile>False</GenerateAppInstallerFile>
|
||||||
|
<AppxPackageSigningEnabled>False</AppxPackageSigningEnabled>
|
||||||
|
<AppxPackageSigningTimestampDigestAlgorithm>SHA256</AppxPackageSigningTimestampDigestAlgorithm>
|
||||||
|
<AppxAutoIncrementPackageRevision>True</AppxAutoIncrementPackageRevision>
|
||||||
|
<GenerateTestArtifacts>True</GenerateTestArtifacts>
|
||||||
|
<AppxBundle>Always</AppxBundle>
|
||||||
|
<AppxBundlePlatforms>x64</AppxBundlePlatforms>
|
||||||
|
<HoursBetweenUpdateChecks>0</HoursBetweenUpdateChecks>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
+1
-1
@@ -29,7 +29,7 @@
|
|||||||
<Platform Solution="*|x86" Project="x86" />
|
<Platform Solution="*|x86" Project="x86" />
|
||||||
</Project>
|
</Project>
|
||||||
<Project Path="Wino.Core.WinUI/Wino.Core.WinUI.csproj" Id="fbb6acb5-7efb-4ac9-beee-adac47a4527a">
|
<Project Path="Wino.Core.WinUI/Wino.Core.WinUI.csproj" Id="fbb6acb5-7efb-4ac9-beee-adac47a4527a">
|
||||||
<Platform Solution="Debug|x64" Project="x64" />
|
<Platform Solution="*|x64" Project="x64" />
|
||||||
</Project>
|
</Project>
|
||||||
<Project Path="Wino.Core/Wino.Core.csproj">
|
<Project Path="Wino.Core/Wino.Core.csproj">
|
||||||
<Platform Solution="*|arm64" Project="arm64" />
|
<Platform Solution="*|arm64" Project="arm64" />
|
||||||
|
|||||||
Reference in New Issue
Block a user