updateOfflineMessagesFromSocket method
Implementation
Future<void> updateOfflineMessagesFromSocket(
String id, ConversationMessage message) async {
final olderConversation =
await _storageService.getString(currentConversationId.value);
if (olderConversation != null) {
final oldMessageJson = jsonDecode(olderConversation);
ConversationModel oldMessageModel =
ConversationModel.fromJson(oldMessageJson);
final messages = oldMessageModel.data!.messages ?? [];
messages.add(message);
oldMessageModel = oldMessageModel.copyWith(
data: oldMessageModel.data!.copyWith(messages: messages));
_conversationsService.conversation.value = oldMessageModel;
_storageService.setString(
currentConversationId.value, jsonEncode(oldMessageModel.toJson()));
//log('updated offline messages from socket');
update();
} else {
//log('olderConversation is null');
}
//log('it got here first');
getOfflineMessage(currentConversationId.value);
}