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

[$500] Display route line when the device comes back online #26596

Closed
6 tasks done
hayata-suenaga opened this issue Sep 3, 2023 · 14 comments
Closed
6 tasks done

[$500] Display route line when the device comes back online #26596

hayata-suenaga opened this issue Sep 3, 2023 · 14 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors

Comments

@hayata-suenaga
Copy link
Contributor

hayata-suenaga commented Sep 3, 2023

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


Action Performed:

  1. Go to a workspace chat
  2. Click the "+" button next to the text composer
  3. Click "Request money"
  4. Click "Distance"

We're going to create the history of recent searches so that we can test this flow offline

  1. Type and choose any addresses for "Start" and "Finish"
  2. Confirm that a route is displayed
  3. Close the Distance Request page (i.e. Right Hand Panel)
  4. Make the device offline
  5. Go through steps 1 ~ 4 again
  6. For "Start" and "Finish", choose addresses from the suggestion (because we have the history of recent searches, we have address suggestions even when the device is offline)
  7. Bring the device back to online
  8. Check that the route is not displayed on the map
  9. Refresh the screen and check the route is still not displayed

Expected Result:

A route should be displayed if two or more valid waypoints are present when the device comes back online

Actual Result:

A route is not present on the map.

Workaround:

N/A

Platforms:

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

  • Android / native
  • Android / Chrome
  • iOS / native
  • iOS / Safari
  • MacOS / Chrome / Safari
  • MacOS / Desktop

Version Number:
Reproducible in staging?: Yes
Reproducible in production?: No (the feature is not deployed to production yet)
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos: Any additional supporting documentation
Expensify/Expensify Issue URL:
Issue reported by: @shubham1206agra
Slack conversation: https://expensify.slack.com/archives/C01GTK53T8Q/p1693712953909809?thread_ts=1693667520.672399&cid=C01GTK53T8Q

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01b325474ece1a7595
  • Upwork Job ID: 1698212538923118592
  • Last Price Increase: 2023-09-03
@hayata-suenaga hayata-suenaga added External Added to denote the issue can be worked on by a contributor Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Sep 3, 2023
@hayata-suenaga hayata-suenaga self-assigned this Sep 3, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 3, 2023

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

@melvin-bot melvin-bot bot changed the title Display route line when the device comes back online [$500] Display route line when the device comes back online Sep 3, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 3, 2023

Triggered auto assignment to @mallenexpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Sep 3, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 3, 2023

Bug0 Triage Checklist (Main S/O)

  • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
  • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
    • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
  • This bug is reproducible using the reproduction steps in the OP. S/O
    • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
    • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
  • This issue is filled out as thoroughly and clearly as possible
    • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
  • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync

@melvin-bot
Copy link

melvin-bot bot commented Sep 3, 2023

Triggered auto assignment to @dylanexpensify (External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.

@melvin-bot
Copy link

melvin-bot bot commented Sep 3, 2023

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

@b4s36t4
Copy link
Contributor

b4s36t4 commented Sep 3, 2023

Hey, @hayata-suenaga my proposal for issue #26537 solves this issue as well.

@b4s36t4
Copy link
Contributor

b4s36t4 commented Sep 3, 2023

But as that is linked to other issue, not sure what I can do. Shall I post the solution specific to this issue?

@studentofcoding
Copy link
Contributor

Proposal

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

Display route line when the device comes back online

What is the root cause of that problem?

The bug appears because the application does not re-fetch the MapBox route when transitioning from offline to online. This means that if the user goes offline and then comes back online, the MapBox route is not updated, causing it not to appear correctly.

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

Add a mechanism to

function DistanceRequest({iou, iouType, report, transaction, mapboxAccessToken}) {
using useEffect to listens for changes in the network status and triggers a re-fetch of the MapBox route when the application goes from offline to online.

function DistanceRequest({iou, iouType, report, transaction, mapboxAccessToken}) {
    const previousIsOffline = usePrevious(isOffline); // Add this line to store the previous network status

    // ... (rest of the code)


    // Add this useEffect hook
    useEffect(() => {
        if (!previousIsOffline || isOffline || !iou.transactionID) {
            return;
        }
    
        Transaction.getRoute(iou.transactionID, waypoints);
    }, [isOffline, previousIsOffline, iou.transactionID, waypoints]);

    // ... (rest of the code)
}

What alternative solutions did you explore? (Optional)

None

Result

cropped_mapbox_fixed.mp4

@studentofcoding
Copy link
Contributor

Proposal

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

Display route line when the device comes back online

What is the root cause of that problem?

The bug appears because the application does not re-fetch the MapBox route when transitioning from offline to online. This means that if the user goes offline and then comes back online, the MapBox route is not updated, causing it not to appear correctly.

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

Add a mechanism to

function DistanceRequest({iou, iouType, report, transaction, mapboxAccessToken}) {

using useEffect to listens for changes in the network status and triggers a re-fetch of the MapBox route when the application goes from offline to online.

function DistanceRequest({iou, iouType, report, transaction, mapboxAccessToken}) {
    const previousIsOffline = usePrevious(isOffline); // Add this line to store the previous network status

    // ... (rest of the code)


    // Add this useEffect hook
    useEffect(() => {
        if (!previousIsOffline || isOffline || !iou.transactionID) {
            return;
        }
    
        Transaction.getRoute(iou.transactionID, waypoints);
    }, [isOffline, previousIsOffline, iou.transactionID, waypoints]);

    // ... (rest of the code)
}

What alternative solutions did you explore? (Optional)

None

Result

cropped_mapbox_fixed.mp4

cc @hayata-suenaga

@pradeepmdk
Copy link
Contributor

pradeepmdk commented Sep 3, 2023

Proposal

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

Display route line when the device comes back online

What is the root cause of that problem?

const doesRouteExist = lodashHas(transaction, 'routes.route0.geometry.coordinates');

here we are checking the coordinates key or not so its will be always true
because coordinates we are setting as null every every waypoint save
coordinates: null,

but its have null value so that when come back online
Transaction.getRoute(iou.transactionID, waypoints);
not triggering this one

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

we should update the logic

    const doesRouteExist = lodashHas(transaction, 'routes.route0.geometry.coordinates') && transaction.routes.route0.geometry.coordinates && transaction. routes.route0.geometry.type;

token init as well we should update

    useEffect(() => {
        if(isOffline) {
            return;
        }
        MapboxToken.init();
        return MapboxToken.stop;
    }, [isOffline]);

when refresh as well working fine

@hoangzinh
Copy link
Contributor

@hayata-suenaga dup with this issue, and I had a proposal to fix this issue here #26589 (comment)

@hayata-suenaga
Copy link
Contributor Author

#26589 was created earlier, so I'll close this one in favor of #26589

@hayata-suenaga
Copy link
Contributor Author

I'm evaluating proposals from both PRs right now

@hayata-suenaga
Copy link
Contributor Author

@pradeepmdk I'll assign you to this issue. Please see the comment there

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. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors
Projects
None yet
Development

No branches or pull requests

8 participants