From 147a6fbcadf178f9ce3226fd134760a6e4df0882 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Tue, 22 Oct 2024 16:26:56 +0800 Subject: [PATCH 1/2] wait for onyx data to be ready --- src/pages/workspace/WorkspaceInviteMessagePage.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pages/workspace/WorkspaceInviteMessagePage.tsx b/src/pages/workspace/WorkspaceInviteMessagePage.tsx index 608f72744b3c..049fc6289f24 100644 --- a/src/pages/workspace/WorkspaceInviteMessagePage.tsx +++ b/src/pages/workspace/WorkspaceInviteMessagePage.tsx @@ -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'}`, @@ -79,7 +79,7 @@ function WorkspaceInviteMessagePage({policy, route, currentUserPersonalDetails}: }, [workspaceInviteMessageDraft, policy, translate]); useEffect(() => { - if (isWorkspaceInviteMessageDraftLoading) { + if (isOnyxLoading) { return; } if (!isEmptyObject(invitedEmailsToAccountIDsDraft)) { @@ -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); From 008113fd42b1232954b685f4376eac983a3ee0ed Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Tue, 22 Oct 2024 16:38:14 +0800 Subject: [PATCH 2/2] don't validate if onyx data is still loading --- src/pages/workspace/WorkspaceInviteMessagePage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/WorkspaceInviteMessagePage.tsx b/src/pages/workspace/WorkspaceInviteMessagePage.tsx index 049fc6289f24..89cab963fb43 100644 --- a/src/pages/workspace/WorkspaceInviteMessagePage.tsx +++ b/src/pages/workspace/WorkspaceInviteMessagePage.tsx @@ -114,7 +114,7 @@ function WorkspaceInviteMessagePage({policy, route, currentUserPersonalDetails}: const validate = (): FormInputErrors => { const errorFields: FormInputErrors = {}; - if (isEmptyObject(invitedEmailsToAccountIDsDraft)) { + if (isEmptyObject(invitedEmailsToAccountIDsDraft) && !isOnyxLoading) { errorFields.welcomeMessage = translate('workspace.inviteMessage.inviteNoMembersError'); } return errorFields;