Chat Fixes & User Chat Counter

merge-requests/81/head
Aamir Muhammad 3 years ago
parent 13a7f60d67
commit 6a3c6a25d0

@ -38,10 +38,10 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
void registerEvents() { void registerEvents() {
hubConnection.on("OnUpdateUserStatusAsync", changeStatus); hubConnection.on("OnUpdateUserStatusAsync", changeStatus);
hubConnection.on("OnDeliveredChatUserAsync", onMsgReceived); hubConnection.on("OnDeliveredChatUserAsync", onMsgReceived);
hubConnection.on("OnSeenChatUserAsync", onChatSeen); // hubConnection.on("OnSeenChatUserAsync", onChatSeen);
//hubConnection.on("OnUserTypingAsync", onUserTyping); //hubConnection.on("OnUserTypingAsync", onUserTyping);
hubConnection.on("OnUserCountAsync", userCountAsync); hubConnection.on("OnUserCountAsync", userCountAsync);
hubConnection.on("OnUpdateUserChatHistoryWindowsAsync", updateChatHistoryWindow); // hubConnection.on("OnUpdateUserChatHistoryWindowsAsync", updateChatHistoryWindow);
hubConnection.on("OnGetUserChatHistoryNotDeliveredAsync", chatNotDelivered); hubConnection.on("OnGetUserChatHistoryNotDeliveredAsync", chatNotDelivered);
hubConnection.on("OnUpdateUserChatHistoryStatusAsync", updateUserChatStatus); hubConnection.on("OnUpdateUserChatHistoryStatusAsync", updateUserChatStatus);
} }
@ -108,7 +108,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
} }
isLoading = false; isLoading = false;
notifyListeners(); notifyListeners();
// markRead(userChatHistory, receiverUID); markRead(userChatHistory, receiverUID);
generateConvId(); generateConvId();
} }
@ -124,7 +124,12 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
if (!element.isSeen!) { if (!element.isSeen!) {
element.isSeen = true; element.isSeen = true;
dynamic data = [ dynamic data = [
{"userChatHistoryId": element.userChatHistoryId, "TargetUserId": element.currentUserId, "isDelivered": true, "isSeen": true} {
"userChatHistoryId": element.userChatHistoryId,
"TargetUserId": element.currentUserId == receiverID ? element.currentUserId : element.targetUserId,
"isDelivered": true,
"isSeen": true,
}
]; ];
updateUserChatHistoryStatusAsync(data); updateUserChatHistoryStatusAsync(data);
notifyListeners(); notifyListeners();
@ -190,8 +195,6 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
void onChatSeen(List<Object?>? args) { void onChatSeen(List<Object?>? args) {
dynamic items = args!.toList(); dynamic items = args!.toList();
logger.d("---------------------------------Chat Seen -------------------------------------");
logger.d(items);
// for (var user in searchedChats!) { // for (var user in searchedChats!) {
// if (user.id == items.first["id"]) { // if (user.id == items.first["id"]) {
// user.userStatus = items.first["userStatus"]; // user.userStatus = items.first["userStatus"];

@ -84,6 +84,7 @@ class _ChatHomeScreenState extends State<ChatHomeScreen> {
itemCount: m.searchedChats!.length, itemCount: m.searchedChats!.length,
shrinkWrap: true, shrinkWrap: true,
physics: const ClampingScrollPhysics(), physics: const ClampingScrollPhysics(),
padding: EdgeInsets.only(bottom: 80.0),
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
return SizedBox( return SizedBox(
height: 55, height: 55,
@ -189,14 +190,13 @@ class _ChatHomeScreenState extends State<ChatHomeScreen> {
AppRoutes.chatDetailed, AppRoutes.chatDetailed,
arguments: {"targetUser": m.searchedChats![index], "isNewChat": false}, arguments: {"targetUser": m.searchedChats![index], "isNewChat": false},
).then((Object? value) { ).then((Object? value) {
// m.GetUserChatHistoryNotDeliveredAsync(userId: int.parse(AppState().chatDetails!.response!.id.toString()));
m.clearSelections(); m.clearSelections();
m.notifyListeners(); m.notifyListeners();
}); });
}); });
}, },
separatorBuilder: (BuildContext context, int index) => const Divider(color: MyColors.lightGreyE5Color).paddingOnly(left: 59), separatorBuilder: (BuildContext context, int index) => const Divider(color: MyColors.lightGreyE5Color).paddingOnly(left: 59),
).paddingOnly(bottom: 70).expanded, ).expanded,
], ],
).paddingOnly(left: 21, right: 21); ).paddingOnly(left: 21, right: 21);
}, },

Loading…
Cancel
Save