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: prevent double update on message edit #1103

Closed
wants to merge 14 commits into from

Conversation

domw30
Copy link
Collaborator

@domw30 domw30 commented Oct 17, 2023

What does this do?

  • Implemented a check against the Redux state to determine if a message has already been updated = preventing a redundant server event from triggering a UI refresh.

Why are we making this change?

  • Resolves a race condition where both user action and server event trigger a UI update, causing flickering/edited message renders as received message.

How do I test this?

  • Send message > Edit Message > Check UI is as expected.

Key decisions and Risk Assessment:

Things to consider:

  1. How will this affect security?
  2. How will this affect performance?
  3. Does this change any APIs?

Before:

Screen.Recording.2023-10-17.at.11.28.49.mov

After:

Screen.Recording.2023-10-17.at.11.36.07.mov

Comment on lines +490 to +493
const existingMessage = yield select(messageSelector(message.id));
if (existingMessage && existingMessage.message === message.message) {
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this is the right solution. A message could be updated for any number of reasons that aren't the message changing.

We should be able to update this message in state and if nothing has changed then it should just work. If that's not working then we're updating too much of the state or we're not providing enough of it in the event.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm yeah looks like that shouldn't be needed.

The reason for the edited message rendering as a 'received' message is due to the userId and senderId differing slightly, therefore the isOwner boolean is false when determining if sent/edited message is from the current user. Maybe we could have a v.quick call to discuss?

Screenshot 2023-10-18 at 11 41 46

Copy link
Collaborator

@ratik21 ratik21 Oct 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i guess this is related to NOT mapping the user correctly maybe, while receiving the edit message event perhaps? (i.e userId/senderId don't match because one of them is zOS user id, and the other one is matrixId). Could you please check/confirm?

Base automatically changed from feat/edit-message/zos-710 to main October 18, 2023 10:21
@domw30
Copy link
Collaborator Author

domw30 commented Oct 23, 2023

Closing this pul request in favour of : #1135

@domw30 domw30 closed this Oct 23, 2023
@domw30 domw30 deleted the fix/prevent-double-update-on-message-edit branch October 23, 2023 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants