code-corps-ember
code-corps-ember copied to clipboard
Mark conversations as read
What's in this PR?
WIP.
Basic logic is the following:
- check the conversation or its latest conversation part has not been read and that it can be marked as read by this user
- if yes,
PATCHconversation with virtual attributeread: true- on the server this should update
readAtfor the conversation if the current user can mark it as read - sets
readAtfor all conversation parts wherereadAtisnulland the current user can mark it as read
- on the server this should update
- if no, do nothing
- if yes,
We mark the message read when the user is active and either of the following are true:
- The conversation is unread and either:
- The message was sent by an admin and the user is the target
- The message was sent to the project and the user did not author it
- The latest conversation part is unread and either:
- The user is the target and the part was not written by them
- The user is a project admin and the part was written by the target
A lot of this logic being done client-side may need to be reimplemented server-side, but my thinking here is that we are saving a potentially large number of network requests by doing some client-side checking. Distributed computing on the client in JS is much cheaper than paid servers.
I'm sure this logic can be refactored/simplified, especially since I'm tired now. It does seem like the hard parts are mostly figured out, though.