From 1d36026cb7c70598d4569ac587f2a02c6356a88a Mon Sep 17 00:00:00 2001 From: lizandrogd <77708265+lizandrogd@users.noreply.github.com> Date: Tue, 22 Aug 2023 16:00:57 -0500 Subject: [PATCH] Revert "notificacion chat" This reverts commit 96edb73a882f65ca8a5b3c4a3945ea837511fb11. --- lib/src/screens/chat.dart | 43 +++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/lib/src/screens/chat.dart b/lib/src/screens/chat.dart index 358fcab..0d35d48 100644 --- a/lib/src/screens/chat.dart +++ b/lib/src/screens/chat.dart @@ -54,6 +54,9 @@ class _ChatScreenState extends State { }, ), ); + + print(token); + print(response); response; } catch (e) { print('error al enviar notificacion $e'); @@ -198,29 +201,25 @@ class _ChatScreenState extends State { }); if (user?.token != '') { - sendPushNotification(user!.token!); + final mensajesQuerySnapshot = + await FirebaseFirestore.instance + .collection('chats') + .doc(widget.eventoId) + .get(); + final mensajes = + mensajesQuerySnapshot.data()?['message']; + if (mensajes != null && mensajes.isNotEmpty) { + final ultimoMensaje = mensajes.last; + final ultimoMensajeUser = ultimoMensaje['user']; + if (ultimoMensajeUser == uid) { + // El último mensaje fue enviado por ti, no se envía la notificación + } else { + sendPushNotification(user!.token!); + } + } else { + sendPushNotification(user!.token!); + } } - - // if (user?.token != '') { - // final mensajesQuerySnapshot = - // await FirebaseFirestore.instance - // .collection('chats') - // .doc(widget.eventoId) - // .get(); - // final mensajes = - // mensajesQuerySnapshot.data()?['message']; - // if (mensajes != null && mensajes.isNotEmpty) { - // final ultimoMensaje = mensajes.last; - // final ultimoMensajeUser = ultimoMensaje['user']; - // if (ultimoMensajeUser == uid) { - // // El último mensaje fue enviado por ti, no se envía la notificación - // } else { - // sendPushNotification(user!.token!); - // } - // } else { - // sendPushNotification(user!.token!); - // } - // } _textController.clear(); } },