ctm / mb2-doc

Mb2, poker software
https://devctm.com
7 stars 2 forks source link

Replayed chat messages have incorrect timestamps #1419

Closed ctm closed 1 month ago

ctm commented 1 month ago

Fix so hovering over a table chat message shows the time that message was sent initially, not the time it was replayed.

When I added preserving chat logs, not only did I introduce the other bugs (#1416, #1418), but I also introduced the bug that causes the timestamp to be wrong. Before we replayed chat, there was no need to send a timestamp with the chat, because the client could (and does) record when the chat message comes in.

Most likely, I'll fix this bug in the same commit that fixes the inability to chat after a tournament finishes (#1418).

ctm commented 1 month ago

FWIW, the Lobby makes a distinction between a Chat(PlayerId, String) and ReplayChats(Vec<ChatMessage>), where ChatMessage contains a DateTime<Utc> when field in addition to the message and player id. IOW, we don't send a timestamp for chat messages that are delivered in realtime.

It slightly complicates our message format, but we could add a ReplayedChat(ChatMessage) TableMessage (or, perhaps more appropriately PlayerMessage) and record that, rather than TableMessage::Chat. It just means that each client (and we really only have the web one right now) would need to process both Chat and ReplayedChat. I'm pretty sure that's what I want to implement, but I'll think about it while I take a coding break.

ctm commented 1 month ago

LogLine::subst and its helper function line_or_chat both have a hardcoded utc_now() for when. That's not a really big deal, in that we can add a when: Option<DateTime<Utc>> parameter to subst and pass it to line_or_chat, but that makes it less likely that I'll get this finished before this evening's game.

ctm commented 1 month ago

Turns out, updating subst was trivial. Timestamps are now working. Deploying now.