getOfflineConversation method
Implementation
Future<void> getOfflineConversation(GetAllConversationsData data) async {
final oldConvo = await _storageService.getString('bodsquareConversations');
if (oldConvo != null) {
final oldConvoJson = jsonDecode(oldConvo);
GetAllConversations? oldConvoModel =
GetAllConversations.fromJson(oldConvoJson);
// GetAllConversationsData? valueToChange
oldConvoModel = oldConvoModel.copyWith(
data: oldConvoModel.data!.map((e) {
if (e.contactUid == data.contactUid) {
e = e.copyWith(
channel: data.channel,
companyUid: data.companyUid,
contactUid: data.contactUid,
createdAt: data.createdAt,
id: data.id,
connectionUid: data.connectionUid,
lastMessage: data.lastMessage,
messageType: data.messageType,
noOfUnseenMessages: data.noOfUnseenMessages,
status: data.status,
updatedAt: data.updatedAt,
uid: data.uid);
}
return e;
}).toList());
_conversationsService.allConversationsList.value =
oldConvoModel.data ?? [];
_storageService.setString(
'bodsquareConversations', jsonEncode(oldConvoModel.toJson()));
} else {
//log('oldConvo is null');
}
update();
}