Closed camerojo closed 8 months ago
Bug with browser refresh or initial login
I think what I need is a Hot observable. See https://www.learnrxjs.io/learn-rxjs/operators/multicasting - in particular some of the Additional resources. Including Ben Lesh.
Each chat will have a toggling button "Mark read/unread" (or something equivalent)
Clicking that button will send a message to the server, updating the database recording whether or not the chat has been read by the user.
The data can be stored in a table UserReadChat which stores an entry for each chat read by a user
user/chat/timestamp(or last read post id)
That entry records that the user has indicated that they have read the chat.
When a new post is made on a chat, all entries for that chat will be removed from the table - because the chat now contains new information unread by any user.
On the front end, a new component can be created which monitors and displays the read/unread status of a chat. Instances of this component are used to notify the user of new chat posts that they have not read. It may simply display an asterisk (for example) indicating that the chat has unread posts. This component queries the initial "read status" of the chat (from the UserReadChat table on the server), and then subscribes to the stream of post updates received by subscribing to the chat, merged with a stream of "user read chat" events. The latter stream is generated completely locally from the Angular code (rather than events from the server). The component subscribes to the stream when it is displayed, an unsubscribes when it is not displayed. A new chat post causes the component to display "unread", a "user read chat" event causes the component to display "read". @sadatmalik
Originally posted by @camerojo in https://github.com/Talent-Catalog/talentcatalog/issues/445#issuecomment-1826731942