loadConversation method

Future<List<Nip17Message>> loadConversation({
  1. required String peerPubKey,
  2. bool forceRefresh = false,
  3. Duration timeout = const Duration(seconds: 5),
})

Loads the full conversation with one peer.

If forceRefresh is false, cached reads are allowed before or alongside network refresh. If the peer has no messages, an empty list is returned.

Implementation

Future<List<Nip17Message>> loadConversation({
  required String peerPubKey,
  bool forceRefresh = false,
  Duration timeout = const Duration(seconds: 5),
}) async {
  final conversations = await loadConversations(
    forceRefresh: forceRefresh,
    timeout: timeout,
  );
  for (final conversation in conversations) {
    if (conversation.peerPubKey == peerPubKey) {
      return conversation.messages;
    }
  }
  return const [];
}