Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix accounts update #477

Merged
merged 2 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading