Fix focus-other toggle for Live accounts.

This commit is contained in:
Burak Kaan Köse
2024-12-22 00:59:59 +01:00
parent 8390a868ba
commit da2a58a88b
3 changed files with 14 additions and 7 deletions

View File

@@ -155,6 +155,6 @@ namespace Wino.Core.Domain.Interfaces
/// <param name="accountId">Account id.</param> /// <param name="accountId">Account id.</param>
/// <returns>Primary alias for the account.</returns> /// <returns>Primary alias for the account.</returns>
Task<MailAccountAlias> GetPrimaryAccountAliasAsync(Guid accountId); Task<MailAccountAlias> GetPrimaryAccountAliasAsync(Guid accountId);
Task<bool> IsAccountFocusedEnabledAsync(Guid accountId);
} }
} }

View File

@@ -72,6 +72,7 @@ namespace Wino.Mail.ViewModels
public IPreferencesService PreferencesService { get; } public IPreferencesService PreferencesService { get; }
public IThemeService ThemeService { get; } public IThemeService ThemeService { get; }
private readonly IAccountService _accountService;
private readonly IMailService _mailService; private readonly IMailService _mailService;
private readonly IFolderService _folderService; private readonly IFolderService _folderService;
private readonly IThreadingStrategyProvider _threadingStrategyProvider; private readonly IThreadingStrategyProvider _threadingStrategyProvider;
@@ -147,6 +148,7 @@ namespace Wino.Mail.ViewModels
public MailListPageViewModel(IMailDialogService dialogService, public MailListPageViewModel(IMailDialogService dialogService,
INavigationService navigationService, INavigationService navigationService,
IAccountService accountService,
IMailService mailService, IMailService mailService,
IStatePersistanceService statePersistenceService, IStatePersistanceService statePersistenceService,
IFolderService folderService, IFolderService folderService,
@@ -163,7 +165,7 @@ namespace Wino.Mail.ViewModels
_winoServerConnectionManager = winoServerConnectionManager; _winoServerConnectionManager = winoServerConnectionManager;
StatePersistenceService = statePersistenceService; StatePersistenceService = statePersistenceService;
NavigationService = navigationService; NavigationService = navigationService;
_accountService = accountService;
_mailService = mailService; _mailService = mailService;
_folderService = folderService; _folderService = folderService;
_threadingStrategyProvider = threadingStrategyProvider; _threadingStrategyProvider = threadingStrategyProvider;
@@ -376,7 +378,7 @@ namespace Wino.Mail.ViewModels
SetupTopBarActions(); SetupTopBarActions();
} }
private void UpdateFolderPivots() private async Task UpdateFolderPivotsAsync()
{ {
PivotFolders.Clear(); PivotFolders.Clear();
SelectedFolderPivot = null; SelectedFolderPivot = null;
@@ -393,8 +395,7 @@ namespace Wino.Mail.ViewModels
{ {
var parentAccount = singleFolderMenuItem.ParentAccount; var parentAccount = singleFolderMenuItem.ParentAccount;
bool isAccountSupportsFocusedInbox = parentAccount.Preferences.IsFocusedInboxEnabled != null; bool isFocusedInboxEnabled = await _accountService.IsAccountFocusedEnabledAsync(parentAccount.Id);
bool isFocusedInboxEnabled = isAccountSupportsFocusedInbox && parentAccount.Preferences.IsFocusedInboxEnabled.GetValueOrDefault();
bool isInboxFolder = ActiveFolder.SpecialFolderType == SpecialFolderType.Inbox; bool isInboxFolder = ActiveFolder.SpecialFolderType == SpecialFolderType.Inbox;
// Folder supports Focused - Other // Folder supports Focused - Other
@@ -515,7 +516,7 @@ namespace Wino.Mail.ViewModels
{ {
if (string.IsNullOrEmpty(SearchQuery) && IsInSearchMode) if (string.IsNullOrEmpty(SearchQuery) && IsInSearchMode)
{ {
UpdateFolderPivots(); UpdateFolderPivotsAsync();
IsInSearchMode = false; IsInSearchMode = false;
await InitializeFolderAsync(); await InitializeFolderAsync();
} }
@@ -891,7 +892,7 @@ namespace Wino.Mail.ViewModels
OnPropertyChanged(nameof(IsArchiveSpecialFolder)); OnPropertyChanged(nameof(IsArchiveSpecialFolder));
// Prepare Focused - Other or folder name tabs. // Prepare Focused - Other or folder name tabs.
UpdateFolderPivots(); UpdateFolderPivotsAsync();
// Reset filters and sorting options. // Reset filters and sorting options.
ResetFilters(); ResetFilters();

View File

@@ -578,5 +578,11 @@ namespace Wino.Services
return aliases.FirstOrDefault(a => a.IsPrimary) ?? aliases.First(); return aliases.FirstOrDefault(a => a.IsPrimary) ?? aliases.First();
} }
public async Task<bool> IsAccountFocusedEnabledAsync(Guid accountId)
{
var account = await GetAccountAsync(accountId);
return account.Preferences.IsFocusedInboxEnabled.GetValueOrDefault();
}
} }
} }