Closed kickahaota closed 1 year ago
Thanks! :pray: Fixed.
Hmm. Seems like for some reason the first time /name is used (after page load/refresh), it doesn't work (and it's not a rendering problem - the name isn't actually changing), but online sometimes
Okay, I think I fixed it - please let me know if you run into any problems
The description of the
/name
command is a bit ambiguous. Is/name
intended to only change the user's name for future messages in the chat (as if the user's name had actually changed in the story at that point)? Or is it intended to change the user's name for the entire chat, including the previous messages (as if the user had made a mistake in choosing their name to begin with)? From looking at the code, it seems like it's intended to change the entire chat... and in that case, there's a bug.Currently, the
/name
command does change the user's name in the chat data. And it callsrenderMessageLoop
to refresh the message display. ButrenderMessageLoop
looks for already-rendered messages that match the ones in the chat data, and doesn't re-render them. And the code that does this comparison doesn't look at the actual name of the user; it just uses character IDs. So the previous chat messages are not re-rerendered, and the old name continues to be displayed. New user messages have the proper name displayed; and reloading the browser tab makes the old messages display correctly.I don't want to back-seat code, but it seems like a good solution might be to add a
rerenderAllMessages
option torenderMessageLoop
, like the existingtriggerBotReply
. If that option is set, then you could skip the message-matching loop, and just clear$.messageFeed.innerHTML
as if nothing had been matched. Then you could set thererenderAllMessages
option in/name
and/avatar
's call torenderMessageLoop
.Thanks again for all your work on this!