Skip to content

Commit 45a5702

Browse files
committed
actions [nfc]: Move legacy-server check inside markNarrowAsRead
1 parent d4d2615 commit 45a5702

File tree

3 files changed

+14
-21
lines changed

3 files changed

+14
-21
lines changed

lib/widgets/actions.dart

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,11 @@ import '../model/narrow.dart';
1616
import 'dialog.dart';
1717
import 'store.dart';
1818

19-
Future<void> markNarrowAsRead(
20-
BuildContext context,
21-
Narrow narrow,
22-
bool useLegacy, // TODO(server-6)
23-
) async {
19+
Future<void> markNarrowAsRead(BuildContext context, Narrow narrow) async {
2420
try {
2521
final store = PerAccountStoreWidget.of(context);
2622
final connection = store.connection;
23+
final useLegacy = connection.zulipFeatureLevel! < 155; // TODO(server-6)
2724
if (useLegacy) {
2825
await _legacyMarkNarrowAsRead(context, narrow);
2926
return;

lib/widgets/message_list.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -688,12 +688,8 @@ class _MarkAsReadWidgetState extends State<MarkAsReadWidget> {
688688

689689
void _handlePress(BuildContext context) async {
690690
if (!context.mounted) return;
691-
692-
final store = PerAccountStoreWidget.of(context);
693-
final connection = store.connection;
694-
final useLegacy = connection.zulipFeatureLevel! < 155;
695691
setState(() => _loading = true);
696-
await markNarrowAsRead(context, widget.narrow, useLegacy);
692+
await markNarrowAsRead(context, widget.narrow);
697693
setState(() => _loading = false);
698694
}
699695

test/widgets/actions_test.dart

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ void main() {
5252
processedCount: 11, updatedCount: 3,
5353
firstProcessedId: null, lastProcessedId: null,
5454
foundOldest: true, foundNewest: true).toJson());
55-
markNarrowAsRead(context, narrow, false);
55+
markNarrowAsRead(context, narrow);
5656
await tester.pump(Duration.zero);
5757
final apiNarrow = narrow.apiEncode()..add(ApiNarrowIsUnread());
5858
check(connection.lastRequest).isA<http.Request>()
@@ -77,7 +77,7 @@ void main() {
7777
processedCount: 11, updatedCount: 3,
7878
firstProcessedId: null, lastProcessedId: null,
7979
foundOldest: true, foundNewest: true).toJson());
80-
markNarrowAsRead(context, narrow, false);
80+
markNarrowAsRead(context, narrow);
8181
await tester.pump(Duration.zero);
8282
check(connection.lastRequest).isA<http.Request>()
8383
..method.equals('POST')
@@ -103,7 +103,7 @@ void main() {
103103
processedCount: 1000, updatedCount: 890,
104104
firstProcessedId: 1, lastProcessedId: 1989,
105105
foundOldest: true, foundNewest: false).toJson());
106-
markNarrowAsRead(context, narrow, false);
106+
markNarrowAsRead(context, narrow);
107107
final apiNarrow = narrow.apiEncode()..add(ApiNarrowIsUnread());
108108
check(connection.lastRequest).isA<http.Request>()
109109
..method.equals('POST')
@@ -147,7 +147,7 @@ void main() {
147147
processedCount: 11, updatedCount: 3,
148148
firstProcessedId: null, lastProcessedId: null,
149149
foundOldest: true, foundNewest: true).toJson());
150-
markNarrowAsRead(context, narrow, false);
150+
markNarrowAsRead(context, narrow);
151151
await tester.pump(Duration.zero);
152152
await tester.pumpAndSettle();
153153
check(store.unreads.oldUnreadsMissing).isFalse();
@@ -161,7 +161,7 @@ void main() {
161161
processedCount: 1000, updatedCount: 0,
162162
firstProcessedId: null, lastProcessedId: null,
163163
foundOldest: true, foundNewest: false).toJson());
164-
markNarrowAsRead(context, narrow, false);
164+
markNarrowAsRead(context, narrow);
165165
await tester.pump(Duration.zero);
166166
final apiNarrow = narrow.apiEncode()..add(ApiNarrowIsUnread());
167167
check(connection.lastRequest).isA<http.Request>()
@@ -191,7 +191,7 @@ void main() {
191191

192192
connection.zulipFeatureLevel = 154;
193193
connection.prepare(json: {});
194-
markNarrowAsRead(context, narrow, true); // TODO move legacy-server check inside markNarrowAsRead
194+
markNarrowAsRead(context, narrow);
195195
await tester.pump(Duration.zero);
196196
check(connection.lastRequest).isA<http.Request>()
197197
..method.equals('POST')
@@ -209,7 +209,7 @@ void main() {
209209
await prepare(tester);
210210
connection.zulipFeatureLevel = 154;
211211
connection.prepare(json: {});
212-
markNarrowAsRead(context, narrow, true); // TODO move legacy-server check inside markNarrowAsRead
212+
markNarrowAsRead(context, narrow);
213213
await tester.pump(Duration.zero);
214214
check(connection.lastRequest).isA<http.Request>()
215215
..method.equals('POST')
@@ -224,7 +224,7 @@ void main() {
224224
await prepare(tester);
225225
connection.zulipFeatureLevel = 154;
226226
connection.prepare(json: {});
227-
markNarrowAsRead(context, narrow, true); // TODO move legacy-server check inside markNarrowAsRead
227+
markNarrowAsRead(context, narrow);
228228
await tester.pump(Duration.zero);
229229
check(connection.lastRequest).isA<http.Request>()
230230
..method.equals('POST')
@@ -246,7 +246,7 @@ void main() {
246246
connection.zulipFeatureLevel = 154;
247247
connection.prepare(json:
248248
UpdateMessageFlagsResult(messages: [message.id]).toJson());
249-
markNarrowAsRead(context, narrow, true); // TODO move legacy-server check inside markNarrowAsRead
249+
markNarrowAsRead(context, narrow);
250250
await tester.pump(Duration.zero);
251251
check(connection.lastRequest).isA<http.Request>()
252252
..method.equals('POST')
@@ -266,7 +266,7 @@ void main() {
266266
connection.zulipFeatureLevel = 154;
267267
connection.prepare(json:
268268
UpdateMessageFlagsResult(messages: [message.id]).toJson());
269-
markNarrowAsRead(context, narrow, true); // TODO move legacy-server check inside markNarrowAsRead
269+
markNarrowAsRead(context, narrow);
270270
await tester.pump(Duration.zero);
271271
check(connection.lastRequest).isA<http.Request>()
272272
..method.equals('POST')
@@ -283,7 +283,7 @@ void main() {
283283
const narrow = CombinedFeedNarrow();
284284
await prepare(tester);
285285
connection.prepare(exception: http.ClientException('Oops'));
286-
markNarrowAsRead(context, narrow, false);
286+
markNarrowAsRead(context, narrow);
287287
await tester.pump(Duration.zero);
288288
await tester.pumpAndSettle();
289289
checkErrorDialog(tester,

0 commit comments

Comments
 (0)