Skip to content

Commit

Permalink
Merge pull request #31255 from dukenv0307/fix/30100
Browse files Browse the repository at this point in the history
Fix not found page display briefly after deleting the workspace
  • Loading branch information
amyevans authored Nov 14, 2023
2 parents cc5a272 + c57dc10 commit 183cce0
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/pages/workspace/WorkspaceInitialPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import ScreenWrapper from '@components/ScreenWrapper';
import Text from '@components/Text';
import Tooltip from '@components/Tooltip';
import useLocalize from '@hooks/useLocalize';
import usePrevious from '@hooks/usePrevious';
import useSingleExecution from '@hooks/useSingleExecution';
import useWaitForNavigation from '@hooks/useWaitForNavigation';
import useWindowDimensions from '@hooks/useWindowDimensions';
Expand Down Expand Up @@ -221,6 +222,15 @@ function WorkspaceInitialPage(props) {
return items;
}, [adminsRoom, announceRoom, translate]);

const prevPolicy = usePrevious(policy);

// eslint-disable-next-line rulesdir/no-negated-variables
const shouldShowNotFoundPage =
_.isEmpty(policy) ||
!PolicyUtils.isPolicyAdmin(policy) ||
// We check isPendingDelete for both policy and prevPolicy to prevent the NotFound view from showing right after we delete the workspace
(PolicyUtils.isPendingDeletePolicy(policy) && PolicyUtils.isPendingDeletePolicy(prevPolicy));

return (
<ScreenWrapper
includeSafeAreaPaddingBottom={false}
Expand All @@ -229,7 +239,7 @@ function WorkspaceInitialPage(props) {
{({safeAreaPaddingBottomStyle}) => (
<FullPageNotFoundView
onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_WORKSPACES)}
shouldShow={_.isEmpty(policy) || !PolicyUtils.isPolicyAdmin(policy) || PolicyUtils.isPendingDeletePolicy(policy)}
shouldShow={shouldShowNotFoundPage}
subtitleKey={_.isEmpty(policy) ? undefined : 'workspace.common.notAuthorized'}
>
<HeaderWithBackButton
Expand Down

0 comments on commit 183cce0

Please sign in to comment.