From da2a58a88b17d7d6504d241640507bb4efa976b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Kaan=20K=C3=B6se?= Date: Sun, 22 Dec 2024 00:59:59 +0100 Subject: [PATCH] Fix focus-other toggle for Live accounts. --- Wino.Core.Domain/Interfaces/IAccountService.cs | 2 +- Wino.Mail.ViewModels/MailListPageViewModel.cs | 13 +++++++------ Wino.Services/AccountService.cs | 6 ++++++ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Wino.Core.Domain/Interfaces/IAccountService.cs b/Wino.Core.Domain/Interfaces/IAccountService.cs index aac9b19b..8a226f25 100644 --- a/Wino.Core.Domain/Interfaces/IAccountService.cs +++ b/Wino.Core.Domain/Interfaces/IAccountService.cs @@ -155,6 +155,6 @@ namespace Wino.Core.Domain.Interfaces /// Account id. /// Primary alias for the account. Task GetPrimaryAccountAliasAsync(Guid accountId); - + Task IsAccountFocusedEnabledAsync(Guid accountId); } } diff --git a/Wino.Mail.ViewModels/MailListPageViewModel.cs b/Wino.Mail.ViewModels/MailListPageViewModel.cs index a6de7bfe..64154835 100644 --- a/Wino.Mail.ViewModels/MailListPageViewModel.cs +++ b/Wino.Mail.ViewModels/MailListPageViewModel.cs @@ -72,6 +72,7 @@ namespace Wino.Mail.ViewModels public IPreferencesService PreferencesService { get; } public IThemeService ThemeService { get; } + private readonly IAccountService _accountService; private readonly IMailService _mailService; private readonly IFolderService _folderService; private readonly IThreadingStrategyProvider _threadingStrategyProvider; @@ -147,6 +148,7 @@ namespace Wino.Mail.ViewModels public MailListPageViewModel(IMailDialogService dialogService, INavigationService navigationService, + IAccountService accountService, IMailService mailService, IStatePersistanceService statePersistenceService, IFolderService folderService, @@ -163,7 +165,7 @@ namespace Wino.Mail.ViewModels _winoServerConnectionManager = winoServerConnectionManager; StatePersistenceService = statePersistenceService; NavigationService = navigationService; - + _accountService = accountService; _mailService = mailService; _folderService = folderService; _threadingStrategyProvider = threadingStrategyProvider; @@ -376,7 +378,7 @@ namespace Wino.Mail.ViewModels SetupTopBarActions(); } - private void UpdateFolderPivots() + private async Task UpdateFolderPivotsAsync() { PivotFolders.Clear(); SelectedFolderPivot = null; @@ -393,8 +395,7 @@ namespace Wino.Mail.ViewModels { var parentAccount = singleFolderMenuItem.ParentAccount; - bool isAccountSupportsFocusedInbox = parentAccount.Preferences.IsFocusedInboxEnabled != null; - bool isFocusedInboxEnabled = isAccountSupportsFocusedInbox && parentAccount.Preferences.IsFocusedInboxEnabled.GetValueOrDefault(); + bool isFocusedInboxEnabled = await _accountService.IsAccountFocusedEnabledAsync(parentAccount.Id); bool isInboxFolder = ActiveFolder.SpecialFolderType == SpecialFolderType.Inbox; // Folder supports Focused - Other @@ -515,7 +516,7 @@ namespace Wino.Mail.ViewModels { if (string.IsNullOrEmpty(SearchQuery) && IsInSearchMode) { - UpdateFolderPivots(); + UpdateFolderPivotsAsync(); IsInSearchMode = false; await InitializeFolderAsync(); } @@ -891,7 +892,7 @@ namespace Wino.Mail.ViewModels OnPropertyChanged(nameof(IsArchiveSpecialFolder)); // Prepare Focused - Other or folder name tabs. - UpdateFolderPivots(); + UpdateFolderPivotsAsync(); // Reset filters and sorting options. ResetFilters(); diff --git a/Wino.Services/AccountService.cs b/Wino.Services/AccountService.cs index 7dfbddd2..a9417661 100644 --- a/Wino.Services/AccountService.cs +++ b/Wino.Services/AccountService.cs @@ -578,5 +578,11 @@ namespace Wino.Services return aliases.FirstOrDefault(a => a.IsPrimary) ?? aliases.First(); } + + public async Task IsAccountFocusedEnabledAsync(Guid accountId) + { + var account = await GetAccountAsync(accountId); + return account.Preferences.IsFocusedInboxEnabled.GetValueOrDefault(); + } } }