|
|
|
|
@ -125,8 +125,9 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
|
AppState().chatDetails!.response!.id.toString(),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
sort();
|
|
|
|
|
notifyListeners();
|
|
|
|
|
if (searchedChats!.isNotEmpty) {
|
|
|
|
|
if (searchedChats!.isNotEmpty || favUsersList.isNotEmpty) {
|
|
|
|
|
getUserImages();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -141,19 +142,11 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
|
if (isNewChat) userChatHistory = [];
|
|
|
|
|
if (!loadMore) paginationVal = 0;
|
|
|
|
|
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);
|
|
|
|
|
if (response.statusCode == 204) {
|
|
|
|
|
if (isNewChat) {
|
|
|
|
|
userChatHistory = [];
|
|
|
|
|
} else if (loadMore) {
|
|
|
|
|
// userChatHistory = [];
|
|
|
|
|
Utils.showToast("No More Data To Load");
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
@ -533,7 +526,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
|
await chatHubConnection.invoke("AddChatUserAsync", args: <Object>[json.decode(chatData)]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void sendChatMessage(int targetUserId, String targetUserName, BuildContext context) async {
|
|
|
|
|
void sendChatMessage(int targetUserId, int userStatus, String targetUserName, BuildContext context) async {
|
|
|
|
|
dynamic contain = searchedChats!.where((ChatUser element) => element.id == targetUserId);
|
|
|
|
|
if (contain.isEmpty) {
|
|
|
|
|
searchedChats!.add(
|
|
|
|
|
@ -546,6 +539,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
|
isImageLoaded: true,
|
|
|
|
|
isTyping: false,
|
|
|
|
|
isFav: false,
|
|
|
|
|
userStatus: userStatus,
|
|
|
|
|
userLocalDownlaodedImage: null,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
@ -764,9 +758,18 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
|
|
|
|
|
|
void getUserImages() async {
|
|
|
|
|
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!));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<ChatUserImageModel> chatImages = await ChatApiClient().getUsersImages(encryptedEmails: emails);
|
|
|
|
|
for (ChatUser user in searchedChats!) {
|
|
|
|
|
for (ChatUserImageModel uImage in chatImages) {
|
|
|
|
|
@ -847,7 +850,6 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
|
String path = await downChatMedia(encodedString, fileTypeName ?? "");
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
OpenFile.open(path);
|
|
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
Utils.showToast("Cannot open file.");
|
|
|
|
|
}
|
|
|
|
|
|