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

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

Loading…
Cancel
Save