Acknowledge muted messages in “Mark as read?” confirmation dialogs (Fixes #2030) #2036
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.
Fix: “Mark as read?” Dialog Now Acknowledges Muted Messages (Fixes #2030)
Background
Issue #2030 reports a confusing behavior in the “Mark as read?” confirmation dialog:
The dialog only showed the count of visible (unmuted) unread messages.
But confirming the action marked all unread messages as read — including those hidden due to:
muted streams
muted topics
muted DMs
This mismatch caused confusion, especially in CombinedFeedNarrow, where users often have thousands of muted unreads that are not shown in the UI.
Example expected behavior from the issue:
No muted unreads:
→ “26 messages will be marked as read.”
With muted unreads:
→ “10026 messages will be marked as read, including 10000 muted messages.”
This PR implements exactly that.
What This PR Does
📁 lib/model/unreads.dart
New public method:
countInNarrowIncludingMuted(Narrow narrow)
Helper methods:
_countInCombinedFeedNarrowIncludingMuted()
_countInChannelNarrowIncludingMuted(int streamId)
_countInMentionsNarrowIncludingMuted()
These return total unread messages, regardless of mute status.
They complement the existing:
countInNarrow() → counts only unmuted messages (visible in UI)
This fulfills the requirement from the issue:
“The Unreads model will need to offer unread counts that include all unreads in a given narrow.”
📁 assets/l10n/app_en.arb
New strings:
markAsReadConfirmationDialogMessage
→ used when no muted messages are present.
markAsReadConfirmationDialogMessageWithMuted
→ used when some messages are muted.
markAsReadConfirmationDialogConfirmButton
→ “Mark as read”
Ran flutter gen-l10n to update generated localization code.
📁 lib/widgets/message_list.dart
Enhanced _handlePress():
Get visible unread count (old behavior)
Get total unread count, including muted (new)
Compute muted count = total − visible
Select dialog message based on presence of muted messages
Ask for explicit user confirmation
Only proceed with mark-as-read after confirmation
This fully aligns with the user expectation outlined in the issue.
📁 test/model/unreads_test.dart
New test group:
countInNarrowIncludingMuted
Covers:
CombinedFeedNarrow
→ includes muted topics, streams, and DMs
ChannelNarrow / StreamNarrow
→ includes muted topics
TopicNarrow
→ unchanged (no subtopic muting exists)
MentionsNarrow
→ mentions are included even if muted
Each test compares:
countInNarrow() (visible only)
countInNarrowIncludingMuted() (total)
to confirm muted messages are correctly counted.
Result: Clear, Transparent Confirmation UI
The user now sees exactly what will happen before marking messages as read.
Example outcomes:
When all are visible
“26 messages will be marked as read.”
When muted messages exist
“10026 messages will be marked as read, including 10000 muted messages.”
This eliminates confusion and improves trust in the action — especially in the interleaved CombinedFeedNarrow view, where muted messages frequently accumulate in large quantities.
Related Issues
Issue #2030 — This PR fixes it.
Related conceptual issue: #2031
“Mark as read?” dialog should acknowledge uncertainty when unreads are extremely high.
Files Changed
lib/model/unreads.dart
lib/widgets/message_list.dart
assets/l10n/app_en.arb
test/model/unreads_test.dart