This commit is contained in:
Felipe
2024-04-25 11:47:34 -05:00
parent c64df99bfb
commit 171b3fd926
+10 -5
View File
@@ -74,6 +74,7 @@ class _ChatScreenState extends State<ChatScreen> {
AsyncSnapshot<List<dynamic>?> snapshot) { AsyncSnapshot<List<dynamic>?> snapshot) {
if (_userInfo != null) { if (_userInfo != null) {
final userInfo = _userInfo![0] as MyUser; final userInfo = _userInfo![0] as MyUser;
return Container( return Container(
padding: const EdgeInsets.symmetric(vertical: 8), padding: const EdgeInsets.symmetric(vertical: 8),
color: const Color(0xFFD6F4FF), color: const Color(0xFFD6F4FF),
@@ -240,6 +241,7 @@ class _ChatScreenState extends State<ChatScreen> {
if (_userInfo != null) { if (_userInfo != null) {
final userInfo = _userInfo![0] as MyUser; final userInfo = _userInfo![0] as MyUser;
final myInfo = _userInfo![1] as MyUser;
if (userInfo.token == null) return; if (userInfo.token == null) return;
@@ -250,7 +252,7 @@ class _ChatScreenState extends State<ChatScreen> {
LocalNotifications.sendPushNotification( LocalNotifications.sendPushNotification(
userInfo.token!, userInfo.token!,
'Nuevo mensaje', 'Nuevo mensaje',
'Tienes un nuevo mensaje de ${userInfo.name}', 'Tienes un nuevo mensaje de ${myInfo.name}',
); );
_lastNotificationTime = DateTime.now(); _lastNotificationTime = DateTime.now();
@@ -282,6 +284,7 @@ class _ChatScreenState extends State<ChatScreen> {
if (_userInfo != null) { if (_userInfo != null) {
final userInfo = _userInfo![0] as MyUser; final userInfo = _userInfo![0] as MyUser;
final myInfo = _userInfo![1] as MyUser;
if (userInfo.token == null) return; if (userInfo.token == null) return;
@@ -292,7 +295,7 @@ class _ChatScreenState extends State<ChatScreen> {
LocalNotifications.sendPushNotification( LocalNotifications.sendPushNotification(
userInfo.token!, userInfo.token!,
'Nuevo mensaje', 'Nuevo mensaje',
'Tienes un nuevo mensaje de ${userInfo.name}', 'Tienes un nuevo mensaje de ${myInfo.name}',
); );
_lastNotificationTime = DateTime.now(); _lastNotificationTime = DateTime.now();
@@ -414,19 +417,21 @@ class _ChatScreenState extends State<ChatScreen> {
.toList(); .toList();
} }
Future<List<dynamic>> _getUserAndProfessionalInfo( Future<List<dynamic>> _getUserAndProfessionalInfo(ServiceEntity service) async {
ServiceEntity service) async {
final userRepo = FirebaseUserRepository(FirebaseAuth.instance); final userRepo = FirebaseUserRepository(FirebaseAuth.instance);
final MyUser? userInfo; final MyUser? userInfo;
final MyUser? myInfo;
if (FirebaseAuth.instance.currentUser!.uid == service.userId) { if (FirebaseAuth.instance.currentUser!.uid == service.userId) {
userInfo = await userRepo.getMyUser(service.professionalId); userInfo = await userRepo.getMyUser(service.professionalId);
myInfo = await userRepo.getMyUser(service.userId);
} else { } else {
userInfo = await userRepo.getMyUser(service.userId); userInfo = await userRepo.getMyUser(service.userId);
myInfo = await userRepo.getMyUser(service.professionalId);
} }
return [userInfo]; return [userInfo, myInfo];
} }
double calculoRating(double average) { double calculoRating(double average) {