Fixing an issue where doing folder config on account does not refresh the folder list.
This commit is contained in:
@@ -151,15 +151,12 @@ namespace Wino.Core.MenuItems
|
||||
return accountMenuItem;
|
||||
}
|
||||
|
||||
public async Task ReplaceFoldersAsync(IEnumerable<IMenuItem> folders)
|
||||
public void ReplaceFolders(IEnumerable<IMenuItem> folders)
|
||||
{
|
||||
await _dispatcher.ExecuteOnUIThread(() =>
|
||||
{
|
||||
ClearFolderAreaMenuItems();
|
||||
ClearFolderAreaMenuItems();
|
||||
|
||||
Items.Add(new SeperatorItem());
|
||||
AddRange(folders);
|
||||
});
|
||||
Items.Add(new SeperatorItem());
|
||||
AddRange(folders);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -194,9 +191,11 @@ namespace Wino.Core.MenuItems
|
||||
{
|
||||
item.IsExpanded = false;
|
||||
item.IsSelected = false;
|
||||
|
||||
Remove(item);
|
||||
});
|
||||
|
||||
RemoveRange(itemsToRemove);
|
||||
// RemoveRange(itemsToRemove);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -387,11 +387,6 @@ namespace Wino.Core.Services
|
||||
if (configuration == null)
|
||||
throw new ArgumentNullException(nameof(configuration));
|
||||
|
||||
var account = await _accountService.GetAccountAsync(accountId);
|
||||
|
||||
if (account == null)
|
||||
throw new ArgumentNullException(nameof(account));
|
||||
|
||||
// Update system folders for this account.
|
||||
|
||||
await Task.WhenAll(UpdateSystemFolderInternalAsync(configuration.SentFolder, SpecialFolderType.Sent),
|
||||
@@ -400,9 +395,8 @@ namespace Wino.Core.Services
|
||||
UpdateSystemFolderInternalAsync(configuration.TrashFolder, SpecialFolderType.Deleted),
|
||||
UpdateSystemFolderInternalAsync(configuration.ArchiveFolder, SpecialFolderType.Archive));
|
||||
|
||||
await _accountService.UpdateAccountAsync(account);
|
||||
|
||||
return account;
|
||||
return await _accountService.GetAccountAsync(accountId).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private Task UpdateSystemFolderInternalAsync(MailItemFolder folder, SpecialFolderType assignedSpecialFolderType)
|
||||
@@ -492,13 +486,6 @@ namespace Wino.Core.Services
|
||||
return;
|
||||
}
|
||||
|
||||
var account = await _accountService.GetAccountAsync(folder.MailAccountId).ConfigureAwait(false);
|
||||
if (account == null)
|
||||
{
|
||||
_logger.Warning("Account with id {MailAccountId} does not exist. Cannot update folder.", folder.MailAccountId);
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.Debug("Updating folder {FolderName}", folder.Id, folder.FolderName);
|
||||
|
||||
await Connection.UpdateAsync(folder).ConfigureAwait(false);
|
||||
|
||||
@@ -38,7 +38,8 @@ namespace Wino.Mail.ViewModels
|
||||
IRecipient<LanguageChanged>,
|
||||
IRecipient<AccountMenuItemsReordered>,
|
||||
IRecipient<AccountSynchronizationProgressUpdatedMessage>,
|
||||
IRecipient<NavigateAppPreferencesRequested>
|
||||
IRecipient<NavigateAppPreferencesRequested>,
|
||||
IRecipient<AccountFolderConfigurationUpdated>
|
||||
{
|
||||
#region Menu Items
|
||||
|
||||
@@ -631,6 +632,9 @@ namespace Wino.Mail.ViewModels
|
||||
|
||||
await MenuItems.SetAccountMenuItemEnabledStatusAsync(false);
|
||||
|
||||
// Load account folder structure and replace the visible folders.
|
||||
var folders = await _folderService.GetAccountFoldersForDisplayAsync(clickedBaseAccountMenuItem);
|
||||
|
||||
await ExecuteUIThread(() =>
|
||||
{
|
||||
clickedBaseAccountMenuItem.IsEnabled = false;
|
||||
@@ -643,12 +647,10 @@ namespace Wino.Mail.ViewModels
|
||||
clickedBaseAccountMenuItem.IsSelected = true;
|
||||
|
||||
latestSelectedAccountMenuItem = clickedBaseAccountMenuItem;
|
||||
|
||||
MenuItems.ReplaceFolders(folders);
|
||||
});
|
||||
|
||||
// Load account folder structure and replace the visible folders.
|
||||
var folders = await _folderService.GetAccountFoldersForDisplayAsync(clickedBaseAccountMenuItem);
|
||||
|
||||
await MenuItems.ReplaceFoldersAsync(folders);
|
||||
await UpdateUnreadItemCountAsync();
|
||||
await MenuItems.SetAccountMenuItemEnabledStatusAsync(true);
|
||||
|
||||
@@ -955,6 +957,16 @@ namespace Wino.Mail.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public async void Receive(AccountFolderConfigurationUpdated message)
|
||||
{
|
||||
// Reloading of folders is needed to re-create folder tree if the account is loaded.
|
||||
|
||||
if (MenuItems.TryGetAccountMenuItem(message.AccountId, out IAccountMenuItem accountMenuItem))
|
||||
{
|
||||
await ChangeLoadedAccountAsync(accountMenuItem, true);
|
||||
}
|
||||
}
|
||||
|
||||
public async void Receive(MergedInboxRenamed message)
|
||||
{
|
||||
var mergedInboxMenuItem = MenuItems.FirstOrDefault(a => a.EntityId == message.MergedInboxId);
|
||||
|
||||
@@ -19,9 +19,9 @@ using Wino.Core.Domain.Models.Folders;
|
||||
using Wino.Core.Domain.Models.Synchronization;
|
||||
using Wino.Core.UWP.Extensions;
|
||||
using Wino.Dialogs;
|
||||
using Wino.Messaging.Client.Accounts;
|
||||
using Wino.Messaging.Client.Shell;
|
||||
using Wino.Messaging.Server;
|
||||
using Wino.Messaging.UI;
|
||||
|
||||
namespace Wino.Services
|
||||
{
|
||||
@@ -197,16 +197,13 @@ namespace Wino.Services
|
||||
|
||||
if (configuration != null)
|
||||
{
|
||||
var updatedAccount = await folderService.UpdateSystemFolderConfigurationAsync(accountId, configuration);
|
||||
|
||||
InfoBarMessage(Translator.SystemFolderConfigSetupSuccess_Title, Translator.SystemFolderConfigSetupSuccess_Message, InfoBarMessageType.Success);
|
||||
|
||||
// Update account menu item and force re-synchronization.
|
||||
WeakReferenceMessenger.Default.Send(new AccountUpdatedMessage(updatedAccount));
|
||||
WeakReferenceMessenger.Default.Send(new AccountFolderConfigurationUpdated(accountId));
|
||||
|
||||
var options = new SynchronizationOptions()
|
||||
{
|
||||
AccountId = updatedAccount.Id,
|
||||
AccountId = accountId,
|
||||
Type = SynchronizationType.Full,
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
using System;
|
||||
|
||||
namespace Wino.Messaging.Client.Accounts
|
||||
{
|
||||
/// <summary>
|
||||
/// When account's special folder configuration is updated.
|
||||
/// </summary>
|
||||
public record AccountFolderConfigurationUpdated(Guid AccountId);
|
||||
}
|
||||
Reference in New Issue
Block a user