Chat Updates & Counter Event Modifications

merge-requests/64/head
Aamir Muhammad 3 years ago
parent 2e88275285
commit 76169e5cb8

@ -87,11 +87,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
token: AppState().chatDetails!.response!.token, token: AppState().chatDetails!.response!.token,
); );
ChatUserModel favUList = userToList(favRes.body); ChatUserModel favUList = userToList(favRes.body);
GetUserChatHistoryNotDeliveredAsync(
userId: int.parse(
AppState().chatDetails!.response!.id.toString(),
),
);
if (favUList.response != null && recentChat.response != null) { if (favUList.response != null && recentChat.response != null) {
favUsersList = favUList.response!; favUsersList = favUList.response!;
favUsersList.sort( favUsersList.sort(
@ -119,7 +115,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
notifyListeners(); notifyListeners();
} }
Future GetUserChatHistoryNotDeliveredAsync({required int userId}) async { Future getUserChatHistoryNotDeliveredAsync({required int userId}) async {
await hubConnection.invoke( await hubConnection.invoke(
"GetUserChatHistoryNotDeliveredAsync", "GetUserChatHistoryNotDeliveredAsync",
args: [userId], args: [userId],
@ -157,7 +153,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
).reversed.toList(); ).reversed.toList();
} }
} }
await GetUserChatHistoryNotDeliveredAsync( await getUserChatHistoryNotDeliveredAsync(
userId: senderUID, userId: senderUID,
); );
isLoading = false; isLoading = false;
@ -274,6 +270,11 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
); );
if (hubConnection.state != HubConnectionState.Connected) { if (hubConnection.state != HubConnectionState.Connected) {
await hubConnection.start(); await hubConnection.start();
getUserChatHistoryNotDeliveredAsync(
userId: int.parse(
AppState().chatDetails!.response!.id.toString(),
),
);
hubConnection.on("OnUpdateUserStatusAsync", changeStatus); hubConnection.on("OnUpdateUserStatusAsync", changeStatus);
hubConnection.on("OnDeliveredChatUserAsync", onMsgReceived); hubConnection.on("OnDeliveredChatUserAsync", onMsgReceived);
// hubConnection.on("OnSeenChatUserAsync", onChatSeen); // hubConnection.on("OnSeenChatUserAsync", onChatSeen);
@ -565,14 +566,14 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
} }
if (isFileSelected && !isMsgReply) { if (isFileSelected && !isMsgReply) {
Utils.showLoading(context); Utils.showLoading(context);
logger.d("Normal Attachment Message"); //logger.d("Normal Attachment Message");
dynamic value = await uploadAttachments(AppState().chatDetails!.response!.id.toString(), selectedFile); dynamic value = await uploadAttachments(AppState().chatDetails!.response!.id.toString(), selectedFile);
String? ext = getFileExtension(selectedFile.path); String? ext = getFileExtension(selectedFile.path);
Utils.hideLoading(context); Utils.hideLoading(context);
sendChatToServer(chatEventId: 2, fileTypeId: getFileType(ext.toString()), targetUserId: targetUserId, targetUserName: targetUserName, isAttachment: true, chatReplyId: null, isReply: false); sendChatToServer(chatEventId: 2, fileTypeId: getFileType(ext.toString()), targetUserId: targetUserId, targetUserName: targetUserName, isAttachment: true, chatReplyId: null, isReply: false);
} }
if (!isFileSelected && isMsgReply) { if (!isFileSelected && isMsgReply) {
logger.d("Normal Text Message With Reply"); // logger.d("Normal Text Message With Reply");
if (message.text == null || message.text.isEmpty) { if (message.text == null || message.text.isEmpty) {
return; return;
} }
@ -580,7 +581,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
chatEventId: 1, fileTypeId: null, targetUserId: targetUserId, targetUserName: targetUserName, chatReplyId: repliedMsg.first.userChatHistoryId, isAttachment: false, isReply: true); chatEventId: 1, fileTypeId: null, targetUserId: targetUserId, targetUserName: targetUserName, chatReplyId: repliedMsg.first.userChatHistoryId, isAttachment: false, isReply: true);
} }
if (isFileSelected && isMsgReply) { if (isFileSelected && isMsgReply) {
logger.d("Attachment Message With Reply"); // logger.d("Attachment Message With Reply");
Utils.showLoading(context); Utils.showLoading(context);
dynamic value = await uploadAttachments(AppState().chatDetails!.response!.id.toString(), selectedFile); dynamic value = await uploadAttachments(AppState().chatDetails!.response!.id.toString(), selectedFile);
String? ext = getFileExtension(selectedFile.path); String? ext = getFileExtension(selectedFile.path);

Loading…
Cancel
Save