Skip to content

Commit 4fc6862

Browse files
gnpricechrisbobbe
authored andcommitted
msglist [nfc]: Cut default for MessageListView.anchor
There's no value that's a natural default for this at a model level: different UI scenarios will use different values. So require callers to be explicit.
1 parent ce98562 commit 4fc6862

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

lib/model/message_list.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ class MessageListView with ChangeNotifier, _MessageSequence {
450450
factory MessageListView.init({
451451
required PerAccountStore store,
452452
required Narrow narrow,
453-
Anchor anchor = AnchorCode.newest, // TODO(#82): make required, for explicitness
453+
required Anchor anchor,
454454
}) {
455455
return MessageListView._(store: store, narrow: narrow, anchor: anchor)
456456
.._register();

test/model/message_list_test.dart

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,12 +1381,14 @@ void main() {
13811381

13821382
int notifiedCount1 = 0;
13831383
final model1 = MessageListView.init(store: store,
1384-
narrow: ChannelNarrow(stream.streamId))
1384+
narrow: ChannelNarrow(stream.streamId),
1385+
anchor: AnchorCode.newest)
13851386
..addListener(() => notifiedCount1++);
13861387

13871388
int notifiedCount2 = 0;
13881389
final model2 = MessageListView.init(store: store,
1389-
narrow: eg.topicNarrow(stream.streamId, 'hello'))
1390+
narrow: eg.topicNarrow(stream.streamId, 'hello'),
1391+
anchor: AnchorCode.newest)
13901392
..addListener(() => notifiedCount2++);
13911393

13921394
for (final m in [model1, model2]) {
@@ -1426,7 +1428,8 @@ void main() {
14261428
await store.handleEvent(mkEvent(message));
14271429

14281430
// init msglist *after* event was handled
1429-
model = MessageListView.init(store: store, narrow: const CombinedFeedNarrow());
1431+
model = MessageListView.init(store: store,
1432+
narrow: const CombinedFeedNarrow(), anchor: AnchorCode.newest);
14301433
checkInvariants(model);
14311434

14321435
connection.prepare(json:

test/model/message_test.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ void main() {
5151

5252
/// Initialize [store] and the rest of the test state.
5353
Future<void> prepare({
54-
Narrow narrow = const CombinedFeedNarrow(),
5554
ZulipStream? stream,
5655
int? zulipFeatureLevel,
5756
}) async {
@@ -64,7 +63,9 @@ void main() {
6463
await store.addSubscription(subscription);
6564
connection = store.connection as FakeApiConnection;
6665
notifiedCount = 0;
67-
messageList = MessageListView.init(store: store, narrow: narrow)
66+
messageList = MessageListView.init(store: store,
67+
narrow: const CombinedFeedNarrow(),
68+
anchor: AnchorCode.newest)
6869
..addListener(() {
6970
notifiedCount++;
7071
});

0 commit comments

Comments
 (0)