|
|
|
|
@ -141,20 +141,13 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
|
)
|
|
|
|
|
.build();
|
|
|
|
|
hubConnection.onclose(
|
|
|
|
|
({Exception? error}) {
|
|
|
|
|
// logger.d(error);
|
|
|
|
|
},
|
|
|
|
|
({Exception? error}) {},
|
|
|
|
|
);
|
|
|
|
|
hubConnection.onreconnecting(
|
|
|
|
|
({Exception? error}) {
|
|
|
|
|
// logger.d(error);
|
|
|
|
|
// logger.d("Reconnecting");
|
|
|
|
|
},
|
|
|
|
|
({Exception? error}) {},
|
|
|
|
|
);
|
|
|
|
|
hubConnection.onreconnected(
|
|
|
|
|
({String? connectionId}) {
|
|
|
|
|
// logger.d("Reconnected");
|
|
|
|
|
},
|
|
|
|
|
({String? connectionId}) {},
|
|
|
|
|
);
|
|
|
|
|
if (hubConnection.state != HubConnectionState.Connected) {
|
|
|
|
|
await hubConnection.start();
|
|
|
|
|
@ -403,7 +396,6 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
|
sFileType = "";
|
|
|
|
|
message.clear();
|
|
|
|
|
notifyListeners();
|
|
|
|
|
// scrollDown();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void sendChatMessage(int targetUserId, String targetUserName) async {
|
|
|
|
|
@ -437,7 +429,6 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
|
}
|
|
|
|
|
sendChatToServer(
|
|
|
|
|
chatEventId: 1, fileTypeId: null, targetUserId: targetUserId, targetUserName: targetUserName, chatReplyId: repliedMsg.first.userChatHistoryId, isAttachment: false, isReply: true);
|
|
|
|
|
//chatReplyId
|
|
|
|
|
}
|
|
|
|
|
if (isFileSelected && isMsgReply) {
|
|
|
|
|
logger.d("Attachment Message With Reply");
|
|
|
|
|
@ -451,54 +442,8 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
|
targetUserName: targetUserName,
|
|
|
|
|
isAttachment: true,
|
|
|
|
|
chatReplyId: repliedMsg.first.userChatHistoryId,
|
|
|
|
|
isReply: true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// dynamic contain = searchedChats!.where((ChatUser element) => element.id == targetUserId);
|
|
|
|
|
// if (contain.isEmpty) {
|
|
|
|
|
// searchedChats!.add(
|
|
|
|
|
// ChatUser(
|
|
|
|
|
// id: targetUserId,
|
|
|
|
|
// userName: targetUserName,
|
|
|
|
|
// ),
|
|
|
|
|
// );
|
|
|
|
|
// notifyListeners();
|
|
|
|
|
// }
|
|
|
|
|
// Uuid uuid = const Uuid();
|
|
|
|
|
// dynamic fileID = fileUploadResponse.isEmpty ? null : getFileType(chatMessage);
|
|
|
|
|
// SingleUserChatModel data = SingleUserChatModel(
|
|
|
|
|
// chatEventId: fileUploadResponse.isEmpty ? 1 : 2,
|
|
|
|
|
// chatSource: 1,
|
|
|
|
|
// contant: chatMessage,
|
|
|
|
|
// contantNo: uuid.v4(),
|
|
|
|
|
// conversationId: uuid.v4(),
|
|
|
|
|
// createdDate: DateTime.now(),
|
|
|
|
|
// currentUserId: AppState().chatDetails!.response!.id,
|
|
|
|
|
// currentUserName: AppState().chatDetails!.response!.userName,
|
|
|
|
|
// targetUserId: targetUserId,
|
|
|
|
|
// targetUserName: targetUserName,
|
|
|
|
|
// fileTypeId: fileID,
|
|
|
|
|
// isReplied: false,
|
|
|
|
|
// // fileTypeResponse: FileTypeResponse(
|
|
|
|
|
// // fileTypeId: 0,
|
|
|
|
|
// // fileTypeDescription: fileUploadResponse.isEmpty ? null : fileUploadResponse.first["filePath"],
|
|
|
|
|
// // fileName: fileUploadResponse.isEmpty ? null : fileUploadResponse.first["filePath"],
|
|
|
|
|
// // fileKind: "image",
|
|
|
|
|
// // fileTypeName: fileUploadResponse.isEmpty ? null : fileUploadResponse.first["filePath"].toString().split(".").last),
|
|
|
|
|
// );
|
|
|
|
|
//
|
|
|
|
|
// String chatData =
|
|
|
|
|
// '{"contant":"$chatMessage","contantNo":"${uuid.v4()}","chatEventId":${fileUploadResponse.isEmpty ? 1 : 2},"fileTypeId": $fileID,"currentUserId":${AppState().chatDetails!.response!.id},"chatSource":1,"userChatHistoryLineRequestList":[{"isSeen":false,"isDelivered":false,"targetUserId":$targetUserId,"targetUserStatus":1}],"conversationId":"${uuid.v4()}"}';
|
|
|
|
|
// await hubConnection.invoke("AddChatUserAsync", args: <Object>[json.decode(chatData)]);
|
|
|
|
|
// userChatHistory.add(data);
|
|
|
|
|
// message.clear();
|
|
|
|
|
// notifyListeners();
|
|
|
|
|
// scrollDown();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void scrollListener() {
|
|
|
|
|
if (userChatHistory.length < paginationVal) {
|
|
|
|
|
print("Get New Data");
|
|
|
|
|
isReply: true,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -513,18 +458,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
|
} else {
|
|
|
|
|
Utils.showToast("Max 1 mb size is allowed to upload");
|
|
|
|
|
}
|
|
|
|
|
//Utils.showLoading(context);
|
|
|
|
|
notifyListeners();
|
|
|
|
|
//Utils.hideLoading(context);
|
|
|
|
|
// Utils.showLoading(context);
|
|
|
|
|
// await m.uploadAttachments(AppState().chatDetails!.response!.id.toString(), file).then((value) {
|
|
|
|
|
// if (value == null) {
|
|
|
|
|
// m.logger.d("Returned EMPTY");
|
|
|
|
|
// } else {
|
|
|
|
|
// m.sendChatMessage(value.isEmpty ? m.message.text : value.first["filePath"], userDetails["targetUser"].id, userDetails["targetUser"].userName, value);
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// Utils.hideLoading(context);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|