feat: create cloud-free Wino Mail fork
This commit is contained in:
@@ -34,16 +34,12 @@ public sealed partial class ShellWindow : WindowEx, IWinoShellWindow,
|
||||
IRecipient<InfoBarMessageRequested>,
|
||||
IRecipient<TitleBarShellContentUpdated>,
|
||||
IRecipient<SynchronizationActionsAdded>,
|
||||
IRecipient<SynchronizationActionsCompleted>,
|
||||
IRecipient<WinoAccountProfileUpdatedMessage>,
|
||||
IRecipient<WinoAccountProfileDeletedMessage>
|
||||
IRecipient<SynchronizationActionsCompleted>
|
||||
{
|
||||
private bool _allowClose;
|
||||
public IStatePersistanceService StatePersistanceService { get; } = WinoApplication.Current.Services.GetService<IStatePersistanceService>() ?? throw new Exception("StatePersistanceService not registered in DI container.");
|
||||
public IPreferencesService PreferencesService { get; } = WinoApplication.Current.Services.GetService<IPreferencesService>() ?? throw new Exception("PreferencesService not registered in DI container.");
|
||||
public INavigationService NavigationService { get; } = WinoApplication.Current.Services.GetService<INavigationService>() ?? throw new Exception("NavigationService not registered in DI container.");
|
||||
private IMailDialogService MailDialogService { get; } = WinoApplication.Current.Services.GetRequiredService<IMailDialogService>();
|
||||
private IWinoAccountProfileService WinoAccountProfileService { get; } = WinoApplication.Current.Services.GetRequiredService<IWinoAccountProfileService>();
|
||||
|
||||
public ObservableCollection<SynchronizationActionItem> SyncActionItems { get; } = new();
|
||||
private bool _calendarReminderServerStartAttempted;
|
||||
@@ -210,15 +206,6 @@ public sealed partial class ShellWindow : WindowEx, IWinoShellWindow,
|
||||
});
|
||||
}
|
||||
|
||||
public void Receive(WinoAccountProfileUpdatedMessage message)
|
||||
{
|
||||
DispatcherQueue.TryEnqueue(() => UpdateWinoAccountState(message.Account));
|
||||
}
|
||||
|
||||
public void Receive(WinoAccountProfileDeletedMessage message)
|
||||
{
|
||||
DispatcherQueue.TryEnqueue(() => UpdateWinoAccountState(null));
|
||||
}
|
||||
|
||||
private void UpdateSyncStatusVisibility()
|
||||
{
|
||||
@@ -426,8 +413,6 @@ public sealed partial class ShellWindow : WindowEx, IWinoShellWindow,
|
||||
WeakReferenceMessenger.Default.Register<InfoBarMessageRequested>(this);
|
||||
WeakReferenceMessenger.Default.Register<SynchronizationActionsAdded>(this);
|
||||
WeakReferenceMessenger.Default.Register<SynchronizationActionsCompleted>(this);
|
||||
WeakReferenceMessenger.Default.Register<WinoAccountProfileUpdatedMessage>(this);
|
||||
WeakReferenceMessenger.Default.Register<WinoAccountProfileDeletedMessage>(this);
|
||||
}
|
||||
|
||||
private void UnregisterRecipients()
|
||||
@@ -437,8 +422,6 @@ public sealed partial class ShellWindow : WindowEx, IWinoShellWindow,
|
||||
WeakReferenceMessenger.Default.Unregister<InfoBarMessageRequested>(this);
|
||||
WeakReferenceMessenger.Default.Unregister<SynchronizationActionsAdded>(this);
|
||||
WeakReferenceMessenger.Default.Unregister<SynchronizationActionsCompleted>(this);
|
||||
WeakReferenceMessenger.Default.Unregister<WinoAccountProfileUpdatedMessage>(this);
|
||||
WeakReferenceMessenger.Default.Unregister<WinoAccountProfileDeletedMessage>(this);
|
||||
}
|
||||
|
||||
private void ShowInfoBarMessage(InfoBarMessageRequested message)
|
||||
@@ -465,29 +448,6 @@ public sealed partial class ShellWindow : WindowEx, IWinoShellWindow,
|
||||
});
|
||||
}
|
||||
|
||||
private void UpdateWinoAccountState(WinoAccount? account)
|
||||
{
|
||||
var isSignedIn = account != null;
|
||||
|
||||
WinoAccountSignedOutView.Visibility = isSignedIn ? Visibility.Collapsed : Visibility.Visible;
|
||||
WinoAccountSignedInView.Visibility = isSignedIn ? Visibility.Visible : Visibility.Collapsed;
|
||||
|
||||
WinoAccountButtonPicture.Visibility = isSignedIn ? Visibility.Visible : Visibility.Collapsed;
|
||||
WinoAccountSignedOutIcon.Visibility = isSignedIn ? Visibility.Collapsed : Visibility.Visible;
|
||||
|
||||
var initials = GetInitials(account?.Email);
|
||||
|
||||
WinoAccountButtonPicture.Initials = initials;
|
||||
WinoAccountFlyoutPicture.Initials = initials;
|
||||
WinoAccountButtonPicture.DisplayName = account?.Email ?? Translator.WinoAccount_Titlebar_SignedOutTitle;
|
||||
WinoAccountFlyoutPicture.DisplayName = account?.Email ?? Translator.WinoAccount_Titlebar_SignedOutTitle;
|
||||
|
||||
WinoAccountFlyoutEmailText.Text = account?.Email ?? string.Empty;
|
||||
WinoAccountFlyoutStatusText.Text = account == null
|
||||
? string.Empty
|
||||
: string.Format(Translator.WinoAccount_Titlebar_SignedInStatus, account.AccountStatus);
|
||||
}
|
||||
|
||||
private static string GetInitials(string? email)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(email))
|
||||
@@ -510,50 +470,5 @@ public sealed partial class ShellWindow : WindowEx, IWinoShellWindow,
|
||||
return string.Concat(segments.Select(segment => char.ToUpperInvariant(segment[0])));
|
||||
}
|
||||
|
||||
private async void RegisterWinoAccountClicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
WinoAccountFlyout.Hide();
|
||||
var account = await MailDialogService.ShowWinoAccountRegistrationDialogAsync();
|
||||
if (account != null)
|
||||
{
|
||||
ShowInfoBarMessage(new InfoBarMessageRequested(
|
||||
InfoBarMessageType.Success,
|
||||
Translator.GeneralTitle_Info,
|
||||
string.Format(Translator.WinoAccount_RegisterSuccessMessage, account.Email)));
|
||||
}
|
||||
}
|
||||
|
||||
private async void LoginWinoAccountClicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
WinoAccountFlyout.Hide();
|
||||
var account = await MailDialogService.ShowWinoAccountLoginDialogAsync();
|
||||
if (account != null)
|
||||
{
|
||||
ShowInfoBarMessage(new InfoBarMessageRequested(
|
||||
InfoBarMessageType.Success,
|
||||
Translator.GeneralTitle_Info,
|
||||
string.Format(Translator.WinoAccount_LoginSuccessMessage, account.Email)));
|
||||
}
|
||||
}
|
||||
|
||||
private async void SignOutWinoAccountClicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var activeAccount = await WinoAccountProfileService.GetActiveAccountAsync();
|
||||
if (activeAccount == null)
|
||||
{
|
||||
ShowInfoBarMessage(new InfoBarMessageRequested(
|
||||
InfoBarMessageType.Warning,
|
||||
Translator.GeneralTitle_Info,
|
||||
Translator.WinoAccount_SignOut_NoAccountMessage));
|
||||
return;
|
||||
}
|
||||
|
||||
await WinoAccountProfileService.SignOutAsync();
|
||||
|
||||
ShowInfoBarMessage(new InfoBarMessageRequested(
|
||||
InfoBarMessageType.Success,
|
||||
Translator.GeneralTitle_Info,
|
||||
string.Format(Translator.WinoAccount_SignOut_SuccessMessage, activeAccount.Email)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user