* perf: batch-load folders, accounts, and contacts in FetchMailsAsync
Replace the sequential per-mail property-loading loop with a three-step
batch pre-load strategy, eliminating the N+1 DB call pattern that was
the main bottleneck when building the mail list with threading enabled.
Changes:
- Pre-seed the folder cache from MailListInitializationOptions.Folders
so that the most common folders (inbox, sent, etc.) never trigger a DB
lookup at all.
- Load all accounts in a single GetAccountsAsync() call instead of one
GetAccountAsync() call per mail (typically 1–5 accounts total).
- Fetch all sender contacts in a single SQL IN(...) query via the new
GetContactsByAddressesAsync() method instead of one query per address.
- Property assignment is now fully synchronous (no awaits in the loop)
since all data is pre-loaded into plain Dictionary<K,V>.
- Thread-expansion follows the same pattern: new folder IDs are loaded
in parallel via Task.WhenAll; new contact addresses are batch-fetched
with a second IN(...) query.
- Also apply batch pre-loading to GetMailItemsAsync (used by merge-inbox
sync path) which had the same sequential issue.
- Remove the now-unused LoadAssignedPropertiesWithCacheAsync helper and
the ConcurrentDictionary dependency it required.
- Tighten GetMailsByThreadIdsAsync to skip the Id NOT IN clause entirely
when the exclusion set is empty.
https://claude.ai/code/session_018bqahGc6zi95JJhc2aARKS
* test: add MailFetchingTests with correctness and performance coverage
Adds integration tests for MailService.FetchMailsAsync that exercise the
full real-service stack (MailService → FolderService / AccountService /
ContactService) backed by the shared in-memory SQLite helper.
Four tests are included:
• ExpandsSiblingsOutsidePage – proves thread expansion fetches mails that
fall beyond the initial SQL page (6 mails, page=4, expects 6 returned).
• NeverExpandsSiblings – proves threading is truly opt-in; with
CreateThreads=false the result exactly matches the raw page size.
• ResolvesFromAllThreeSources – verifies contact resolution for a known
contact (from the AccountContact table), an unknown sender (ad-hoc
fallback), and a self-sent mail (built from account metadata).
• 1000Mails_70Threads_CompletesWithinBudget – the performance scenario:
1 000 mails (70 threads × 7 + 510 standalone), 40 rotating sender
addresses (20 with DB contacts). Times and reports two scenarios:
- Default first-page fetch (100 mails) + expansion of one partial
thread (expects > 100 mails returned).
- Full load of all 1 000 mails with threading enabled (expects
exactly 1 000 mails returned, all 70 threads intact, < 5 s).
Elapsed times for both scenarios are written to xUnit test output so
they appear in CI logs and can be tracked across builds.
https://claude.ai/code/session_018bqahGc6zi95JJhc2aARKS
---------
Co-authored-by: Claude <noreply@anthropic.com>
* feat(notification): ✨ Add notification removal feature
Implemented a new method `RemoveNotificationAsync` in the `INotificationBuilder` interface to allow the removal of toast notifications for specific emails identified by a unique ID.
This change enhances the notification management by ensuring that notifications can be cleared when emails are marked as read. The `NotificationBuilder` class has been updated to include logic for removing existing notifications and to use the unique ID as a tag for the toast notifications, facilitating their removal. Additionally, the `AppShellViewModel` has been modified to call this new method when an email is updated and marked as read.
This improvement aims to provide a better user experience by keeping the notification area relevant and up-to-date.
* feat(notification): ✨ Add MailReadStatusChanged event handling
Introduced a new event system for handling email read status changes. This includes the addition of a listener in `NotificationBuilder` that removes notifications when an email is marked as read.
• Added `MailReadStatusChanged` record to represent the event.
• Registered a listener in `NotificationBuilder` to handle notification removal.
• Removed the `OnMailUpdated` method from `AppShellViewModel`, delegating notification management to the new event system.
• Updated `MailService` to send `MailReadStatusChanged` events when emails are marked as read.
This change improves the communication between components and enhances the notification management system.
* refactor: Remove comments
* Little cleanup.
---------
Co-authored-by: Burak Kaan Köse <bkaankose@outlook.com>
* Improved online search performance when doing local operations
* Retruning an empty list on no item searches.
* Fixed an issue with batch imap downloads.
---------
Co-authored-by: Burak Kaan Köse <bkaankose@outlook.com>
* Disable timer back sync for debug builds.
* Archive / unarchive feature for Gmail.
* Archive folder name override for Gmail.
* Possible crash fix when the next item is being selected after a mail is removed.
* Restore proper account selection after pin/unpin of folder.
* Making sure that incorrect arcive folder id is not saved in Gmailsynchronizer due to migration.
* Very basic online search for gmail.
* Server side of handling offline search and listing part in listing page.
* Default search mode implementation and search UI improvements.
* Online search for Outlook.
* Very basic online search for gmail.
* Server side of handling offline search and listing part in listing page.
* Default search mode implementation and search UI improvements.
* Online search for Outlook.
* Online search for imap without downloading the messages yet. TODO
* Completing imap search.
* Fixing an issue where scrollviewer overrides a part of template in mail list. Adjusted zoomed out header grid's corner radius.
* IDLE implementation, imap synchronization strategies basics and condstore synchronization.
* Adding iCloud and Yahoo as special IMAP handling scenario.
* iCloud special imap handling.
* Support for killing synchronizers.
* Update privacy policy url.
* Batching condstore downloads into 50, using SORT extension for searches if supported.
* Bumping some nugets. More on the imap synchronizers.
* Delegating idle synchronizations to server to post-sync operations.
* Update mailkit to resolve qresync bug with iCloud.
* Fixing remote highest mode seq checks for qresync and condstore synchronizers.
* Yahoo custom settings.
* Bump google sdk package.
* Fixing the build issue....
* NRE on canceled token accounts during setup.
* Server crash handlers.
* Remove ARM32. Upgrade server to .NET 9.
* Fix icons for yahoo and apple.
* Fixed an issue where disabled folders causing an exception on forced sync.
* Remove smtp encoding constraint.
* Remove commented code.
* Fixing merge conflict
* Addressing double registrations for mailkit remote folder events in synchronizers.
* Making sure idle canceled result is not reported.
* Fixing custom imap server dialog opening.
* Fixing the issue with account creation making the previously selected account as selected as well.
* Fixing app close behavior and logging app close.