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

[$250] De-dupe AddComment, EditComment, and DeleteComment requests #50074

Open
roryabraham opened this issue Oct 2, 2024 · 39 comments
Open

[$250] De-dupe AddComment, EditComment, and DeleteComment requests #50074

roryabraham opened this issue Oct 2, 2024 · 39 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Improvement Item broken or needs improvement. Reviewing Has a PR in review Weekly KSv2

Comments

@roryabraham
Copy link
Contributor

roryabraham commented Oct 2, 2024

Problem

When we make unnecessary network requests, it slows down the app and contributes to higher traffic on our servers. In particular:

  • if you are offline and you serialize multiple EditComment requests, only the last one will take effect
  • if you serialize both an AddComment and any number of EditComment requests, the result would be the same as one AddComment with the content of the final EditComment
  • if you serialize an AddComment followed by a DeleteComment, the end result is the same as not sending any network requests at all
  • if you serialize an EditComment request followed by a DeleteComment, the end result is the same as only sending the DeleteComment

Solution

De-dupe the network requests!

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021848400026446902359
  • Upwork Job ID: 1848400026446902359
  • Last Price Increase: 2024-10-21
  • Automatic offers:
    • dukenv0307 | Reviewer | 104528746
    • c3024 | Contributor | 104528756
Issue OwnerCurrent Issue Owner: @dukenv0307
@roryabraham roryabraham added Daily KSv2 Improvement Item broken or needs improvement. labels Oct 2, 2024
@roryabraham roryabraham self-assigned this Oct 2, 2024
@roryabraham
Copy link
Contributor Author

cc @gedu

@gedu
Copy link
Contributor

gedu commented Oct 2, 2024

Hey, I'm Edu from Callstack, I can take this one

@shubham1206agra
Copy link
Contributor

There are several obstacles to achieve this.

  1. if you are offline and you serialize multiple EditComment requests, only the last one will take effect

The obstacle here is that if the request fails after replace call, it will show wrong comment.

  1. if you serialize an AddComment followed by a DeleteComment, the end result is the same as not sending any network requests at all

This is tricky as we are now reducing the queue size.

@roryabraham
Copy link
Contributor Author

The obstacle here is that if the request fails after replace call, it will show wrong comment.

isn't that the case today with any EditComment request? Or is there something I'm missing?

@roryabraham roryabraham removed their assignment Oct 4, 2024
@roryabraham
Copy link
Contributor Author

Going on parental leave. @gedu @mountiny @shubham1206agra I leave this in your capable hands. My parting note is to please use as many automated tests to cover this change as possible 👍🏼

@melvin-bot melvin-bot bot added the Overdue label Oct 4, 2024
@gedu
Copy link
Contributor

gedu commented Oct 7, 2024

I just made a PR for OpenApp, I will start taking a look at this

@melvin-bot melvin-bot bot removed the Overdue label Oct 7, 2024
@mountiny mountiny changed the title De-dupe AddComment, EditComment, and DeleteComment requests De-dupe OpenApp, AddComment, EditComment, and DeleteComment requests Oct 7, 2024
@mountiny mountiny changed the title De-dupe OpenApp, AddComment, EditComment, and DeleteComment requests De-dupe AddComment, EditComment, and DeleteComment requests Oct 7, 2024
@gedu
Copy link
Contributor

gedu commented Oct 7, 2024

@shubham1206agra I'm making me a diagram, and I was thinking, what about a reaction, deleteComment has to delete addEmojiReaction too. Because now if you edit -> edit -> add reaction -> delete, you will see a request for each in that order. When we should see only a delete request, right?

@shubham1206agra
Copy link
Contributor

Yes that is true

@gedu
Copy link
Contributor

gedu commented Oct 7, 2024

@shubham1206agra also just to make sure, if I edit -> create a thread -> add message in that thread -> delete original message, this is the final state. In such case I only delete the editComment the thread should be created and any message in it, right?

Screenshot 2024-10-07 at 18 46 36 This is how it looks now

@shubham1206agra
Copy link
Contributor

Yes

@shubham1206agra
Copy link
Contributor

There's another case
Add comment -> Add comment in thread -> Delete parent comment -> Delete thread comment

No request should be made in this case

@gedu
Copy link
Contributor

gedu commented Oct 7, 2024

There's another case
Add comment -> Add comment in thread -> Delete parent comment -> Delete thread comment

No request should be made in this case

Ohh, yeah, so nothing happens, no new thread is created and no new message is added into that thread. Cool, I'm adding this case too

@gedu
Copy link
Contributor

gedu commented Oct 7, 2024

Just to make sure, these cases can happen at any time, not just offline. Given that the queue is being processed sequentially, the delete could occur at any time, and I have to prevent those messages from being sent, right?

@gedu
Copy link
Contributor

gedu commented Oct 8, 2024

@shubham1206agra Also I was thinking, if I create a thread -> message -> message -> delete last message -> delete thread.
I'm not sure if I found a bug because my chat breaks. I lose my Task, and I should have two [Deleted Message] messages.

delete_message.mp4

@shubham1206agra
Copy link
Contributor

Can you report the bug in slack?

@gedu
Copy link
Contributor

gedu commented Oct 8, 2024

Can you report the bug in slack?

How can I do it? I don't have access to the prompt /bug

@mountiny
Copy link
Contributor

mountiny commented Oct 8, 2024

You can just copy the template and fill it manually

Copy link

melvin-bot bot commented Oct 17, 2024

Triggered auto assignment to @bfitzexpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Oct 17, 2024
@gedu
Copy link
Contributor

gedu commented Oct 18, 2024

if you serialize both an AddComment and any number of EditComment requests, the result would be the same as one
AddComment with the content of the final EditComment

@mountiny After a talk with @zirgulis that point we will tackle in a new PR, not in the same one of multiple EditComment, given that it will require more logic and a new set of tests. That way we can track it better if any issue shows up

@zirgulis
Copy link
Contributor

if you are offline and you serialize multiple EditComment requests, only the last one will take effect

@mountiny @gedu for this I have the code ready here, will create a PR tomorrow since I still need to test on emulators and do the screen recordings.

@melvin-bot melvin-bot bot added Weekly KSv2 and removed Daily KSv2 labels Oct 21, 2024
@zirgulis
Copy link
Contributor

@mountiny @gedu Multiple EditComment requests deduping PR is open #51149

@mountiny
Copy link
Contributor

Thanks!

@muttmuure muttmuure added the External Added to denote the issue can be worked on by a contributor label Oct 21, 2024
@melvin-bot melvin-bot bot changed the title De-dupe AddComment, EditComment, and DeleteComment requests [$250] De-dupe AddComment, EditComment, and DeleteComment requests Oct 21, 2024
Copy link

melvin-bot bot commented Oct 21, 2024

Job added to Upwork: https://www.upwork.com/jobs/~021848400026446902359

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Oct 21, 2024
Copy link

melvin-bot bot commented Oct 21, 2024

Triggered auto assignment to Contributor-plus team member for initial proposal review - @dukenv0307 (External)

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Oct 21, 2024
@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Oct 22, 2024
Copy link

melvin-bot bot commented Oct 22, 2024

📣 @dukenv0307 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job

Copy link

melvin-bot bot commented Oct 22, 2024

📣 @c3024 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job
Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

@gedu
Copy link
Contributor

gedu commented Oct 22, 2024

if you serialize both an AddComment and any number of EditComment requests, the result would be the same as one > AddComment with the content of the final EditComment

@mountiny I did the second item, and I'm seeing this behaviour, for a couple of seconds, until the response is back and then it rerenders, you can see the edit label next to the message. Is it ok?

Given that the optimisticData is applied before the request reaches the SequentialQueue, it is showing, I can try to add a rollback case for it, but want to confirm if we want or not to show the edit label. The rollback will be applied as soon as the "conflict" is resolved so probably the user won't see the edit label while being of line, will be like he just updated the comment.

updateComment_addComment.mp4

@mountiny
Copy link
Contributor

@gedu I think from UX it would be best not to show it but I would not block on this if its too complex to achieve not showing edited label

@melvin-bot melvin-bot bot added Weekly KSv2 and removed Daily KSv2 labels Oct 24, 2024
@gedu
Copy link
Contributor

gedu commented Oct 24, 2024

if you serialize both an AddComment and any number of EditComment requests, the result would be the same as one > > AddComment with the content of the final EditComment

Created a new PR: #51422 to add the last point, it depends on #50919, so would be good to merge that one first

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Improvement Item broken or needs improvement. Reviewing Has a PR in review Weekly KSv2
Projects
Status: CRITICAL
Development

No branches or pull requests

9 participants