setChatHistory method
Implementation
Future<void> setChatHistory(Message message, {Uint8List? imageData}) async {
try {
var key = AtKey()
..key = storageKey + (isGroupChat ? groupChatId! : '') + (chatWithAtSign ?? ' ').substring(1)
..sharedBy = currentAtSign!
..sharedWith = chatWithAtSign
..metadata = Metadata();
key.metadata.ccd = true;
key.metadata.ttr = -1;
chatHistoryMessages.insert(0, message.toJson());
if (message.contentType == MessageContentType.image) {
message.imageData = imageData ?? Uint8List(0);
}
chatHistory.insert(0, message);
chatSink.add(chatHistory);
await atClientManager.atClient.put(key, json.encode(chatHistoryMessages));
} catch (e) {
chatSink.add([]);
}
}