From 9b567c4bac2391215174e679b09332dd6bdedd47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Kaan=20K=C3=B6se?= Date: Mon, 9 Mar 2026 14:18:13 +0100 Subject: [PATCH] Go back to welcome page when the last account is removed. --- Wino.Core.Domain/Enums/WinoPage.cs | 1 - Wino.Mail.ViewModels/MailAppShellViewModel.cs | 15 ++- Wino.Mail.ViewModels/WelcomePageViewModel.cs | 69 ----------- Wino.Mail.WinUI/App.xaml.cs | 20 ++- Wino.Mail.WinUI/Services/NavigationService.cs | 2 - .../Views/Abstract/WelcomePageAbstract.cs | 9 -- Wino.Mail.WinUI/Views/WelcomeHostPage.xaml.cs | 17 ++- Wino.Mail.WinUI/Views/WelcomePage.xaml | 114 ------------------ Wino.Mail.WinUI/Views/WelcomePage.xaml.cs | 25 ---- 9 files changed, 39 insertions(+), 233 deletions(-) delete mode 100644 Wino.Mail.ViewModels/WelcomePageViewModel.cs delete mode 100644 Wino.Mail.WinUI/Views/Abstract/WelcomePageAbstract.cs delete mode 100644 Wino.Mail.WinUI/Views/WelcomePage.xaml delete mode 100644 Wino.Mail.WinUI/Views/WelcomePage.xaml.cs diff --git a/Wino.Core.Domain/Enums/WinoPage.cs b/Wino.Core.Domain/Enums/WinoPage.cs index ddef5f89..15c3dedf 100644 --- a/Wino.Core.Domain/Enums/WinoPage.cs +++ b/Wino.Core.Domain/Enums/WinoPage.cs @@ -11,7 +11,6 @@ public enum WinoPage SettingsPage, ContactsPage, MailRenderingPage, - WelcomePage, AccountDetailsPage, MergedAccountDetailsPage, ManageAccountsPage, diff --git a/Wino.Mail.ViewModels/MailAppShellViewModel.cs b/Wino.Mail.ViewModels/MailAppShellViewModel.cs index b4a4ca3f..7580c175 100644 --- a/Wino.Mail.ViewModels/MailAppShellViewModel.cs +++ b/Wino.Mail.ViewModels/MailAppShellViewModel.cs @@ -427,7 +427,7 @@ public partial class MailAppShellViewModel : MailBaseViewModel, { if (PreferencesService.StartupEntityId == null) { - NavigationService.Navigate(WinoPage.WelcomePage); + NavigateToWelcomeWizard(); } else { @@ -451,8 +451,8 @@ public partial class MailAppShellViewModel : MailBaseViewModel, } else { - // Fallback to welcome page if startup entity is not found. - NavigationService.Navigate(WinoPage.WelcomePage); + // Fallback to the welcome wizard if startup entity is not found. + NavigateToWelcomeWizard(); } } } @@ -1038,10 +1038,17 @@ public partial class MailAppShellViewModel : MailBaseViewModel, else { await ExecuteUIThread(() => SelectedMenuItem = null); - NavigationService.Navigate(WinoPage.WelcomePage); + NavigateToWelcomeWizard(); } } + private void NavigateToWelcomeWizard() + => NavigationService.Navigate( + WinoPage.WelcomeHostPage, + null, + NavigationReferenceFrame.ShellFrame, + NavigationTransitionType.None); + private bool IsAccountCurrentlyLoaded(Guid accountId) { return latestSelectedAccountMenuItem?.HoldingAccounts?.Any(a => a.Id == accountId) == true; diff --git a/Wino.Mail.ViewModels/WelcomePageViewModel.cs b/Wino.Mail.ViewModels/WelcomePageViewModel.cs deleted file mode 100644 index 9a38fb66..00000000 --- a/Wino.Mail.ViewModels/WelcomePageViewModel.cs +++ /dev/null @@ -1,69 +0,0 @@ -using System; -using System.Collections.Generic; -using CommunityToolkit.Mvvm.ComponentModel; -using CommunityToolkit.Mvvm.Input; -using Wino.Core.Domain; -using Wino.Core.Domain.Interfaces; -using Wino.Core.Domain.Enums; -using Wino.Core.Domain.Models.Navigation; -using Wino.Core.Domain.Models.Updates; - -namespace Wino.Mail.ViewModels; - -public partial class WelcomePageViewModel : MailBaseViewModel -{ - private readonly IUpdateManager _updateManager; - private readonly INativeAppService _nativeAppService; - private readonly INavigationService _navigationService; - - [ObservableProperty] - public partial string VersionDisplay { get; set; } = string.Empty; - - [ObservableProperty] - public partial List UpdateSections { get; set; } = []; - - [ObservableProperty] - public partial List FeatureSections { get; set; } = []; - - public string GitHubUrl => "https://github.com/bkaankose/Wino-Mail/"; - public string PaypalUrl => "https://paypal.me/bkaankose?country.x=PL&locale.x=en_US"; - - public WelcomePageViewModel(IUpdateManager updateManager, - INativeAppService nativeAppService, - INavigationService navigationService) - { - _updateManager = updateManager; - _nativeAppService = nativeAppService; - _navigationService = navigationService; - } - - public override async void OnNavigatedTo(NavigationMode mode, object parameters) - { - base.OnNavigatedTo(mode, parameters); - - VersionDisplay = $"{Translator.SettingsAboutVersion}{_nativeAppService.GetFullAppVersion()}"; - - try - { - var updateNotes = await _updateManager.GetLatestUpdateNotesAsync(); - UpdateSections = updateNotes.Sections; - } - catch (Exception) - { - UpdateSections = []; - } - - try - { - FeatureSections = await _updateManager.GetFeaturesAsync(); - } - catch (Exception) - { - FeatureSections = []; - } - } - - [RelayCommand] - private void NavigateManageAccounts() - => _navigationService.Navigate(WinoPage.ManageAccountsPage, null, NavigationReferenceFrame.ShellFrame, NavigationTransitionType.DrillIn); -} diff --git a/Wino.Mail.WinUI/App.xaml.cs b/Wino.Mail.WinUI/App.xaml.cs index 6a85f851..25eec544 100644 --- a/Wino.Mail.WinUI/App.xaml.cs +++ b/Wino.Mail.WinUI/App.xaml.cs @@ -35,6 +35,7 @@ using Wino.Messaging.Client.Navigation; using Wino.Messaging.Server; using Wino.Messaging.UI; using Wino.Services; +using Wino.Views; using WinUIEx; namespace Wino.Mail.WinUI; @@ -145,7 +146,6 @@ public partial class App : WinoApplication, services.AddTransient(typeof(MailListPageViewModel)); services.AddTransient(typeof(MailRenderingPageViewModel)); services.AddTransient(typeof(AccountManagementViewModel)); - services.AddTransient(typeof(WelcomePageViewModel)); services.AddTransient(typeof(WelcomePageV2ViewModel)); services.AddTransient(typeof(ProviderSelectionPageViewModel)); services.AddTransient(typeof(AccountSetupProgressPageViewModel)); @@ -606,12 +606,22 @@ public partial class App : WinoApplication, var windowManager = Services.GetRequiredService(); MainWindow = windowManager.CreateWindow(WinoWindowKind.Welcome, () => new WelcomeWindow()); if (MainWindow is WelcomeWindow welcomeWindow) - windowManager.SetPrimaryNavigationFrame(WinoWindowKind.Welcome, welcomeWindow.GetRootFrame()); + { + var rootFrame = welcomeWindow.GetRootFrame(); + windowManager.SetPrimaryNavigationFrame(WinoWindowKind.Welcome, rootFrame); + + if (rootFrame.Content is WelcomeHostPage welcomeHostPage) + { + welcomeHostPage.ResetWizard(); + } + else + { + Services.GetRequiredService() + .Navigate(WinoPage.WelcomeHostPage, null, NavigationReferenceFrame.ShellFrame, NavigationTransitionType.None); + } + } InitializeNavigationDispatcher(); - - Services.GetRequiredService() - .Navigate(WinoPage.WelcomeHostPage, null, NavigationReferenceFrame.ShellFrame, NavigationTransitionType.None); } private void InitializeNavigationDispatcher() diff --git a/Wino.Mail.WinUI/Services/NavigationService.cs b/Wino.Mail.WinUI/Services/NavigationService.cs index 819976e7..5a0a1abb 100644 --- a/Wino.Mail.WinUI/Services/NavigationService.cs +++ b/Wino.Mail.WinUI/Services/NavigationService.cs @@ -44,7 +44,6 @@ public class NavigationService : NavigationServiceBase, INavigationService WinoPage.MailRenderingPage, WinoPage.ComposePage, WinoPage.IdlePage, - WinoPage.WelcomePage, WinoPage.WelcomePageV2, WinoPage.WelcomeHostPage, WinoPage.ProviderSelectionPage, @@ -109,7 +108,6 @@ public class NavigationService : NavigationServiceBase, INavigationService WinoPage.ComposePage => typeof(ComposePage), WinoPage.MailListPage => typeof(MailListPage), WinoPage.SettingsPage => typeof(SettingsPage), - WinoPage.WelcomePage => typeof(WelcomePage), WinoPage.WelcomePageV2 => typeof(WelcomePageV2), WinoPage.SettingOptionsPage => typeof(SettingOptionsPage), WinoPage.AppPreferencesPage => typeof(AppPreferencesPage), diff --git a/Wino.Mail.WinUI/Views/Abstract/WelcomePageAbstract.cs b/Wino.Mail.WinUI/Views/Abstract/WelcomePageAbstract.cs deleted file mode 100644 index 138e1f9b..00000000 --- a/Wino.Mail.WinUI/Views/Abstract/WelcomePageAbstract.cs +++ /dev/null @@ -1,9 +0,0 @@ -using Wino.Mail.WinUI; -using Wino.Mail.ViewModels; - -namespace Wino.Views.Abstract; - -public abstract class WelcomePageAbstract : BasePage -{ - -} diff --git a/Wino.Mail.WinUI/Views/WelcomeHostPage.xaml.cs b/Wino.Mail.WinUI/Views/WelcomeHostPage.xaml.cs index ef41e685..0adf616b 100644 --- a/Wino.Mail.WinUI/Views/WelcomeHostPage.xaml.cs +++ b/Wino.Mail.WinUI/Views/WelcomeHostPage.xaml.cs @@ -29,10 +29,7 @@ public sealed partial class WelcomeHostPage : WelcomeHostPageAbstract, WeakReferenceMessenger.Default.Register(this); WeakReferenceMessenger.Default.Register(this); - // Navigate to the welcome/get-started page without adding it to the wizard breadcrumb. - // Breadcrumb steps only start after the user clicks "Get Started". - var welcomePageType = ViewModel.NavigationService.GetPageType(WinoPage.WelcomePageV2); - WizardFrame.Navigate(welcomePageType, null, new SuppressNavigationTransitionInfo()); + ResetWizard(); } protected override void OnNavigatingFrom(NavigatingCancelEventArgs e) @@ -53,6 +50,18 @@ public sealed partial class WelcomeHostPage : WelcomeHostPageAbstract, GoBackFrame(); } + public void ResetWizard() + { + PageHistory.Clear(); + WizardFrame.BackStack.Clear(); + WizardFrame.ForwardStack.Clear(); + + // Navigate to the welcome/get-started page without adding it to the wizard breadcrumb. + // Breadcrumb steps only start after the user clicks "Get Started". + var welcomePageType = ViewModel.NavigationService.GetPageType(WinoPage.WelcomePageV2); + WizardFrame.Navigate(welcomePageType, null, new SuppressNavigationTransitionInfo()); + } + private void GoBackFrame() { BreadcrumbNavigationHelper.GoBack(WizardFrame, PageHistory, NavigationTransitionEffect.FromLeft); diff --git a/Wino.Mail.WinUI/Views/WelcomePage.xaml b/Wino.Mail.WinUI/Views/WelcomePage.xaml deleted file mode 100644 index 7faa66d3..00000000 --- a/Wino.Mail.WinUI/Views/WelcomePage.xaml +++ /dev/null @@ -1,114 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Wino.Mail.WinUI/Views/WelcomePage.xaml.cs b/Wino.Mail.WinUI/Views/WelcomePage.xaml.cs deleted file mode 100644 index 93440684..00000000 --- a/Wino.Mail.WinUI/Views/WelcomePage.xaml.cs +++ /dev/null @@ -1,25 +0,0 @@ -using Microsoft.UI.Xaml; -using Microsoft.UI.Xaml.Controls; -using CommunityToolkit.WinUI.Controls; -using Wino.Views.Abstract; - -namespace Wino.Views; - -public sealed partial class WelcomePage : WelcomePageAbstract -{ - public WelcomePage() - { - InitializeComponent(); - } - - private void OnTabSelectionChanged(object sender, SelectionChangedEventArgs e) - { - if (sender is not Segmented segmented) - return; - - bool isFeaturesTab = segmented.SelectedIndex == 0; - - FeaturesFlipView.Visibility = isFeaturesTab ? Visibility.Visible : Visibility.Collapsed; - WhatsNewFlipView.Visibility = isFeaturesTab ? Visibility.Collapsed : Visibility.Visible; - } -}