openActive method

Future<void> openActive()

Back to the visitor's current conversation (the newest open one), or an empty chat when there is none, so the next message starts a new one.

Implementation

Future<void> openActive() async {
  final page = await listConversations(status: 'open', limit: 1);
  final open = page.conversations.firstOrNull;
  if (open != null) {
    await openConversation(open.id, summary: open);
    return;
  }
  if (_state.conversation == null) return;
  _emit(_state.copyWith(clearConversation: true, timeline: Timeline.empty, clearTyping: true, clearRated: true));
  unawaited(_persist(_stored.copyWith(clearConversation: true)));
}