Bug: message.sent and message.sentAt
fabriguespe opened this issue · comments
Describe the bug
Messages loaded using display date with sentAt
field
const { messages, isLoading } = useMessages(conversation);
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]
);
Expected behavior
No response
Steps to reproduce the bug
No response
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.
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],
);