The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Avoid fetching more emails when first query loading (#3709)
Thomas Trompette9597b1ae4138
diff --git a/packages/twenty-front/src/modules/activities/emails/components/EmailThreads.tsx b/packages/twenty-front/src/modules/activities/emails/components/EmailThreads.tsxindex 816b63219b6..879bda9697b 100644--- a/packages/twenty-front/src/modules/activities/emails/components/EmailThreads.tsx+++ b/packages/twenty-front/src/modules/activities/emails/components/EmailThreads.tsx@@ -75,12 +75,21 @@ export const EmailThreads = ({pageSize: TIMELINE_THREADS_DEFAULT_PAGE_SIZE,} as GetTimelineThreadsFromPersonIdQueryVariables;- const { data, loading, fetchMore, error } = useQuery(threadQuery, {+ const {+ data,+ loading: firstQueryLoading,+ fetchMore,+ error,+ } = useQuery(threadQuery, {variables: threadQueryVariables,});const fetchMoreRecords = async () => {- if (emailThreadsPage.hasNextPage && !isFetchingMoreEmails) {+ if (+ emailThreadsPage.hasNextPage &&+ !isFetchingMoreEmails &&+ !firstQueryLoading+ ) {setIsFetchingMoreEmails(true);await fetchMore({@@ -144,7 +153,7 @@ export const EmailThreads = ({}fontColor={H1TitleFontColor.Primary}/>- {!loading && (+ {!firstQueryLoading && (<Card>{timelineThreads?.map((thread: TimelineThread, index: number) => (<EmailThreadPreview@@ -157,7 +166,7 @@ export const EmailThreads = ({</Card>)}<EmailThreadFetchMoreLoader- loading={isFetchingMoreEmails}+ loading={isFetchingMoreEmails || firstQueryLoading}onLastRowVisible={fetchMoreRecords}/></Section>