Skip to content

Commit 972df42

Browse files
committed
actions: Add markNarrowAsRead dialog to MentionsNarrow view
1 parent a197fd4 commit 972df42

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

lib/widgets/actions.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,11 @@ abstract final class ZulipAction {
3636
final unreadCount = switch (narrow) {
3737
CombinedFeedNarrow() => store.unreads.countInCombinedFeedNarrow(),
3838
ChannelNarrow(:final streamId) => store.unreads.countInChannelNarrow(streamId),
39+
MentionsNarrow() => store.unreads.countInMentionsNarrow(),
3940
_ => 0,
4041
};
4142

42-
if (narrow is CombinedFeedNarrow || narrow is ChannelNarrow) {
43+
if (narrow is CombinedFeedNarrow || narrow is ChannelNarrow || narrow is MentionsNarrow) {
4344
final didConfirm = showSuggestedActionDialog(context: context,
4445
title: zulipLocalizations.markAllAsReadConfirmationDialogTitle,
4546
message: zulipLocalizations.markAllAsReadConfirmationDialogMessage(unreadCount),

test/widgets/actions_test.dart

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

101+
testWidgets('MentionsNarrow sends API request when confirmed 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+
final unreadCount = store.unreads.countInMentionsNarrow();
109+
await confirmToMarkNarrowAsRead(tester: tester, context: context, narrow: narrow, unreadCount: unreadCount);
110+
final apiNarrow = narrow.apiEncode()..add(ApiNarrowIs(IsOperand.unread));
111+
check(connection.lastRequest).isA<http.Request>()
112+
..method.equals('POST')
113+
..url.path.equals('/api/v1/messages/flags/narrow')
114+
..bodyFields.deepEquals({
115+
'anchor': 'oldest',
116+
'include_anchor': 'false',
117+
'num_before': '0',
118+
'num_after': '1000',
119+
'narrow': jsonEncode(resolveApiNarrowForServer(apiNarrow, connection.zulipFeatureLevel!)),
120+
'op': 'add',
121+
'flag': 'read',
122+
});
123+
});
124+
101125
testWidgets('use is:unread optimization', (tester) async {
102126
const narrow = CombinedFeedNarrow();
103127
await prepare(tester);

0 commit comments

Comments
 (0)