-
Notifications
You must be signed in to change notification settings - Fork 118
ADR-71 CollapseThread #4380
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
Open
hoangdat
wants to merge
10
commits into
master
Choose a base branch
from
ADR_COLLAPSETHREAD
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+697
−0
Open
ADR-71 CollapseThread #4380
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
9595975
ADR-71 CollapseThread
hoangdat a8d5527
fixup! ADR-71 CollapseThread
hoangdat c921388
docs(ADR-0072): Add thread-aware bulk actions for collapseThreads in …
dab246 4a8c629
fixup! docs(ADR-0072): Add thread-aware bulk actions for collapseThre…
dab246 3a3fdcb
fixup! fixup! docs(ADR-0072): Add thread-aware bulk actions for colla…
dab246 1877de4
fixup! fixup! fixup! docs(ADR-0072): Add thread-aware bulk actions fo…
dab246 0564453
fixup! fixup! fixup! fixup! docs(ADR-0072): Add thread-aware bulk act…
dab246 d57e44e
fixup! fixup! fixup! fixup! fixup! docs(ADR-0072): Add thread-aware b…
dab246 2e2d2af
fixup! fixup! fixup! fixup! fixup! fixup! docs(ADR-0072): Add thread-…
dab246 c944fc1
fixup! fixup! fixup! fixup! fixup! fixup! fixup! docs(ADR-0072): Add …
dab246 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| # 0071 - Enable collapseThreads in Email/query | ||
|
|
||
| Date: 2026-03-12 | ||
|
|
||
| ## Status | ||
|
|
||
| Proposed | ||
|
|
||
| ## Context | ||
|
|
||
| JMAP `Email/query` supports `collapseThreads` (RFC 8621 §4.4). When `true`, server returns only the **latest email per thread**, avoiding duplicate rows in the mail list. | ||
|
|
||
| Currently, our app does **not** set `collapseThreads`. When thread is enabled, users see multiple emails from the same thread as separate rows. | ||
|
|
||
| ### Two Query Paths (see ADR-0070) | ||
|
|
||
| | Path | `FORCE_EMAIL_QUERY` | Method | Cache | | ||
| |------|---------------------|--------|-------| | ||
| | Force query | `true` | `forceQueryAllEmailsForWeb()` | No local cache — server only | | ||
| | Cache-first | `false` | `getAllEmail()` | Local DB first, then sync | | ||
|
|
||
| ### Problem: Cache Inconsistency on Toggle | ||
|
|
||
| On the cache-first path, the local DB reflects the `collapseThreads` mode it was built under. When thread mode changes: | ||
|
|
||
| - **OFF → ON**: Cache has individual emails (5 rows) but server now returns collapsed (3 rows) → stale first yield | ||
| - **ON → OFF**: Cache has collapsed emails (3 rows) but server now returns all individuals (5 rows) → missing emails in first yield | ||
|
|
||
| Force-query path has **no problem** — always queries server directly. | ||
|
|
||
| ## Decision | ||
|
|
||
| ### 1. Set `collapseThreads: true` in Email/query When Thread Is Enabled | ||
|
|
||
| In `MailAPIMixin.fetchAllEmail()` and `ThreadAPI.searchEmails()`, pass `collapseThreads: true` when thread is enabled. | ||
|
|
||
| ### 2. Clear Email Cache on Thread Setting Toggle | ||
|
|
||
| Reuse the existing thread-enabled setting. **No new flag needed.** When thread is toggled (enable ↔ disable), clear email cache immediately in the toggle handler. Next `getAllEmail()` will rebuild cache under correct mode. | ||
|
|
||
| ### 3. No Change for Force-Query Path | ||
|
|
||
| Already server-only. Just pass `collapseThreads: true` in the query. | ||
|
|
||
| ## Consequences | ||
|
|
||
| **Positive**: Correct thread display, reduced data per page, spec-compliant. | ||
|
|
||
| **Negative**: One-time full reload on each toggle; toggle handler coupled with cache management. | ||
|
|
||
| ## Implementation Steps | ||
|
|
||
| 1. Add `collapseThreads` to `QueryEmailMethod` in `MailAPIMixin.fetchAllEmail()` and `ThreadAPI.searchEmails()` | ||
| 2. Pass thread-enabled status from Settings to query builder | ||
| 3. Clear email cache in thread setting toggle handler | ||
| 4. Update `GetEmailsInMailboxInteractor` and related interactors to propagate thread status | ||
|
|
||
| ## References | ||
|
|
||
| - [RFC 8621 §4.4](https://www.rfc-editor.org/rfc/rfc8621#section-4.4) | ||
| - [ADR-0070](./0070-sync-strategy-disappearing-emails.md) | ||
| - `lib/features/base/mixin/mail_api_mixin.dart` — `fetchAllEmail()` | ||
| - `lib/features/thread/data/repository/thread_repository_impl.dart` — `getAllEmail()` | ||
| - `lib/features/thread/domain/usecases/get_emails_in_mailbox_interactor.dart` | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.