Chat Updates & Counter Event Modifications

merge-requests/62/head
Aamir Muhammad 3 years ago
parent 86ac29946f
commit fab16db8b3

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

Loading…
Cancel
Save