|
|
|
@ -1,5 +1,6 @@
|
|
|
|
import 'dart:async';
|
|
|
|
import 'dart:async';
|
|
|
|
import 'dart:convert';
|
|
|
|
import 'dart:convert';
|
|
|
|
|
|
|
|
import 'dart:developer';
|
|
|
|
import 'dart:io';
|
|
|
|
import 'dart:io';
|
|
|
|
import 'dart:typed_data';
|
|
|
|
import 'dart:typed_data';
|
|
|
|
import 'package:audio_waveforms/audio_waveforms.dart';
|
|
|
|
import 'package:audio_waveforms/audio_waveforms.dart';
|
|
|
|
@ -251,6 +252,9 @@ class ChatProvider with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
chatHubConnection!.on("OnSubmitChatAsync", OnSubmitChatAsync);
|
|
|
|
chatHubConnection!.on("OnSubmitChatAsync", OnSubmitChatAsync);
|
|
|
|
chatHubConnection!.on("OnTypingAsync", OnTypingAsync);
|
|
|
|
chatHubConnection!.on("OnTypingAsync", OnTypingAsync);
|
|
|
|
chatHubConnection!.on("OnStopTypingAsync", OnStopTypingAsync);
|
|
|
|
chatHubConnection!.on("OnStopTypingAsync", OnStopTypingAsync);
|
|
|
|
|
|
|
|
//Need by Chat Backend for seen and un seen.
|
|
|
|
|
|
|
|
chatHubConnection!.on("OnSeenChatUserAsync", onSeenUserChatAsync);
|
|
|
|
|
|
|
|
chatHubConnection!.on("OnAckSeenAsync", onAckSeenAsync);
|
|
|
|
|
|
|
|
|
|
|
|
//group On message
|
|
|
|
//group On message
|
|
|
|
|
|
|
|
|
|
|
|
@ -468,6 +472,15 @@ class ChatProvider with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
print(args);
|
|
|
|
print(args);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> markMessageAsRead(int messageId) async {
|
|
|
|
|
|
|
|
final senderId = sender?.userId;
|
|
|
|
|
|
|
|
if (senderId == null) return;
|
|
|
|
|
|
|
|
chatHubConnection?.invoke(
|
|
|
|
|
|
|
|
"SendMessageReadAsync",
|
|
|
|
|
|
|
|
args: [messageId, senderId],
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void onChatSeen(List<Object?>? args) {
|
|
|
|
void onChatSeen(List<Object?>? args) {
|
|
|
|
dynamic items = args!.toList();
|
|
|
|
dynamic items = args!.toList();
|
|
|
|
// for (var user in searchedChats!) {
|
|
|
|
// for (var user in searchedChats!) {
|
|
|
|
@ -574,6 +587,57 @@ class ChatProvider with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
notifyListeners();
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> onSeenUserChatAsync(List<Object?>? parameters) async {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
if (parameters == null || parameters.isEmpty) {
|
|
|
|
|
|
|
|
log('onSeenUserChatAsync: parameters are null or empty');
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
final parm = parameters.first;
|
|
|
|
|
|
|
|
if (parm is! List || parm.isEmpty) {
|
|
|
|
|
|
|
|
log('onSeenUserChatAsync: parm is not a valid list');
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
final firstItem = parm.first;
|
|
|
|
|
|
|
|
if (firstItem is! Map<String, dynamic>) {
|
|
|
|
|
|
|
|
log('onSeenUserChatAsync: firstItem is not a Map');
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
await chatHubConnection!.invoke(
|
|
|
|
|
|
|
|
"AckSeenAsync",
|
|
|
|
|
|
|
|
args: [
|
|
|
|
|
|
|
|
firstItem['currentUserId'],
|
|
|
|
|
|
|
|
[firstItem['userChatHistoryId']],
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
} catch (e, stackTrace) {
|
|
|
|
|
|
|
|
log('onSeenUserChatAsync error: $e');
|
|
|
|
|
|
|
|
log('StackTrace: $stackTrace');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> onAckSeenAsync(List<Object?>? parameters) async {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
if (parameters == null || parameters.isEmpty) {
|
|
|
|
|
|
|
|
log('onAckSeenAsync: parameters are null or empty');
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
final parm = parameters.first;
|
|
|
|
|
|
|
|
log('parm onAckSeenAsync $parm');
|
|
|
|
|
|
|
|
if (chatResponseList.isEmpty) {
|
|
|
|
|
|
|
|
log('onAckSeenAsync: chatResponseList is empty');
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
log('last list item id ${chatResponseList.first.toJson()}');
|
|
|
|
|
|
|
|
chatResponseList.first.isSeen = true;
|
|
|
|
|
|
|
|
notifyListeners();
|
|
|
|
|
|
|
|
} catch (e, stackTrace) {
|
|
|
|
|
|
|
|
log('onAckSeenAsync error: $e');
|
|
|
|
|
|
|
|
log('StackTrace: $stackTrace');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Future<void> OnSubmitChatAsync(List<Object?>? parameters) async {
|
|
|
|
// Future<void> OnSubmitChatAsync(List<Object?>? parameters) async {
|
|
|
|
// // List data = jsonDecode(parameters!.first!.toString());
|
|
|
|
// // List data = jsonDecode(parameters!.first!.toString());
|
|
|
|
//
|
|
|
|
//
|
|
|
|
|