pull method

Future<void> pull()

Catch up after a reconnect or when the app comes to the foreground.

Implementation

Future<void> pull() async {
  if (_session == null) return;
  final r = await request('GET', '/support/v1/conversations');
  _set(_state.copyWith(conversations: _withLocal(Conversation.listFrom(r['conversations']))));
  final ids = {for (final id in _state.messages.keys) if (!id.startsWith(_localConv)) id};
  final active = _state.activeConversationId;
  if (active != null && !active.startsWith(_localConv)) ids.add(active);
  await Future.wait(ids.map((id) => loadMessages(id).catchError((Object _) => const <Message>[])));
}