I want to track the number of unseen messages for each member of a group chat. I store chat metadata in a chats
collection, and messages for each chat in messages/{chatId}
.
I have checked other threads that ask about this, but in this scenario there's a group chat so it's more complicated. The threads that I have read suppose that it's a chat between two people.
I have thought about having a new collection seenMsgTimestamps
where I store the timestamp of the last message that a certain user has seen for each group chat. In my app, I will listen to changes to messages
starting from the the timestamp found in seenMsgTimestamps
for that chat, and count how many new messages are there.
Is this a good approach or is there a better way of doing this?
Thanks in advance.