Fav Users Images Fix

merge-requests/100/head
Aamir Muhammad 3 years ago
parent ef347f1078
commit feb5c5071c

@ -127,7 +127,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
);
sort();
notifyListeners();
if (searchedChats!.isNotEmpty) {
if (searchedChats!.isNotEmpty || favUsersList.isNotEmpty) {
getUserImages();
}
}
@ -142,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 {
@ -765,9 +757,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) {
@ -848,7 +849,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.");
}

@ -72,6 +72,9 @@ class _DashboardScreenState extends State<DashboardScreen> {
void _bHubCon() {
cProvider.getUserAutoLoginToken().whenComplete(() {
cProvider.buildHubConnection();
Future.delayed(const Duration(seconds: 2), () {
cProvider.invokeChatCounter(userId: AppState().chatDetails!.response!.id!);
});
});
}

Loading…
Cancel
Save