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

Fix issue with duplicate messages on reconnect #575

Merged
merged 2 commits into from
Nov 24, 2024

Conversation

11k
Copy link
Contributor

@11k 11k commented Nov 24, 2024

No description provided.

11k added 2 commits November 23, 2024 17:25
An unresolved message has a hash that differs from its counterpart in
chat history as tracked by the server. This is because a message's
timestamp is used to generate its hash and client-side and server-side
timestamps differ. The system for preventing duplicate messages when
processing the chat history payload uses message hashes to determine if
a message already exists. As a result, if the user disconnects and
reconnects, their recent messages will be rendered to the DOM a second
time.

Modifying the message resolution system to update the timestamp of a
user's message after it's echoed by the server fixes the issue. After
resolution, a message's client-side timestamp will match its server-side
timestamp, as will its hash.
Only generating the hash for a message in the `ChatMessage` constructor
doesn't consider the fact that a message's user is often set in a child
class' contructor. A message's hash is derived from the user's ID, so
its hash also needs to be regenerated in this circumstance.
@11k 11k added the bug Something isn't working label Nov 24, 2024
@11k 11k merged commit 25e4a55 into master Nov 24, 2024
2 checks passed
@11k 11k deleted the fix/dupe-messages-on-reconnect branch November 24, 2024 03:25
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

Successfully merging this pull request may close these issues.

After a reconnect, the current user's recent messages are added to the DOM again
1 participant