Skip to content

Commit

Permalink
fix(condo): DOMA-10739 wait for persistor on contact id page
Browse files Browse the repository at this point in the history
  • Loading branch information
nomerdvadcatpyat committed Nov 26, 2024
1 parent a81c084 commit 8a7c4ac
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion apps/callcenter
7 changes: 4 additions & 3 deletions apps/condo/pages/contact/[id]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import get from 'lodash/get'
import Head from 'next/head'
import Link from 'next/link'
import { useRouter } from 'next/router'
import React, { CSSProperties, useCallback } from 'react'
import React, { CSSProperties, useCallback, useMemo } from 'react'

import { useCachePersistor } from '@open-condo/apollo'
import { getClientSideSenderInfo } from '@open-condo/codegen/utils/userId'
Expand Down Expand Up @@ -232,6 +232,7 @@ const ContactInfoPage: PageComponentType<{ id: string }> = ({ id: contactId }) =
})
const filteredContacts = data?.contacts?.filter(Boolean)
const contact = Array.isArray(filteredContacts) && filteredContacts.length > 0 ? filteredContacts[0] : null
const contactLoading = useMemo(() => loading || !persistor, [loading, persistor])

const [updateContactMutation] = useUpdateContactMutation({
variables: {
Expand All @@ -249,8 +250,8 @@ const ContactInfoPage: PageComponentType<{ id: string }> = ({ id: contactId }) =
await push('/contact')
}, [push, updateContactMutation])

if (error || loading) {
return <LoadingOrErrorPage title={LoadingMessage} loading={loading} error={error ? ErrorMessage : null}/>
if (error || contactLoading) {
return <LoadingOrErrorPage title={LoadingMessage} loading={contactLoading} error={error ? ErrorMessage : null}/>
}
if (!contact) {
return <LoadingOrErrorPage title={ContactNotFoundTitle} loading={false} error={ContactNotFoundMessage}/>
Expand Down

0 comments on commit 8a7c4ac

Please sign in to comment.