Skip to content

Commit

Permalink
fix: fix accounts update (#477)
Browse files Browse the repository at this point in the history
  • Loading branch information
ValeraFinebits authored Dec 20, 2024
1 parent 97c6288 commit e460500
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ protected async Task ProcessAccountDataAsync(Account account, CancellationToken
}
else
{
// TODO: TVM-319
await Core.UpdateAccountAsync(account, cancellationToken).ConfigureAwait(true);
}

Expand Down
14 changes: 13 additions & 1 deletion src/Eppie.App/Eppie.App.ViewModels/MainPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ private void SubscribeOnCoreEvents()
Core.MessageDeleted += OnMessageDeleted;
Core.MessagesIsReadChanged += OnMessagesIsReadChanged;
Core.AccountAdded += OnAccountAdded;
Core.AccountUpdated += OnAccountUpdated;
Core.ContactAdded += OnContactAdded;
Core.ContactChanged += OnContactChanged;
Core.ContactDeleted += OnContactDeleted;
Expand All @@ -456,6 +457,7 @@ private void UnsubscribeFromCoreEvents()
Core.MessageDeleted -= OnMessageDeleted;
Core.MessagesIsReadChanged -= OnMessagesIsReadChanged;
Core.AccountAdded -= OnAccountAdded;
Core.AccountUpdated -= OnAccountUpdated;
Core.ContactAdded -= OnContactAdded;
Core.ContactChanged -= OnContactChanged;
Core.ContactDeleted -= OnContactDeleted;
Expand Down Expand Up @@ -545,7 +547,17 @@ private async void UpdateUnreadCounts(EmailAddress email)
}
}

private async void OnAccountAdded(object sender, AccountEventArgs e)
private void OnAccountAdded(object sender, AccountEventArgs e)
{
UpdateAccountsList();
}

private void OnAccountUpdated(object sender, AccountEventArgs e)
{
UpdateAccountsList();
}

private async void UpdateAccountsList()
{
try
{
Expand Down
14 changes: 1 addition & 13 deletions src/Eppie.App/Eppie.App.ViewModels/Models/MailBoxesModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,7 @@ public void SetAccounts(IReadOnlyList<CompositeAccount> accounts)

private void RefreshFolderStructure()
{
var itemsToRemove = Items.Where(item => AccountList.FirstOrDefault(account => account.Email.HasSameAddress(item.Email)) == null)
.ToArray();
foreach (var item in itemsToRemove)
{
Items.Remove(item);
}
Items.Clear();

foreach (var accountData in AccountList)
{
Expand All @@ -75,13 +70,6 @@ private void RefreshFolderStructure()
}
else
{
itemsToRemove = rootItem.Children.Where(item => accountData.FoldersStructure.FirstOrDefault(folder => folder.HasSameName(item.Folder)) == null)
.ToArray();
foreach (var item in itemsToRemove)
{
rootItem.Children.Remove(item);
}

foreach (var folder in accountData.FoldersStructure)
{
var folderItem = rootItem.Children.FirstOrDefault(item => item.Folder.HasSameName(folder));
Expand Down

0 comments on commit e460500

Please sign in to comment.