|
|
|
@ -127,7 +127,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
sort();
|
|
|
|
sort();
|
|
|
|
notifyListeners();
|
|
|
|
notifyListeners();
|
|
|
|
if (searchedChats!.isNotEmpty) {
|
|
|
|
if (searchedChats!.isNotEmpty || favUsersList.isNotEmpty) {
|
|
|
|
getUserImages();
|
|
|
|
getUserImages();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -142,19 +142,11 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
if (isNewChat) userChatHistory = [];
|
|
|
|
if (isNewChat) userChatHistory = [];
|
|
|
|
if (!loadMore) paginationVal = 0;
|
|
|
|
if (!loadMore) paginationVal = 0;
|
|
|
|
isChatScreenActive = true;
|
|
|
|
isChatScreenActive = true;
|
|
|
|
// if (chatHubConnection.state != HubConnectionState.Connected) {
|
|
|
|
|
|
|
|
// getUserAutoLoginToken().whenComplete(() async {
|
|
|
|
|
|
|
|
// await buildHubConnection();
|
|
|
|
|
|
|
|
// getSingleUserChatHistory(senderUID: senderUID, receiverUID: receiverUID, loadMore: loadMore);
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
// return;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
Response response = await ChatApiClient().getSingleUserChatHistory(senderUID: senderUID, receiverUID: receiverUID, loadMore: loadMore, paginationVal: paginationVal);
|
|
|
|
Response response = await ChatApiClient().getSingleUserChatHistory(senderUID: senderUID, receiverUID: receiverUID, loadMore: loadMore, paginationVal: paginationVal);
|
|
|
|
if (response.statusCode == 204) {
|
|
|
|
if (response.statusCode == 204) {
|
|
|
|
if (isNewChat) {
|
|
|
|
if (isNewChat) {
|
|
|
|
userChatHistory = [];
|
|
|
|
userChatHistory = [];
|
|
|
|
} else if (loadMore) {
|
|
|
|
} else if (loadMore) {
|
|
|
|
// userChatHistory = [];
|
|
|
|
|
|
|
|
Utils.showToast("No More Data To Load");
|
|
|
|
Utils.showToast("No More Data To Load");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
@ -765,9 +757,18 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
|
|
|
|
|
|
|
|
void getUserImages() async {
|
|
|
|
void getUserImages() async {
|
|
|
|
List<String> emails = [];
|
|
|
|
List<String> emails = [];
|
|
|
|
for (ChatUser element in searchedChats!) {
|
|
|
|
List<ChatUser> exists = [], unique = [];
|
|
|
|
|
|
|
|
exists.addAll(searchedChats!);
|
|
|
|
|
|
|
|
exists.addAll(favUsersList!);
|
|
|
|
|
|
|
|
Map<String, ChatUser> profileMap = {};
|
|
|
|
|
|
|
|
for (ChatUser item in exists) {
|
|
|
|
|
|
|
|
profileMap[item.email!] = item;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
unique = profileMap.values.toList();
|
|
|
|
|
|
|
|
for (ChatUser element in unique!) {
|
|
|
|
emails.add(await EmailImageEncryption().encrypt(val: element.email!));
|
|
|
|
emails.add(await EmailImageEncryption().encrypt(val: element.email!));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
List<ChatUserImageModel> chatImages = await ChatApiClient().getUsersImages(encryptedEmails: emails);
|
|
|
|
List<ChatUserImageModel> chatImages = await ChatApiClient().getUsersImages(encryptedEmails: emails);
|
|
|
|
for (ChatUser user in searchedChats!) {
|
|
|
|
for (ChatUser user in searchedChats!) {
|
|
|
|
for (ChatUserImageModel uImage in chatImages) {
|
|
|
|
for (ChatUserImageModel uImage in chatImages) {
|
|
|
|
@ -848,7 +849,6 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
String path = await downChatMedia(encodedString, fileTypeName ?? "");
|
|
|
|
String path = await downChatMedia(encodedString, fileTypeName ?? "");
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
OpenFile.open(path);
|
|
|
|
OpenFile.open(path);
|
|
|
|
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
} catch (e) {
|
|
|
|
Utils.showToast("Cannot open file.");
|
|
|
|
Utils.showToast("Cannot open file.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|