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

Fix/28098: Clicking back button bring back the workspace #28573

33 changes: 29 additions & 4 deletions src/libs/actions/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,17 @@ function endSignOnTransition() {
* @param {String} [policyName] Optional, custom policy name we will use for created workspace
* @param {Boolean} [transitionFromOldDot] Optional, if the user is transitioning from old dot
* @param {Boolean} [shouldNavigateToAdminChat] Optional, navigate to the #admin room after creation
* @param {Boolean} [isThereModalToDismiss] Optional, if there is a modal to dismiss

*/
function createWorkspaceAndNavigateToIt(policyOwnerEmail = '', makeMeAdmin = false, policyName = '', transitionFromOldDot = false, shouldNavigateToAdminChat = true) {
function createWorkspaceAndNavigateToIt(
policyOwnerEmail = '',
makeMeAdmin = false,
policyName = '',
transitionFromOldDot = false,
shouldNavigateToAdminChat = true,
isThereModalToDismiss = true,
) {
const policyID = Policy.generatePolicyID();
const adminsChatReportID = Policy.createWorkspace(policyOwnerEmail, makeMeAdmin, policyName, policyID);
Navigation.isNavigationReady()
Expand All @@ -325,10 +334,26 @@ function createWorkspaceAndNavigateToIt(policyOwnerEmail = '', makeMeAdmin = fal
}

if (shouldNavigateToAdminChat) {
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(adminsChatReportID));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DylanDylann Why did we remove this line? on staging when we create a new workspace , it should be redirected to admins room.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dismissModal should redirect to #admins room but that doesn’t seem to be the case, can you please check?

Copy link
Contributor Author

@DylanDylann DylanDylann Oct 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I replace it by Navigation.dismissModal(adminsChatReportID);, it still redirects to the admins room, and removes the current RHN modal as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I mentioned in the proposal #28098 (comment):

we can make sure that the current RIGHT_MODAL_NAVIGATOR screen is REPLACE by report screen, rather than PUSH a new report screen to the stack by using Navigation.dismissModal function:

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it still redirects to the admins room, and removes the current RHN modal as well

It doesn’t work for me.

Can we just dismiss the modal , navigate to admins then open the modal again?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the browsers history is just [/r/{reportID}, /settings, /settings/workspaces]`

That's the expected behavior, no? I mean what's the issue here?

Copy link
Contributor Author

@DylanDylann DylanDylann Oct 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or sorry. My bad. I have updated this comment #28573 (comment)

the browser`s history is just [/r/{reportID}, /settings/workspaces]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fedirjh do you have any suggestions for this one? The issue is that window.history does not sync with the react-navigation stacks

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fedirjh based on the issue here #28573 (comment), I just updated the PR to fix the error mentioned here #28573 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Result

#28573 (comment)

Screencast.from.06-10-2023.22.40.21.webm
Screencast.from.06-10-2023.22.39.00.webm

if (isThereModalToDismiss) {
Navigation.dismissModal(adminsChatReportID);
setTimeout(() => {
Navigation.navigate(ROUTES.SETTINGS);
setTimeout(() => {
Navigation.navigate(ROUTES.SETTINGS_WORKSPACES);
setTimeout(() => {
Navigation.navigate(ROUTES.WORKSPACE_INITIAL.getRoute(policyID));
}, 50);
}, 50);
}, 50);
mountiny marked this conversation as resolved.
Show resolved Hide resolved
} else {
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(adminsChatReportID));
setTimeout(() => {
Navigation.navigate(ROUTES.WORKSPACE_INITIAL.getRoute(policyID));
}, 50);
}
} else {
Navigation.navigate(ROUTES.WORKSPACE_INITIAL.getRoute(policyID));
}

Navigation.navigate(ROUTES.WORKSPACE_INITIAL.getRoute(policyID));
})
.then(endSignOnTransition);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ function FloatingActionButtonAndPopover(props) {
iconHeight: 40,
text: props.translate('workspace.new.newWorkspace'),
description: props.translate('workspace.new.getTheExpensifyCardAndMore'),
onSelected: () => interceptAnonymousUser(() => App.createWorkspaceAndNavigateToIt('', false, '', false, !props.isSmallScreenWidth)),
onSelected: () => interceptAnonymousUser(() => App.createWorkspaceAndNavigateToIt('', false, '', false, !props.isSmallScreenWidth, false)),
},
]
: []),
Expand Down
Loading