getMessages method
Implementation
@override
List<ChatwootMessage> getMessages() {
final messageClientInstancekey = _clientInstanceKey;
//filter current client instance message ids
Set<int> clientMessageIds = _messageIdToClientInstanceKeyBox.keys
.map((e) => e as int)
.where((key) =>
_messageIdToClientInstanceKeyBox.get(key) ==
messageClientInstancekey)
.toSet();
//retrieve messages with ids
List<ChatwootMessage> sortedMessages = _box.values
.where((message) => clientMessageIds.contains(message.id))
.toList(growable: false);
//sort message using creation dates
sortedMessages.sort((a, b) {
return b.createdAt.compareTo(a.createdAt);
});
return sortedMessages;
}