|
|
|
|
@ -330,8 +330,11 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
|
temp = getSingleUserChatModel(jsonEncode(msg));
|
|
|
|
|
data.first.targetUserId = temp.first.currentUserId;
|
|
|
|
|
data.first.targetUserName = temp.first.currentUserName;
|
|
|
|
|
data.first.targetUserEmail = temp.first.currentUserEmail;
|
|
|
|
|
data.first.currentUserId = temp.first.targetUserId;
|
|
|
|
|
data.first.currentUserName = temp.first.targetUserName;
|
|
|
|
|
data.first.currentUserEmail = temp.first.targetUserEmail;
|
|
|
|
|
|
|
|
|
|
if (data.first.fileTypeId == 12 || data.first.fileTypeId == 4 || data.first.fileTypeId == 3) {
|
|
|
|
|
data.first.image = await ChatApiClient().downloadURL(fileName: data.first.contant!, fileTypeDescription: data.first.fileTypeResponse!.fileTypeDescription ?? "image/jpg");
|
|
|
|
|
}
|
|
|
|
|
@ -349,21 +352,24 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
|
if (searchedChats != null) {
|
|
|
|
|
dynamic contain = searchedChats!.where((ChatUser element) => element.id == data.first.currentUserId);
|
|
|
|
|
if (contain.isEmpty) {
|
|
|
|
|
List<String> emails = [];
|
|
|
|
|
emails.add(await EmailImageEncryption().encrypt(val: data.first.currentUserEmail!));
|
|
|
|
|
List<ChatUserImageModel> chatImages = await ChatApiClient().getUsersImages(encryptedEmails: emails);
|
|
|
|
|
searchedChats!.add(
|
|
|
|
|
ChatUser(
|
|
|
|
|
id: data.first.currentUserId,
|
|
|
|
|
userName: data.first.currentUserName,
|
|
|
|
|
unreadMessageCount: 0,
|
|
|
|
|
isImageLoading: false,
|
|
|
|
|
image: "",
|
|
|
|
|
isImageLoaded: true,
|
|
|
|
|
userStatus: 1,
|
|
|
|
|
isTyping: false,
|
|
|
|
|
userLocalDownlaodedImage: null),
|
|
|
|
|
id: data.first.currentUserId,
|
|
|
|
|
userName: data.first.currentUserName,
|
|
|
|
|
unreadMessageCount: 0,
|
|
|
|
|
isImageLoading: false,
|
|
|
|
|
image: chatImages!.first.profilePicture ?? "",
|
|
|
|
|
isImageLoaded: true,
|
|
|
|
|
userStatus: 1,
|
|
|
|
|
isTyping: false,
|
|
|
|
|
userLocalDownlaodedImage: await downloadImageLocal(chatImages.first.profilePicture, data.first.currentUserId.toString()),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setMsgTune();
|
|
|
|
|
userChatHistory.insert(0, data.first);
|
|
|
|
|
|
|
|
|
|
@ -526,21 +532,25 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
|
await chatHubConnection.invoke("AddChatUserAsync", args: <Object>[json.decode(chatData)]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void sendChatMessage(int targetUserId, int userStatus, String targetUserName, BuildContext context) async {
|
|
|
|
|
void sendChatMessage(BuildContext context, {required int targetUserId, required int userStatus, required String userEmail, required String targetUserName}) async {
|
|
|
|
|
dynamic contain = searchedChats!.where((ChatUser element) => element.id == targetUserId);
|
|
|
|
|
if (contain.isEmpty) {
|
|
|
|
|
List<String> emails = [];
|
|
|
|
|
emails.add(await EmailImageEncryption().encrypt(val: userEmail));
|
|
|
|
|
List<ChatUserImageModel> chatImages = await ChatApiClient().getUsersImages(encryptedEmails: emails);
|
|
|
|
|
searchedChats!.add(
|
|
|
|
|
ChatUser(
|
|
|
|
|
id: targetUserId,
|
|
|
|
|
userName: targetUserName,
|
|
|
|
|
unreadMessageCount: 0,
|
|
|
|
|
email: userEmail,
|
|
|
|
|
isImageLoading: false,
|
|
|
|
|
image: "",
|
|
|
|
|
image: chatImages.first.profilePicture ?? "",
|
|
|
|
|
isImageLoaded: true,
|
|
|
|
|
isTyping: false,
|
|
|
|
|
isFav: false,
|
|
|
|
|
userStatus: userStatus,
|
|
|
|
|
userLocalDownlaodedImage: null,
|
|
|
|
|
userLocalDownlaodedImage: await downloadImageLocal(chatImages.first.profilePicture, targetUserId.toString()),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
notifyListeners();
|
|
|
|
|
|