Skip to content

Commit 4d21396

Browse files
committed
actions: Add markNarrowAsRead dialog to MentionsNarrow view
1 parent a60fcf4 commit 4d21396

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

lib/widgets/actions.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ abstract final class ZulipAction {
3232
static Future<void> markNarrowAsRead(BuildContext context, Narrow narrow) async {
3333
final zulipLocalizations = ZulipLocalizations.of(context);
3434

35-
if (narrow is CombinedFeedNarrow || narrow is ChannelNarrow) {
35+
if (narrow is CombinedFeedNarrow || narrow is ChannelNarrow || narrow is MentionsNarrow) {
3636
final didConfirm = showSuggestedActionDialog(context: context,
3737
title: zulipLocalizations.markAllAsReadConfirmationDialogTitle,
3838
message: zulipLocalizations.markAllAsReadConfirmationDialogMessage,

test/widgets/actions_test.dart

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,29 @@ void main() {
9898
});
9999
});
100100

101+
testWidgets('MentionsNarrow sends API request when confirme to mark as read', (tester) async {
102+
const narrow = MentionsNarrow();
103+
await prepare(tester);
104+
connection.prepare(json: UpdateMessageFlagsForNarrowResult(
105+
processedCount: 2, updatedCount: 2,
106+
firstProcessedId: 1, lastProcessedId: 2,
107+
foundOldest: true, foundNewest: true).toJson());
108+
await confirmToMarkNarrowAsRead(tester: tester, context: context, narrow: narrow);
109+
final apiNarrow = narrow.apiEncode()..add(ApiNarrowIs(IsOperand.unread));
110+
check(connection.lastRequest).isA<http.Request>()
111+
..method.equals('POST')
112+
..url.path.equals('/api/v1/messages/flags/narrow')
113+
..bodyFields.deepEquals({
114+
'anchor': 'oldest',
115+
'include_anchor': 'false',
116+
'num_before': '0',
117+
'num_after': '1000',
118+
'narrow': jsonEncode(resolveApiNarrowForServer(apiNarrow, connection.zulipFeatureLevel!)),
119+
'op': 'add',
120+
'flag': 'read',
121+
});
122+
});
123+
101124
testWidgets('use is:unread optimization', (tester) async {
102125
const narrow = CombinedFeedNarrow();
103126
await prepare(tester);

0 commit comments

Comments
 (0)