Skip to content

Commit

Permalink
Merge pull request #51228 from bernhardoj/fix/page-go-back-when-refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
dangrous authored Oct 28, 2024
2 parents bafc322 + 008113f commit 05f3b1d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/pages/workspace/WorkspaceInviteMessagePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ function WorkspaceInviteMessagePage({policy, route, currentUserPersonalDetails}:

const {inputCallbackRef, inputRef} = useAutoFocusInput();

const [invitedEmailsToAccountIDsDraft] = useOnyx(`${ONYXKEYS.COLLECTION.WORKSPACE_INVITE_MEMBERS_DRAFT}${route.params.policyID.toString()}`);
const [invitedEmailsToAccountIDsDraft, invitedEmailsToAccountIDsDraftResult] = useOnyx(`${ONYXKEYS.COLLECTION.WORKSPACE_INVITE_MEMBERS_DRAFT}${route.params.policyID.toString()}`);
const [workspaceInviteMessageDraft, workspaceInviteMessageDraftResult] = useOnyx(`${ONYXKEYS.COLLECTION.WORKSPACE_INVITE_MESSAGE_DRAFT}${route.params.policyID.toString()}`);
const [allPersonalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST);
const isWorkspaceInviteMessageDraftLoading = isLoadingOnyxValue(workspaceInviteMessageDraftResult);
const isOnyxLoading = isLoadingOnyxValue(workspaceInviteMessageDraftResult, invitedEmailsToAccountIDsDraftResult);

const welcomeNoteSubject = useMemo(
() => `# ${currentUserPersonalDetails?.displayName ?? ''} invited you to ${policy?.name ?? 'a workspace'}`,
Expand All @@ -79,7 +79,7 @@ function WorkspaceInviteMessagePage({policy, route, currentUserPersonalDetails}:
}, [workspaceInviteMessageDraft, policy, translate]);

useEffect(() => {
if (isWorkspaceInviteMessageDraftLoading) {
if (isOnyxLoading) {
return;
}
if (!isEmptyObject(invitedEmailsToAccountIDsDraft)) {
Expand All @@ -91,7 +91,7 @@ function WorkspaceInviteMessagePage({policy, route, currentUserPersonalDetails}:
}
Navigation.goBack(ROUTES.WORKSPACE_INVITE.getRoute(route.params.policyID), true);
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
}, [isWorkspaceInviteMessageDraftLoading]);
}, [isOnyxLoading]);

const debouncedSaveDraft = lodashDebounce((newDraft: string | null) => {
Policy.setWorkspaceInviteMessageDraft(route.params.policyID, newDraft);
Expand All @@ -114,7 +114,7 @@ function WorkspaceInviteMessagePage({policy, route, currentUserPersonalDetails}:

const validate = (): FormInputErrors<typeof ONYXKEYS.FORMS.WORKSPACE_INVITE_MESSAGE_FORM> => {
const errorFields: FormInputErrors<typeof ONYXKEYS.FORMS.WORKSPACE_INVITE_MESSAGE_FORM> = {};
if (isEmptyObject(invitedEmailsToAccountIDsDraft)) {
if (isEmptyObject(invitedEmailsToAccountIDsDraft) && !isOnyxLoading) {
errorFields.welcomeMessage = translate('workspace.inviteMessage.inviteNoMembersError');
}
return errorFields;
Expand Down

0 comments on commit 05f3b1d

Please sign in to comment.