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] Report - Added content is lost after editing in offline mode and refreshing the page #40455

Closed
1 of 6 tasks
lanitochka17 opened this issue Apr 18, 2024 · 20 comments
Closed
1 of 6 tasks
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review Weekly KSv2

Comments

@lanitochka17
Copy link

lanitochka17 commented Apr 18, 2024

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 1.4.63-0
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail: N/A
Issue reported by: Applause - Internal Team

Action Performed:

  1. Send a message in any report
  2. Apply offline mode
  3. Edit the sent message
  4. Refresh the page
  5. Change network mode to online

Expected Result:

Added comment while editing in offline mode should persist

Actual Result:

Add comment while editing in offline mode is lost

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

Bug6453446_1713434894311.Screen_Recording_2024-04-18_at_adf1.02.28_in_the_afternoon.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01bf8721625590c5d0
  • Upwork Job ID: 1783009829966831616
  • Last Price Increase: 2024-04-24
  • Automatic offers:
    • Pujan92 | Reviewer | 0
    • bernhardoj | Contributor | 0
@lanitochka17 lanitochka17 added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Apr 18, 2024
Copy link

melvin-bot bot commented Apr 18, 2024

Triggered auto assignment to @JmillsExpensify (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.

@lanitochka17
Copy link
Author

@JmillsExpensify FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors

@lanitochka17
Copy link
Author

We think that this bug might be related to #vip-vsp

@melvin-bot melvin-bot bot added the Overdue label Apr 22, 2024
Copy link

melvin-bot bot commented Apr 23, 2024

@JmillsExpensify Eep! 4 days overdue now. Issues have feelings too...

@JmillsExpensify
Copy link

Yikes, this doesn't seem good. I agree that it's #vip-vsb so I will add it to the project. Also going to start with external since that'll be picked up faster.

@melvin-bot melvin-bot bot removed the Overdue label Apr 24, 2024
@JmillsExpensify JmillsExpensify added the External Added to denote the issue can be worked on by a contributor label Apr 24, 2024
@melvin-bot melvin-bot bot changed the title Report - Added content is lost after editing in offline mode and refreshing the page [$250] Report - Added content is lost after editing in offline mode and refreshing the page Apr 24, 2024
Copy link

melvin-bot bot commented Apr 24, 2024

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

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

melvin-bot bot commented Apr 24, 2024

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

@Pujan92
Copy link
Contributor

Pujan92 commented Apr 26, 2024

@lanitochka17 I am not able to reproduce it, can you plz check and confirm

Screen.Recording.2024-04-26.at.22.02.14.mov

@lanitochka17
Copy link
Author

@Pujan92 Tester is still able to reproduce this issue

Screen.Recording.2024-04-26.at.7.40.11.in.the.evening.mp4

@melvin-bot melvin-bot bot added the Overdue label Apr 29, 2024
@bernhardoj
Copy link
Contributor

Proposal

Please re-state the problem that we are trying to solve in this issue.

The edited comment is discarded when refreshing the page while offline.

What is the root cause of that problem?

When we do an API request while offline, we will save it to the networkRequestQueue Onyx so we can process it when we are back online.

function save(requestToPersist: Request) {
persistedRequests.push(requestToPersist);
Onyx.set(ONYXKEYS.PERSISTED_REQUESTS, persistedRequests).then(() => {
Log.info(`[SequentialQueue] '${requestToPersist.command}' command queued. Queue length is ${getLength()}`);
});
}

However, the queue is never saved because we pass the same instance of the array. You can see in the log that the hasChanged is false.
Screenshot 2024-04-29 at 16 06 35

So, when we refresh the page, the edit request will never be processed, and the OpenReport/ReconnectApp request will return the message data from the BE which is unedited.

What changes do you think we should make in order to solve the problem?

Create a new instance of array before saving the queue.

const requests = [...persistedRequests, requestToPersist];
persistedRequests = requests;
Onyx.set(ONYXKEYS.PERSISTED_REQUESTS, requests)

Copy link

melvin-bot bot commented Apr 29, 2024

@JmillsExpensify, @Pujan92 Whoops! This issue is 2 days overdue. Let's get this updated quick!

@Pujan92
Copy link
Contributor

Pujan92 commented Apr 29, 2024

I agree with @bernhardoj's RCA and solution as it is not getting updated in the Onyx due to the ref issue. We should assign the new array to the onyx which will do the check correctly for hasValueChanged with 2 different refs.

🎀👀🎀 C+ reviewed

@melvin-bot melvin-bot bot removed the Overdue label Apr 29, 2024
Copy link

melvin-bot bot commented Apr 29, 2024

Triggered auto assignment to @Gonals, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Apr 30, 2024
Copy link

melvin-bot bot commented Apr 30, 2024

📣 @Pujan92 🎉 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 Apr 30, 2024

📣 @bernhardoj 🎉 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 📖

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Apr 30, 2024
@bernhardoj
Copy link
Contributor

PR is ready

cc: @Pujan92

@Pujan92
Copy link
Contributor

Pujan92 commented May 14, 2024

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

@Pujan92
Copy link
Contributor

Pujan92 commented May 17, 2024

Bump @JmillsExpensify for the payment as PR hit the prod a week ago, automation seems broken here.

@JmillsExpensify
Copy link

Payment summary:

@JmillsExpensify
Copy link

All contracts paid out via Upwork and the BZ checklist is complete. Closing this one out!

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 Reviewing Has a PR in review Weekly KSv2
Projects
No open projects
Development

No branches or pull requests

5 participants