Initial setup for account ordering.
This commit is contained in:
@@ -215,7 +215,7 @@ namespace Wino.Core.Services
|
||||
|
||||
public async Task<List<MailAccount>> GetAccountsAsync()
|
||||
{
|
||||
var accounts = await Connection.Table<MailAccount>().ToListAsync();
|
||||
var accounts = await Connection.Table<MailAccount>().OrderBy(a => a.Order).ToListAsync();
|
||||
|
||||
foreach (var account in accounts)
|
||||
{
|
||||
@@ -301,12 +301,21 @@ namespace Wino.Core.Services
|
||||
{
|
||||
var account = await Connection.Table<MailAccount>().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<CustomServerInformation> 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<Guid, int> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user