recent method

Future<List<ChatMessage>> recent([
  1. int n = 10
])

The last n messages, oldest first.

Implementation

Future<List<ChatMessage>> recent([int n = 10]) async {
  if (n <= 0) return const [];
  // Newest-first with a limit, so the cost is the page rather than the
  // whole conversation.
  final newest = await store.list(
    filter: _scope,
    limit: n,
    newestFirst: true,
  );
  return [for (final d in newest.reversed) _message(d)];
}