Skip to content

Commit 4058e7f

Browse files
committed
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 c0b44d2 commit 4058e7f

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
@@ -1368,12 +1368,14 @@ void main() {
13681368

13691369
int notifiedCount1 = 0;
13701370
final model1 = MessageListView.init(store: store,
1371-
narrow: ChannelNarrow(stream.streamId))
1371+
narrow: ChannelNarrow(stream.streamId),
1372+
anchor: AnchorCode.newest)
13721373
..addListener(() => notifiedCount1++);
13731374

13741375
int notifiedCount2 = 0;
13751376
final model2 = MessageListView.init(store: store,
1376-
narrow: eg.topicNarrow(stream.streamId, 'hello'))
1377+
narrow: eg.topicNarrow(stream.streamId, 'hello'),
1378+
anchor: AnchorCode.newest)
13771379
..addListener(() => notifiedCount2++);
13781380

13791381
for (final m in [model1, model2]) {
@@ -1413,7 +1415,8 @@ void main() {
14131415
await store.handleEvent(mkEvent(message));
14141416

14151417
// init msglist *after* event was handled
1416-
model = MessageListView.init(store: store, narrow: const CombinedFeedNarrow());
1418+
model = MessageListView.init(store: store,
1419+
narrow: const CombinedFeedNarrow(), anchor: AnchorCode.newest);
14171420
checkInvariants(model);
14181421

14191422
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)