The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
fix: EmailThreads and Calendar making one extra graphql requests even total records are fetched (#6814)
Nabhag Motivarasea7b9e90c95c
diff --git a/packages/twenty-front/src/modules/activities/calendar/components/Calendar.tsx b/packages/twenty-front/src/modules/activities/calendar/components/Calendar.tsxindex 5bc8afa2171..360eccbbcc2 100644--- a/packages/twenty-front/src/modules/activities/calendar/components/Calendar.tsx+++ b/packages/twenty-front/src/modules/activities/calendar/components/Calendar.tsx@@ -63,7 +63,18 @@ export const Calendar = ({TIMELINE_CALENDAR_EVENTS_DEFAULT_PAGE_SIZE,);- const { timelineCalendarEvents } = data?.[queryName] ?? {};+ const { timelineCalendarEvents, totalNumberOfCalendarEvents } =+ data?.[queryName] ?? {};+ const hasMoreCalendarEvents =+ timelineCalendarEvents && totalNumberOfCalendarEvents+ ? timelineCalendarEvents?.length < totalNumberOfCalendarEvents+ : false;++ const handleLastRowVisible = async () => {+ if (hasMoreCalendarEvents) {+ await fetchMoreRecords();+ }+ };const {calendarEventsByDayTime,@@ -134,7 +145,7 @@ export const Calendar = ({})}<CustomResolverFetchMoreLoaderloading={isFetchingMore || firstQueryLoading}- onLastRowVisible={fetchMoreRecords}+ onLastRowVisible={handleLastRowVisible}/></StyledContainer></CalendarContext.Provider>diff --git a/packages/twenty-front/src/modules/activities/emails/components/EmailThreads.tsx b/packages/twenty-front/src/modules/activities/emails/components/EmailThreads.tsxindex 53038755dc8..17f44524fea 100644--- a/packages/twenty-front/src/modules/activities/emails/components/EmailThreads.tsx+++ b/packages/twenty-front/src/modules/activities/emails/components/EmailThreads.tsx@@ -60,6 +60,16 @@ export const EmailThreads = ({);const { totalNumberOfThreads, timelineThreads } = data?.[queryName] ?? {};+ const hasMoreTimelineThreads =+ timelineThreads && totalNumberOfThreads+ ? timelineThreads?.length < totalNumberOfThreads+ : false;++ const handleLastRowVisible = async () => {+ if (hasMoreTimelineThreads) {+ await fetchMoreRecords();+ }+ };if (firstQueryLoading) {return <SkeletonLoader />;@@ -108,7 +118,7 @@ export const EmailThreads = ({)}<CustomResolverFetchMoreLoaderloading={isFetchingMore || firstQueryLoading}- onLastRowVisible={fetchMoreRecords}+ onLastRowVisible={handleLastRowVisible}/></Section></StyledContainer>