This UX question is unusual in that it deals with the user experience across several devices and modalities, and not just within one screen.
Suppose you have a chat app that can be accessed from various clients running on laptop, tablet, mobile, etc. Messages come in and are sent to all participants in the chatroom. At any time each client might be "online" or "offline" relative to the server. Sometimes the chatroom is visible in the client, other times it is in some hidden tab, i.e. not shown.
- Suppose the user subscribed to get offline notifications for new messages in the chat. When do we send them?
One case is easy: if no clients are online. But what if one client is online and the chatroom is in the foreground? So the message has been "seen". But what if a person leaves a chatroom open on their desktop and walks away with their phone? Throughout the next day or more, they won't get any offline notifications. To solve this "perfectly" it seems I would have to use bluetooth pairing or track the movement of the user's phone. Or I could just have a really timeout of a minute or so for when there is no mouse movement or something.
- An even more serious issue is what I should show for Unread Message Counts. On each client, I can store the triple (user X in chat Y saw up to message Z). This is cheap and easy to store on the client side. But then each client will show the number of unread messages relative to that client. This kind of intersects with point #1, namely, what if some other client has already displayed the message? Should the software assume that it was displayed to me over there, and therefore mark the message as read on all other clients?
Tech stuff follows
For #2, the trade-off is this. I am pretty sure that syncing across clients is more desirable, but it's very expensive from a tech point of view. Updating the triple (X, Y, Z) on the server requires an additional acknowledgment for every message in every chatroom from every client. This doesn't just double the traffic but also makes the server lock the (X, Y) rows in the database in order to increment the count of Z. This lock isn't too bad, since it's not like a user will have millions of clients open at the same time, probably only 3 or 4 max. But that's still a huge number of acknowledgments and locks just to sync (X, Y, Z) triples across clients.
My question in #2 is, is it good enough to show unread messages per client without syncing, or syncing (X, Y, Z) triples for unread messages is so vastly better that I should pay the price of all this extra traffic?