diff --git a/Wino.Core.Domain/Entities/MailAccount.cs b/Wino.Core.Domain/Entities/MailAccount.cs
index c8f39c1d..7d87128b 100644
--- a/Wino.Core.Domain/Entities/MailAccount.cs
+++ b/Wino.Core.Domain/Entities/MailAccount.cs
@@ -50,6 +50,11 @@ namespace Wino.Core.Domain.Entities
///
public Guid? SignatureId { get; set; }
+ ///
+ /// Gets or sets the listing order of the account in the accounts list.
+ ///
+ public int Order { get; set; }
+
///
/// Gets or sets whether the account has any reason for an interactive user action to fix continue operating.
///
diff --git a/Wino.Core.Domain/Interfaces/IAccountService.cs b/Wino.Core.Domain/Interfaces/IAccountService.cs
index 99190af3..78682cda 100644
--- a/Wino.Core.Domain/Interfaces/IAccountService.cs
+++ b/Wino.Core.Domain/Interfaces/IAccountService.cs
@@ -68,12 +68,37 @@ namespace Wino.Core.Domain.Interfaces
/// Current account synchronization modifier.
Task UpdateSynchronizationIdentifierAsync(Guid accountId, string newIdentifier);
+ ///
+ /// Renames the merged inbox with the given id.
+ ///
+ /// Merged Inbox id
+ /// New name for the merged/linked inbox.
Task RenameMergedAccountAsync(Guid mergedInboxId, string newName);
+ ///
+ /// Creates a new merged inbox with the given accounts.
+ ///
+ /// Merged inbox properties.
+ /// List of accounts to merge together.
Task CreateMergeAccountsAsync(MergedInbox mergedInbox, IEnumerable accountsToMerge);
+ ///
+ /// Updates the merged inbox with the given id with the new linked accounts.
+ ///
+ /// Updating merged inbox id.
+ /// List of linked account ids.
Task UpdateMergedInboxAsync(Guid mergedInboxId, IEnumerable linkedAccountIds);
+ ///
+ /// Destroys the merged inbox with the given id.
+ ///
+ /// Merged inbox id to destroy.
Task UnlinkMergedInboxAsync(Guid mergedInboxId);
+
+ ///
+ /// Updates the account listing orders.
+ ///
+ /// AccountId-OrderNumber pair for all accounts.
+ Task UpdateAccountOrdersAsync(Dictionary accountIdOrderPair);
}
}
diff --git a/Wino.Core.Domain/Translations/en_US/resources.json b/Wino.Core.Domain/Translations/en_US/resources.json
index ee59438a..88b8b57f 100644
--- a/Wino.Core.Domain/Translations/en_US/resources.json
+++ b/Wino.Core.Domain/Translations/en_US/resources.json
@@ -407,6 +407,8 @@
"SettingsFolderMenuStyle_Description": "Change whether account folders should be nested inside an account menu item or not. Toggle this off if you like the old menu system in Windows Mail",
"SettingsManageAccountSettings_Description": "Notifications, signatures, synchronization and other settings per account.",
"SettingsManageAccountSettings_Title": "Manage Account Settings",
+ "SettingsReorderAccounts_Title": "Reorder Accounts",
+ "SettingsReorderAccounts_Description": "Change the order of accounts in the account list.",
"SettingsManageLink_Description": "Move items to add new link or remove existing link.",
"SettingsManageLink_Title": "Manage Link",
"SettingsMarkAsRead_Description": "Change what should happen to the selected item.",
diff --git a/Wino.Core.Domain/Translator.Designer.cs b/Wino.Core.Domain/Translator.Designer.cs
index ee2312c1..9c83ca16 100644
--- a/Wino.Core.Domain/Translator.Designer.cs
+++ b/Wino.Core.Domain/Translator.Designer.cs
@@ -2481,6 +2481,18 @@ namespace Wino.Core.Domain
public static string SettingsManageAccountSettings_Title => Resources.GetTranslatedString(@"SettingsManageAccountSettings_Title");
+ ///
+ /// Reorder Accounts
+ ///
+ public static string SettingsReorderAccounts_Title => Resources.GetTranslatedString(@"SettingsReorderAccounts_Title");
+
+
+ ///
+ /// Change the order of accounts in the account list.
+ ///
+ public static string SettingsReorderAccounts_Description => Resources.GetTranslatedString(@"SettingsReorderAccounts_Description");
+
+
///
/// Move items to add new link or remove existing link.
///
diff --git a/Wino.Core/Services/AccountService.cs b/Wino.Core/Services/AccountService.cs
index 850139f2..dd8a9f8a 100644
--- a/Wino.Core/Services/AccountService.cs
+++ b/Wino.Core/Services/AccountService.cs
@@ -215,7 +215,7 @@ namespace Wino.Core.Services
public async Task> GetAccountsAsync()
{
- var accounts = await Connection.Table().ToListAsync();
+ var accounts = await Connection.Table().OrderBy(a => a.Order).ToListAsync();
foreach (var account in accounts)
{
@@ -301,12 +301,21 @@ namespace Wino.Core.Services
{
var account = await Connection.Table().FirstOrDefaultAsync(a => a.Id == accountId);
- if (account?.ProviderType == MailProviderType.IMAP4)
- account.ServerInformation = await GetAccountCustomServerInformationAsync(account.Id);
+ if (account == null)
+ {
+ _logger.Error("Could not find account with id {AccountId}", accountId);
+ }
+ else
+ {
+ if (account.ProviderType == MailProviderType.IMAP4)
+ account.ServerInformation = await GetAccountCustomServerInformationAsync(account.Id);
- account.Preferences = await GetAccountPreferencesAsync(account.Id);
+ account.Preferences = await GetAccountPreferencesAsync(account.Id);
- return account;
+ return account;
+ }
+
+ return null;
}
public Task GetAccountCustomServerInformationAsync(Guid accountId)
@@ -336,6 +345,12 @@ namespace Wino.Core.Services
{
_preferencesService.StartupEntityId = account.Id;
}
+ else
+ {
+ // Set the order of the account.
+ // This can be changed by the user later in manage accounts page.
+ account.Order = accountCount;
+ }
await Connection.InsertAsync(account);
@@ -352,6 +367,8 @@ namespace Wino.Core.Services
// Outlook & Office 365 supports Focused inbox. Enabled by default.
bool isMicrosoftProvider = account.ProviderType == MailProviderType.Outlook || account.ProviderType == MailProviderType.Office365;
+ // TODO: This should come from account settings API.
+ // Wino doesn't have MailboxSettings yet.
if (isMicrosoftProvider)
account.Preferences.IsFocusedInboxEnabled = true;
@@ -398,6 +415,22 @@ namespace Wino.Core.Services
return account.SynchronizationDeltaIdentifier;
}
+ public async Task UpdateAccountOrdersAsync(Dictionary accountIdOrderPair)
+ {
+ foreach (var pair in accountIdOrderPair)
+ {
+ var account = await GetAccountAsync(pair.Key);
+ if (account == null)
+ {
+ _logger.Error("Could not find account with id {AccountId}", pair.Key);
+ continue;
+ }
+
+ account.Order = pair.Value;
+
+ await Connection.UpdateAsync(account);
+ }
+ }
}
}
diff --git a/Wino.Mail.ViewModels/AccountManagementViewModel.cs b/Wino.Mail.ViewModels/AccountManagementViewModel.cs
index e370f190..4c06374d 100644
--- a/Wino.Mail.ViewModels/AccountManagementViewModel.cs
+++ b/Wino.Mail.ViewModels/AccountManagementViewModel.cs
@@ -42,6 +42,7 @@ namespace Wino.Mail.ViewModels
public bool IsPurchasePanelVisible => !HasUnlimitedAccountProduct;
public bool IsAccountCreationAlmostOnLimit => Accounts != null && Accounts.Count == FREE_ACCOUNT_COUNT - 1;
public bool HasAccountsDefined => Accounts != null && Accounts.Any();
+ public bool CanReorderAccounts => Accounts?.Count > 1;
public string UsedAccountsString => string.Format(Translator.WinoUpgradeRemainingAccountsMessage, Accounts.Count, FREE_ACCOUNT_COUNT);
@@ -263,6 +264,12 @@ namespace Wino.Mail.ViewModels
mergedAccountProviderDetailViewModel));
}
+ [RelayCommand]
+ private async Task ReorderAccountsAsync()
+ {
+
+ }
+
public override void OnNavigatedFrom(NavigationMode mode, object parameters)
{
base.OnNavigatedFrom(mode, parameters);
@@ -276,6 +283,9 @@ namespace Wino.Mail.ViewModels
{
OnPropertyChanged(nameof(HasAccountsDefined));
OnPropertyChanged(nameof(UsedAccountsString));
+ OnPropertyChanged(nameof(IsAccountCreationAlmostOnLimit));
+
+ ReorderAccountsCommand.NotifyCanExecuteChanged();
}
private void PagePropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
diff --git a/Wino.Mail/Views/Account/AccountManagementPage.xaml b/Wino.Mail/Views/Account/AccountManagementPage.xaml
index 266d2c04..6876ae12 100644
--- a/Wino.Mail/Views/Account/AccountManagementPage.xaml
+++ b/Wino.Mail/Views/Account/AccountManagementPage.xaml
@@ -220,6 +220,18 @@
Description="{x:Bind domain:Translator.SettingsLinkAccounts_Description}">
+
+
+
+
+
+
+