|
|
|
|
@ -91,7 +91,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void getSingleUserChatHistory({required String senderUID, required int receiverUID, required bool loadMore}) async {
|
|
|
|
|
void getSingleUserChatHistory({required String senderUID, required int receiverUID, required bool loadMore, bool isNewChat = false}) async {
|
|
|
|
|
isLoading = true;
|
|
|
|
|
if (!loadMore) paginationVal = 0;
|
|
|
|
|
isChatScreenActive = true;
|
|
|
|
|
@ -100,8 +100,12 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
|
token: AppState().chatDetails!.response!.token,
|
|
|
|
|
);
|
|
|
|
|
if (response.statusCode == 204) {
|
|
|
|
|
if (!loadMore) userChatHistory = [];
|
|
|
|
|
Utils.showToast("No More Data To Load");
|
|
|
|
|
if (isNewChat) {
|
|
|
|
|
userChatHistory = [];
|
|
|
|
|
} else if (loadMore) {
|
|
|
|
|
// userChatHistory = [];
|
|
|
|
|
Utils.showToast("No More Data To Load");
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (loadMore) {
|
|
|
|
|
List<SingleUserChatModel> temp = getSingleUserChatModel(response.body);
|
|
|
|
|
@ -131,7 +135,12 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
|
} else {
|
|
|
|
|
result = [];
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
if (kDebugMode) {
|
|
|
|
|
print(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -139,11 +148,9 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
|
HttpConnectionOptions httpOp = HttpConnectionOptions(skipNegotiation: false, logMessageContent: true);
|
|
|
|
|
hubConnection = HubConnectionBuilder()
|
|
|
|
|
.withUrl(ApiConsts.chatHubConnectionUrl + "?UserId=${AppState().chatDetails!.response!.id}&source=Web&access_token=${AppState().chatDetails!.response!.token}", options: httpOp)
|
|
|
|
|
.withAutomaticReconnect(retryDelays: [2000, 5000, 10000, 20000])
|
|
|
|
|
.configureLogging(
|
|
|
|
|
Logger("Logs Enabled"),
|
|
|
|
|
)
|
|
|
|
|
.build();
|
|
|
|
|
.withAutomaticReconnect(
|
|
|
|
|
retryDelays: <int>[2000, 5000, 10000, 20000],
|
|
|
|
|
).build();
|
|
|
|
|
hubConnection.onclose(
|
|
|
|
|
({Exception? error}) {},
|
|
|
|
|
);
|
|
|
|
|
@ -157,6 +164,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
|
await hubConnection.start();
|
|
|
|
|
hubConnection.on("OnUpdateUserStatusAsync", changeStatus);
|
|
|
|
|
hubConnection.on("OnDeliveredChatUserAsync", onMsgReceived);
|
|
|
|
|
hubConnection.on("OnSeenChatUserAsync", onChatSeen);
|
|
|
|
|
|
|
|
|
|
//hubConnection.on("OnUserTypingAsync", onUserTyping);
|
|
|
|
|
// hubConnection.on("OnUserCountAsync", userCountAsync);
|
|
|
|
|
@ -179,6 +187,18 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void onChatSeen(List<Object?>? args) {
|
|
|
|
|
dynamic items = args!.toList();
|
|
|
|
|
logger.d("---------------------------------Chat Seen -------------------------------------");
|
|
|
|
|
logger.d(items);
|
|
|
|
|
// for (var user in searchedChats!) {
|
|
|
|
|
// if (user.id == items.first["id"]) {
|
|
|
|
|
// user.userStatus = items.first["userStatus"];
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void userCountAsync(List<Object?>? args) {
|
|
|
|
|
dynamic items = args!.toList();
|
|
|
|
|
//logger.d("---------------------------------User Count Async -------------------------------------");
|
|
|
|
|
|