Read Issue On Sub Page

merge-requests/107/head
Aamir Muhammad 3 years ago
parent 2266ace39a
commit cb4b95ddb4

@ -36,7 +36,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
String chatCID = ''; String chatCID = '';
bool isLoading = true; bool isLoading = true;
bool isChatScreenActive = false; bool isChatScreenActive = false;
int ReceiverID = 0; int receiverID = 0;
late File selectedFile; late File selectedFile;
bool isFileSelected = false; bool isFileSelected = false;
@ -144,7 +144,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
if (isNewChat) userChatHistory = []; if (isNewChat) userChatHistory = [];
if (!loadMore) paginationVal = 0; if (!loadMore) paginationVal = 0;
isChatScreenActive = true; isChatScreenActive = true;
ReceiverID = receiverUID; receiverID = receiverUID;
Response response = await ChatApiClient().getSingleUserChatHistory(senderUID: senderUID, receiverUID: receiverUID, loadMore: loadMore, paginationVal: paginationVal); Response response = await ChatApiClient().getSingleUserChatHistory(senderUID: senderUID, receiverUID: receiverUID, loadMore: loadMore, paginationVal: paginationVal);
if (response.statusCode == 204) { if (response.statusCode == 204) {
if (isNewChat) { if (isNewChat) {
@ -163,7 +163,9 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
isLoading = false; isLoading = false;
notifyListeners(); notifyListeners();
if (isChatScreenActive && receiverUID == receiverID) {
markRead(userChatHistory, receiverUID); markRead(userChatHistory, receiverUID);
}
generateConvId(); generateConvId();
} }
@ -374,7 +376,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
} }
} }
setMsgTune(); setMsgTune();
if (isChatScreenActive && data.first.currentUserId == ReceiverID) { if (isChatScreenActive && data.first.currentUserId == receiverID) {
userChatHistory.insert(0, data.first); userChatHistory.insert(0, data.first);
} }
@ -389,7 +391,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
} }
List list = [ List list = [
{"userChatHistoryId": data.first.userChatHistoryId, "TargetUserId": temp.first.targetUserId, "isDelivered": true, "isSeen": isChatScreenActive ? true : false} {"userChatHistoryId": data.first.userChatHistoryId, "TargetUserId": temp.first.targetUserId, "isDelivered": true, "isSeen": isChatScreenActive && data.first.currentUserId == receiverID ? true : false}
]; ];
updateUserChatHistoryOnMsg(list); updateUserChatHistoryOnMsg(list);
invokeChatCounter(userId: AppState().chatDetails!.response!.id!); invokeChatCounter(userId: AppState().chatDetails!.response!.id!);
@ -751,6 +753,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
searchedChats = pChatHistory; searchedChats = pChatHistory;
search.clear(); search.clear();
isChatScreenActive = false; isChatScreenActive = false;
receiverID = 0;
paginationVal = 0; paginationVal = 0;
message.text = ''; message.text = '';
isFileSelected = false; isFileSelected = false;
@ -764,6 +767,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
searchedChats = pChatHistory; searchedChats = pChatHistory;
search.clear(); search.clear();
isChatScreenActive = false; isChatScreenActive = false;
receiverID = 0;
paginationVal = 0; paginationVal = 0;
message.text = ''; message.text = '';
isFileSelected = false; isFileSelected = false;

Loading…
Cancel
Save