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

Bug: message.sent and message.sentAt #208

Closed
humanagent opened this issue Feb 29, 2024 · 2 comments
Closed

Bug: message.sent and message.sentAt #208

humanagent opened this issue Feb 29, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@humanagent
Copy link
Contributor

Describe the bug

Messages loaded using display date with sentAt field

const { messages, isLoading } = useMessages(conversation);

CleanShot 2024-02-29 at 13 38 20@2x

While messages loaded via a stream show the date with the sent field

  const onMessage = useCallback(
    (message) => {
      console.log("onMessage", message.content);
      setStreamedMessages((prev) => [...prev, message]);
    },
    [streamedMessages]
  );

CleanShot 2024-02-29 at 13 38 33@2x

Expected behavior

No response

Steps to reproduce the bug

No response

@humanagent humanagent added the bug Something isn't working label Feb 29, 2024
@rygine
Copy link
Collaborator

rygine commented Mar 3, 2024

thanks for the report! yes, the onMessage callback references the DecodedMessage in its callback rather than the CachedMessage.

this is intentional for developers who want to access the original DecodedMessage. it's easy to convert to a cached message with the toCachedMessage export from the React SDK.

@humanagent humanagent self-assigned this Mar 4, 2024
@humanagent
Copy link
Contributor Author

Thks! adding the code for reference

// callback to handle incoming messages
  const onMessage = useCallback(
    (message: DecodedMessage) => {
      // Convert into cached message format
      const cached = toCachedMessage(message);
      //Add it to the array
      setStreamedMessages((prev) => [...prev, cached]);
    },
    [streamedMessages],
  );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants