-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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: Address bar URL is not updated after login or landing on root #2346
Fix: Address bar URL is not updated after login or landing on root #2346
Conversation
With the current configuration it should be possible for the navigation to resolve initial state entirely through `linkingConfig`
1. Either initial report data is available right from the start from Onyx 2. Or it is fetched and restored by `fetchAllReports` 3. Or if all else fails start with no report opened
Found one more thing that this PR fixes. I don't think it was reported. It's Android only and related to the keyboard issues I've discovered and tracked to Navigation state: Navigation returns to the same screen/modal on AndroidAndroid.Emulator.-.Pixel_2_API_29_5554.2021-04-12.20-51-32.mp4I've stumbled on this while testing if my changes also cover: #1855 It looks like this PR together with #2221 address fully the keyboard issues in #1855 and #2150 (and the above that's not yet reported) 🦸 A video summary of all the fixesAndroid.Emulator.-.Pixel_2_API_29_5554.2021-04-12.21-06-52.mp4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just leaving some initial thoughts since this is in draft.
The Report Screen renders the "currently viewed report" - it can persist it This way we doesn't have to check per each navigation state change
@@ -37,6 +38,7 @@ class ReportScreen extends React.Component { | |||
|
|||
if (reportChanged) { | |||
this.prepareTransition(); | |||
this.storeCurrentlyViewedReport(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This replaces the logic here:
The ReportScreen
renders the last viewed report so we don't need to check per each navigation change, but only save the last report that was viewed in ReportScreen
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change makes sense to me. I don't see how it's different from what we had before (maybe a bit cleaner). Was there any other motivation for the change or just cleaning stuff up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Primarily clean up, it should still work the same as before. I can revert this you think it might cause some issue down the road
…-updating-after-login-or-refresh Conflicts: src/libs/Navigation/AppNavigator/AuthScreens.js
Updated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look great to me just one small comment left about adding a method doc.
@@ -37,6 +38,7 @@ class ReportScreen extends React.Component { | |||
|
|||
if (reportChanged) { | |||
this.prepareTransition(); | |||
this.storeCurrentlyViewedReport(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change makes sense to me. I don't see how it's different from what we had before (maybe a bit cleaner). Was there any other motivation for the change or just cleaning stuff up?
@@ -73,6 +75,11 @@ class ReportScreen extends React.Component { | |||
this.loadingTimerId = setTimeout(() => this.setState({isLoading: false}), 300); | |||
} | |||
|
|||
storeCurrentlyViewedReport() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All our components methods must have a method doc even if they don't take params or return anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid docs that don't add any additional information.
Method descriptions are optional and should be added when it's not obvious what the purpose of the method is.
https://github.com/Expensify/Expensify.cash/blob/master/STYLE.md#jsdocs 🤓
This is a class method and I'll just be adding this as a description: "Persists the currently viewed report id". I could extend it to "...with Onyx" but this is just an implementation detail
Anyway this is not the first time, someone would bring up func/method documentation. In fact it is always the case that I should add documentation so you might consider updating the guide - I would have just always added documentation if I hadn't read the above in the style guide.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for calling that out. I will update it to be more clear.
Updated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 👍
I'm not sure if we need/want to do anything about this yet. But an interesting side effect of this change is that on a fresh sign in the report with Concierge loads first on web, but the header component does not say we are chatting with Concierge.
My guess would be this happens because the HeaderView
is still waiting for the personalDetails
to be set. And ideally we would wait for both of these things before showing the very first report.
Compared to the main branch where we wait (but also never redirect which is what we are fixing)
I'd propose making a follow up issue for this.
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
Strange, on my sample video for web above - the header information loads/updates as well. Though I made a new user and there's only the Concierge chat. I'll have a look tomorrow |
Perhaps because there are very few users and everything loads fast. |
I thought you mean the header never updated and stayed the way it is in the your screenshot It's not a side effect of this PR or the loader addition - it was always the case that elements would render in their own time as soon as they have data: A video from 1359f9f before any of the loader/url fixesExpensify.cash.-.Google.Chrome.2021-04-14.10-17-01.mp4
A video from current state d10d52cExpensify.cash.-.Google.Chrome.2021-04-14.10-11-58.mp4To fine tune loading we could replace the timeout logic with state change polling like it's done here: kidroca/Expensify.cash@ae376b4 |
Apologies, sounds like the case here. To clarify, I didn't mean to suggest it should be fixed as a direct follow up or anything (but looks like it re-reading my comment 🤦). Perhaps more accurate to say the effect or more noticeable/pronounced now. |
@marcaaron Question about QAing this. I think we're only able to execute the steps in Web and mWeb to be able to check the URL. Is there a way to test this on Apps (android, iOS and desktop) or should we go ahead with just web/mweb? |
Thanks @isagoico, it should be testable by using deep links. We're using universal links so in most cases if we can reach a link like |
Of course, there is no "url" to verify but we can see if things are working at least. |
@marcaaron Links are not working for the iOS app. It only open mWeb and doesn't show the option to open in cash app 🤔 Android is working as expected. Should I go ahead an open a separate issue for this? |
The Sign Up - Blank screen after setting the passwordExpected resultUser proceeds to expensify.cash chat list Actual ResultUser is redirected to a blank screen and a JS error can be seen in the console Action Performed
PlatformIssue is confirmed in: Android ✔️ Build: 1.0.21-0 |
I'm not 100% sure if this PR is the one responsible for this behaviour so please let me know if it's not the case so I can open a separate issue :) |
Not sure, but I'm not able to reproduce that issue locally. |
I think it kinda is 😭 @marcaaron I've traced this to
This would happen milliseconds before It doesn't have to perform navigation for this specific case, as it's being resolved from initial params, but I see the function is used on a couple of other places, to create a new chat and redirect navigation to it. For the moment it can be addressed as suggested here: https://reactnavigation.org/docs/navigating-without-navigation-prop/#handling-initialization
We can update An alternative solution might be to only switch to Or maybe simply calling |
Ah interesting. I see what you're saying here. So we need to do something like:
I'm not sure what would be best in this case, but one possibly naive idea would be to: add on import {onNavigationContainerReady} from '/Navigation'
<NavigationContainer
onReady={onNavigationContainerReady} let lastAttemptedRoute;
let isReady = false;
function navigate(route) {
if (!isReady) {
lastAttemptedRoute = route;
return
}
...
}
function onNavigationContainerReady() {
isReady = true;
navigate(lastAttemptedRoute);
} |
In their documentation they would just skip doing anything. Your solution seem an improvement over that. Looks like it would work It might be a bit too clever but I you can do something like this: let lastAttemptedRoute;
function navigate(route) {
// unmodified
}
function navigateLater(route) {
lastAttemptedRoute = route;
}
function onNavigationContainerReady() {
navigate(lastAttemptedRoute);
exports.navigate = navigate;
}
const exports = {
navigate: navigateLater,
onNavigationContainerReady,
};
export default exports; Because that check is only needed initially but will be performed for the lifetime of the Navigation |
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
Yep I like that improvement. |
🚀 [Deployed](https://github.com/Expensify/Expensify.cash
|
Hey @marcaaron I'm not sure if you expect anything more from me? Should I open another PR add work on a fix? |
If you want to create an issue for this follow up we can make a new job out of it ? |
That would be great! |
Sounds good thanks :) |
The new issue is already created, the link is just above your comment #2497 |
Thanks @kidroca, I am going to remove the |
<If necessary, assign reviewers that know the area or changes well. Feel free to tag any additional reviewers you see fit.>
@marcaaron
Details
Update navigation initial state logic.
Fixed Issues
Fixes #2325
Tests
All the steps described here are for web and mWeb. For desktop and the native apps there should be no regressions. E.g. opening the mobile app should still go to the Home screen where you select a conversation.
Best to use Incognito Mode for the below 2 flows so that you're sure something in existing storage doesn't help in passing these steps
Login Flow
/
(with no traces of previous report in the url)/r/71403817
Create Account
/r/71403817
Opening the app when authenticated
localhost:8080
)/r/71403817
Navigating to the root of the app
localhost:8080/
/r/71403817
Refreshing
/r/71403817
QA Steps
Same as the tests above
Tested On
Screenshots
Web
Expensify.cash.-.Google.Chrome.2021-04-12.18-13-28.mp4
Mobile Web
Android.Emulator.-.Pixel_2_API_29_5554.2021-04-12.18-14-50.mp4