Skip to content

Commit 4f6283e

Browse files
committed
actions [nfc]: Simplify name of anchor parameter to update-flags
From the perspective of the callers, this anchor works just like the "anchor" parameters anywhere else, including the Zulip server API endpoints that take an anchor and narrow: the function operates on messages starting from there. The fact that it does so with potentially multiple server API calls, each with a different anchor, is an implementation detail. So we can just call the parameter "anchor".
1 parent 463e270 commit 4f6283e

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

lib/widgets/actions.dart

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Future<void> markNarrowAsRead(BuildContext context, Narrow narrow) async {
4646
// will be the oldest non-muted unread message, which would
4747
// result in muted unreads older than the first unread not
4848
// being processed.
49-
startingAnchor: AnchorCode.oldest,
49+
anchor: AnchorCode.oldest,
5050
// [AnchorCode.oldest] is an anchor ID lower than any valid
5151
// message ID.
5252
includeAnchor: false,
@@ -73,7 +73,7 @@ Future<void> markNarrowAsUnreadFromMessage(
7373
await updateMessageFlagsStartingFromAnchor(
7474
context: context,
7575
apiNarrow: narrow.apiEncode(),
76-
startingAnchor: NumericAnchor(message.id),
76+
anchor: NumericAnchor(message.id),
7777
includeAnchor: true,
7878
op: UpdateMessageFlagsOp.remove,
7979
flag: MessageFlag.read,
@@ -95,7 +95,7 @@ Future<void> markNarrowAsUnreadFromMessage(
9595
Future<bool> updateMessageFlagsStartingFromAnchor({
9696
required BuildContext context,
9797
required List<ApiNarrowElement> apiNarrow,
98-
required Anchor startingAnchor,
98+
required Anchor anchor,
9999
required bool includeAnchor,
100100
required UpdateMessageFlagsOp op,
101101
required MessageFlag flag,
@@ -110,10 +110,8 @@ Future<bool> updateMessageFlagsStartingFromAnchor({
110110

111111
// Compare web's `mark_all_as_read` in web/src/unread_ops.js
112112
// and zulip-mobile's `markAsUnreadFromMessage` in src/action-sheets/index.js .
113-
Anchor anchor = startingAnchor;
114113
int responseCount = 0;
115114
int updatedCount = 0;
116-
117115
while (true) {
118116
final result = await updateMessageFlagsForNarrow(connection,
119117
anchor: anchor,

test/widgets/actions_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ void main() {
217217
op: UpdateMessageFlagsOp.add,
218218
flag: MessageFlag.read,
219219
includeAnchor: false,
220-
startingAnchor: AnchorCode.oldest,
220+
anchor: AnchorCode.oldest,
221221
onCompletedMessage: onCompletedMessage,
222222
onFailedTitle: onFailedTitle,
223223
progressMessage: progressMessage);

0 commit comments

Comments
 (0)