flyerhq / flutter_firebase_chat_core

Actively maintained, community-driven Firebase BaaS for chat applications with an optional chat UI.
https://flyer.chat
Apache License 2.0
248 stars 201 forks source link

Message status : "Unread" and "seen" #9

Open giorgio79 opened 3 years ago

giorgio79 commented 3 years ago

Does the package track message status like unread or seen? I think the demo chat by the Firebase team has some code for that https://firechat.firebaseapp.com/

demchenkoalex commented 3 years ago

In the documentation we provide an example for delivered status, but we didn't add the seen example because it requires a paid plan. We for sure want to add this in the future, it should be done inside cloud functions and may or may not require some additional events from this package. Right now we have some other priorities, but I will leave this one opened in case anyone will want to open a PR.

femidof commented 2 years ago

In the documentation we provide an example for delivered status, but we didn't add the seen example because it requires a paid plan. We for sure want to add this in the future, it should be done inside cloud functions and may or may not require some additional events from this package. Right now we have some other priorities, but I will leave this one opened in case anyone will want to open a PR.

Thank you so much for this package, tested the use of the delivered status, and i would like to add that the latency to get the delivered status and especially the last message isn't good. I don't know if I'm the only one with this problem but i was thinking if the plugin could could embed the delivered status instead of cloud firestore to trigger the changes, it could be done from plugin with the frontend in communication with firestore

demchenkoalex commented 2 years ago

can you elaborate a bit more please, I don't think I follow :( how frontend will set the delivered status if we are not sure it was actually delivered until server responds it was?

louislamlam commented 2 years ago

My solution to update "seen" status:

  1. Store users online status every time they enter the room.
  2. Update "delivered" messages by calling a cloud function or update directly from client.
  3. Update the cloud function in example - lookup the user online status in Step 1 and check whether its necessary to update message status from "delivered" to "seen".

I'm not sure it's good way to do so, let me know if you have any better solutions.

giorgio79 commented 1 year ago

Sounds good @louislamme , can you share this cloud function?

Alternatively, if we store the last access time of the user, and the last message time to the user in the chat room meta data, we can compare if last access time by user was before the last message time to the user, and in that case the user has unread message(s). Got this idea from stackoverflow here https://stackoverflow.com/questions/22623879/managing-unread-messages-in-firebase-chat/64674829#comment57522035_22645372