Open tassoevan opened 5 years ago
@tassoevan, I think you fixed it, right?
Livechat.onMessage(async(message) => {
if (message.ts instanceof Date) {
message.ts = message.ts.toISOString();
}
...
https://github.com/RocketChat/Rocket.Chat.Livechat/blob/dev/src/routes/Chat/room.js#L92
@renatobecker It was more an attempt to equate the REST responses with the streamer ones. Maybe ts
should be converted as Number
, but that should be done on SDK. Better keep this issue open until this change is available and all ts
references updated.
We’re running into this issue using the Rocketchat SDK as well. In our use case, we create a Livechat instance when starting the application. The user can start a chat as a guest and close it after a while. But as soon as he starts a new chat and opens a new room, the messages received onMessage have an Invalid Date
for ts.
As a workaround, we’re using the _updatedAt.$date
for now, but it would be great if this could be solved in a nicer way in the future.
This is because hot updates are ‘onMessage’ many times.Fixed it like this.
if(!window.haveLiveChatOnMessage ){
window.haveLiveChatOnMessage = true
Livechat.onMessage(async (message) => {
//do something
});
}
Once the client is hot reloaded in development mode,
Livechat.onMessage((message) => console.log(message.ts))
will log an invalidDate
object.