-
Notifications
You must be signed in to change notification settings - Fork 3k
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
mWeb - Refreshing the LHN page opens chat with recent user #5027
Comments
Triggered auto assignment to @joelbettner ( |
Issue reproducible during KI retests |
@joelbettner Whoops! This issue is 2 days overdue. Let's get this updated quick! |
Sorry. I was OOO the past two days. This looks like it has what it needs to be worked on, and can be worked on by an external contributor. |
Triggered auto assignment to @mallenexpensify ( |
Triggered auto assignment to @roryabraham ( |
@joelbettner it looks like you accidentally unassigned me, I've had that happen before, Sonia gave me the tip to unassign myself first, then add the label to avoid the double unassign. |
Issue reproducible during KI retests. |
This is caused by the routing we have. We are by default because of our linkingConfig(I think) always routed to the last active report. So when the user first logs in, and when onyx is all synced up and all, the link is rewritten to Problem here is we do not have any special route for indicating homepage which probably makes sense trying to normalize this on all platforms. However, this creates issues like this. I believe solving this would require a fair bit of refactoring in our react-navigation related code. How would we want to go about this? |
Hmmm I think you're close to understanding everything here, but just to clarify the flow:
So I'm guessing what's happening here is a race condition – when the page is refreshed to I think we might be able to fix this by just changing /**
* @param {Boolean} isSmallScreenWidth
* @returns {String}
*/
function getDefaultDrawerState(isSmallScreenWidth) {
return didTapNotificationBeforeReady ? 'closed' : 'open';
} Because on wide screen widths, whether or not the drawer is open or closed shouldn't matter too much, and on small screen widths we want to default to the drawer being closed? Maybe there are some cases I'm missing here though? |
Job doubled a day early cuz I'm doing the resync now |
@roryabraham even the current implementation would be returning function getDefaultDrawerState(isSmallScreenWidth) {
if (didTapNotificationBeforeReady) {
return 'closed';
}
return isSmallScreenWidth ? 'open' : 'closed';
} Even if it had, it would still not give a consistent view I suppose, if I copy the link while on a report and open that link a new tab, it will rather open on the drawer, not on the report. Maybe we should add a query parameter |
@meetmangukiya Have you seen this documentation? |
Please refer to this post for updated information on the |
@roryabraham As I previously mentioned that this is an issue from the Lib but I was not sure about it. I checked the router state and it was telling me to open the drawer by default. But Drawer was not opening which led me to the conclusion that this is an issue with lib rather than our configuration. I also mentioned that we can set the route to Unfortunately, I deleted the comments for some reason. Good newsAs a result, the lib author found the real bug and fixed it react-navigation/react-navigation#9936 (comment). Now as soon as I push the fix for #4211. This will be resolved as well. Please assign this issue to me as I am fixing this in a PR and if you think that's okay. I know Meetmanguria is assigned but no other solution would be needed anymore. Also, he has not come up with a solution yet. |
Issue reproducible during KI retests. |
After discussing internally, we have decided that we are indeed going to reassign this issue to @parasharrajat, because after nearly two weeks, @meetmangukiya has not produced a PR to fix the issue via the original approach. They also have not provided an update in the last 10 days. Now that we have a better approach (due to the bug fixed in react-navigation), we'll move forward with that solution. @mallenexpensify Please close @meetmangukiya's Upwork contract and hire @parasharrajat for this issue. |
@parasharrajat hired in Upwork, @meetmangukiya hadn't been hired yet. |
Issue reproducible during KI retests. |
|
Posting a solution for review.
Keeping the URL and Drawer in sync based on the queryParams is not directly possible. We have to create a custom Router to manage this. Here is an implementation of the DrawerRouter which uses // It is used to update the queryParam based on the Drawer State.
function setRouteParam(state) {
const drawerStatus = state.history
.find(it => it.type === 'drawer')?.status ?? state.default;
const drawerOpenParam = drawerStatus === 'open' ? 'true' : 'false';
const params = {
...state.routes[state.index].params,
home: drawerOpenParam,
};
// eslint-disable-next-line no-param-reassign
state.routes[state.index] = {
...state.routes[state.index],
params,
};
return state;
}
export function DrawerRouter(props) {
const router = CoreRouter(props);
const defaultStatus = props.defaultStatus;
const isDrawerInHistory = state => Boolean(state.history?.some(it => it.type === 'drawer'));
const addDrawerToHistory = (state) => {
if (isDrawerInHistory(state)) {
return state;
}
return {
...state,
history: [
...state.history,
{
type: 'drawer',
status: defaultStatus === 'open' ? 'closed' : 'open',
},
],
};
};
const removeDrawerFromHistory = (state) => {
if (!isDrawerInHistory(state)) {
return state;
}
return {
...state,
history: state.history.filter(it => it.type !== 'drawer'),
};
};
const openDrawer = (
state,
) => {
if (defaultStatus === 'open') {
return removeDrawerFromHistory(state);
}
return addDrawerToHistory(state);
};
const closeDrawer = (
state,
) => {
if (defaultStatus === 'open') {
return addDrawerToHistory(state);
}
return removeDrawerFromHistory(state);
};
return {
...router,
getInitialState({routeNames, routeParamList, routeGetIdList}) {
const state = router.getInitialState({
routeNames,
routeParamList,
routeGetIdList,
});
return {
...setRouteParam(state),
};
},
getRehydratedState(
partialState,
{routeNames, routeParamList, routeGetIdList},
) {
let state = router.getRehydratedState(partialState, {
routeNames,
routeParamList,
routeGetIdList,
});
const activeRoute = state.routes[state.index];
const drawerOpenParam = activeRoute.params.home;
switch (drawerOpenParam) {
case 'true': state = openDrawer(state); break;
case 'false': state = closeDrawer(state); break;
default: state = closeDrawer(state); break;
}
state = setRouteParam(state, false);
return state;
},
getStateForAction(state, action, options) {
let result = router.getStateForAction(state, action, options);
// We use reset action to navigate to the report on Drawer which needs to be handled here.
if (result && action.type === 'RESET') {
result = closeDrawer(result);
}
return result != null ? setRouteParam(result) : result;
},
};
} This Router uses ditto implementation for opening and closing the drawer from the main DrawerRouter from the lib. |
Dang, that is pretty complicated 😅 I have think it looks like it will work, but we'll need to work through some of the details in the PR. @mallenexpensify Feel free to hire @parasharrajat on upwork.
What is ditto implementation? |
There is more to it. We will have to create the custom navigator as well to utilize this Router which will be an exact copy of Drawernavigator Component. I tried all the possible techniques but none of them were able to sync the URLs correctly. e.g. Linkingconfig https://reactnavigation.org/docs/configuring-links/#advanced-cases etc.
I mean it uses the same function definitions for opening and closing. |
Issue reproducible during KI retests. |
Feels like we are maybe hitting some boundaries that will require fairly complicated code. Should we maybe reevaluate whether this is worth doing? |
Fair point, this probably isn't worth making a custom router and navigator for. |
Then, #5745 at least fixes the issue where LHN was not opened by default. |
@roryabraham , let me know if you'd still like me to hire @parasharrajat, seems like we might be in limbo |
Given the mild severity of the problem and the complexity of the solution, I'm going to go ahead and close this out. Thanks for the investigation @parasharrajat |
Thanks @roryabraham . I spent a ton of time into this and following it up since some time. It is sad see that we are not taking any action but yeah it seems complex. I think current behaviour is fine. But my other pr #5745 does effect the current behaviour. It fixes the part where LHN was not shown in opened state. Do we want to keep that behaviour? |
Yeah, I think the new behavior from #5745 is better than what we have now. |
If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!
Action Performed:
Expected Result:
User should stay in LHN
Actual Result:
After page refresh opens the chat conversation with recent user
Workaround:
Unknown
Platform:
Where is this issue occurring?
Version Number:
1.92-0
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos:
Bug5220978_2.09.21.mp4
View all open jobs on GitHub
The text was updated successfully, but these errors were encountered: