@@ -17,14 +17,8 @@ Future<MessageListView> messageListViewWithMessages(List<Message> messages, [Nar
17
17
final model = MessageListView .init (store: store, narrow: narrow);
18
18
19
19
final connection = store.connection as FakeApiConnection ;
20
- connection.prepare (json: GetMessagesResult (
21
- anchor: messages.first.id,
22
- foundNewest: true ,
23
- foundOldest: true ,
24
- foundAnchor: true ,
25
- historyLimited: false ,
26
- messages: messages,
27
- ).toJson ());
20
+ connection.prepare (json:
21
+ newestResult (foundOldest: true , messages: messages).toJson ());
28
22
await model.fetch ();
29
23
30
24
return model;
@@ -257,3 +251,22 @@ extension MessageListViewChecks on Subject<MessageListView> {
257
251
Subject <List <ZulipContent >> get contents => has ((x) => x.contents, 'contents' );
258
252
Subject <bool > get fetched => has ((x) => x.fetched, 'fetched' );
259
253
}
254
+
255
+ /// A GetMessagesResult the server might return on an `anchor=newest` request.
256
+ GetMessagesResult newestResult ({
257
+ required bool foundOldest,
258
+ bool historyLimited = false ,
259
+ required List <Message > messages,
260
+ }) {
261
+ return GetMessagesResult (
262
+ // These anchor, foundAnchor, and foundNewest values are what the server
263
+ // appears to always return when the request had `anchor=newest`.
264
+ anchor: 10000000000000000 , // that's 16 zeros
265
+ foundAnchor: false ,
266
+ foundNewest: true ,
267
+
268
+ foundOldest: foundOldest,
269
+ historyLimited: historyLimited,
270
+ messages: messages,
271
+ );
272
+ }
0 commit comments