Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Callback for "onRead" #167

Open
macinspak opened this issue Dec 11, 2024 · 0 comments
Open

Callback for "onRead" #167

macinspak opened this issue Dec 11, 2024 · 0 comments

Comments

@macinspak
Copy link

macinspak commented Dec 11, 2024

Problem statement:

Chat programs have a concept of "read" status for messages. But you cannot simply mark an entire message history "read" if a user taps on a conversation (naive implementation).

An intelligent implementation uses a number of heuristics such as:

  • Percentage of message on screen (above a watermark - ie 80% of the message is visible) then the message has been "read"
  • Time on screen or speed of scrolling while on screen (ie, if on screen for 5 seconds, or scrolling less than x pixels per second whilst visible
  • If the item just appears on the screen at all maybe is a simple heuristic
  • Also, providing a list of all items now "read" (ie: these 3 are now on screen even though they are marked unread by me). Rather than 3 individual notifications or callbacks.

So to achieve this, each user of chat-ui-kit-react needs to build the solution to detect on screen, duration, percentage to determine when a message has been read by this user. This logic is very similar and reusable and should be part of the library.

Solution proposed:

<Message> and <MessageList> (and any others that are relevant), should have an "onRead" callback.
The signature would be something like onRead([messages]) or likewise.

For instance, when using <MessageList> with messageContent as an array, the content may be pre-calculated, but the react view can provide an "onRead" callback to the <MessageList> component in the context of the component.

Parameters for heuristics can be passed to the <Message> or <MessageList> (or other) component as well, such as minimumReadTime=6000 (6seconds) or minimumReadPercent=0.5 (50% showing), etc.

When the message is determined "read" by the <MessageList> component, it collates and sends a list of all newly "read" messages to the callback.

The developer can then use that list to notify their server of the list of messages that this user has now read.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant