Merge branch 'development_aamir' into 'master'

Chat Fix

See merge request Cloud_Solution/mohemm-flutter-app!62
merge-requests/63/head
haroon amjad 3 years ago
commit 2d8ee5a8eb

@ -29,7 +29,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
late HubConnection hubConnection;
L.Logger logger = L.Logger();
bool hubConInitialized = false;
String chatCID = '';
bool isLoading = true;
bool isChatScreenActive = false;
late File selectedFile;
@ -40,17 +40,12 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
List<ChatUser> favUsersList = [];
int paginationVal = 0;
//Scroll
bool _firstAutoscrollExecuted = false;
bool _shouldAutoscroll = false;
Future<void> getUserAutoLoginToken(BuildContext cxt) async {
Response response = await ApiClient().postJsonForResponse(
"${ApiConsts.chatServerBaseApiUrl}user/externaluserlogin",
{
"employeeNumber": int.parse(
"employeeNumber":
AppState().memberInformationList!.eMPLOYEENUMBER.toString(),
),
"password": "FxIu26rWIKoF8n6mpbOmAjDLphzFGmpG"
},
);
@ -173,6 +168,12 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
userChatHistory,
receiverUID,
);
generateConvId();
}
void generateConvId() async {
Uuid uuid = const Uuid();
chatCID = uuid.v4();
}
void markRead(List<SingleUserChatModel> data, reciverID) {
@ -506,13 +507,14 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
Future<void> sendChatToServer(
{required int chatEventId, required fileTypeId, required int targetUserId, required String targetUserName, required chatReplyId, required bool isAttachment, required bool isReply}) async {
Uuid uuid = const Uuid();
var msg = message.text;
SingleUserChatModel data = SingleUserChatModel(
chatEventId: chatEventId,
chatSource: 1,
contant: msg,
contantNo: uuid.v4(),
conversationId: uuid.v4(),
conversationId: chatCID,
createdDate: DateTime.now(),
currentUserId: AppState().chatDetails!.response!.id,
currentUserName: AppState().chatDetails!.response!.userName,
@ -539,7 +541,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
notifyListeners();
String chatData =
'{"contant":"$msg","contantNo":"${uuid.v4()}","chatEventId":$chatEventId,"fileTypeId": $fileTypeId,"currentUserId":${AppState().chatDetails!.response!.id},"chatSource":1,"userChatHistoryLineRequestList":[{"isSeen":false,"isDelivered":false,"targetUserId":$targetUserId,"targetUserStatus":1}],"chatReplyId":$chatReplyId,"conversationId":"${uuid.v4()}"}';
'{"contant":"$msg","contantNo":"${uuid.v4()}","chatEventId":$chatEventId,"fileTypeId": $fileTypeId,"currentUserId":${AppState().chatDetails!.response!.id},"chatSource":1,"userChatHistoryLineRequestList":[{"isSeen":false,"isDelivered":false,"targetUserId":$targetUserId,"targetUserStatus":1}],"chatReplyId":$chatReplyId,"conversationId":"$chatCID"}';
await hubConnection.invoke("AddChatUserAsync", args: <Object>[json.decode(chatData)]);
}
@ -743,22 +745,22 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
sFileType = "";
}
void scrollListener() {
_firstAutoscrollExecuted = true;
if (scrollController.hasClients && scrollController.position.pixels == scrollController.position.maxScrollExtent) {
_shouldAutoscroll = true;
} else {
_shouldAutoscroll = false;
}
}
void scrollToBottom() {
scrollController.animateTo(
scrollController.position.maxScrollExtent + 100,
duration: const Duration(milliseconds: 500),
curve: Curves.easeIn,
);
}
// void scrollListener() {
// _firstAutoscrollExecuted = true;
// if (scrollController.hasClients && scrollController.position.pixels == scrollController.position.maxScrollExtent) {
// _shouldAutoscroll = true;
// } else {
// _shouldAutoscroll = false;
// }
// }
//
// void scrollToBottom() {
// scrollController.animateTo(
// scrollController.position.maxScrollExtent + 100,
// duration: const Duration(milliseconds: 500),
// curve: Curves.easeIn,
// );
// }
void msgScroll() {
scrollController.animateTo(

Loading…
Cancel
Save