mirror of
https://github.com/twentyhq/twenty.git
synced 2024-11-24 14:53:52 +03:00
Avoid fetching more emails when first query loading (#3709)
Co-authored-by: Thomas Trompette <thomast@twenty.com>
This commit is contained in:
parent
06e35e5119
commit
9597b1ae41
@ -75,12 +75,21 @@ export const EmailThreads = ({
|
|||||||
pageSize: TIMELINE_THREADS_DEFAULT_PAGE_SIZE,
|
pageSize: TIMELINE_THREADS_DEFAULT_PAGE_SIZE,
|
||||||
} as GetTimelineThreadsFromPersonIdQueryVariables;
|
} as GetTimelineThreadsFromPersonIdQueryVariables;
|
||||||
|
|
||||||
const { data, loading, fetchMore, error } = useQuery(threadQuery, {
|
const {
|
||||||
|
data,
|
||||||
|
loading: firstQueryLoading,
|
||||||
|
fetchMore,
|
||||||
|
error,
|
||||||
|
} = useQuery(threadQuery, {
|
||||||
variables: threadQueryVariables,
|
variables: threadQueryVariables,
|
||||||
});
|
});
|
||||||
|
|
||||||
const fetchMoreRecords = async () => {
|
const fetchMoreRecords = async () => {
|
||||||
if (emailThreadsPage.hasNextPage && !isFetchingMoreEmails) {
|
if (
|
||||||
|
emailThreadsPage.hasNextPage &&
|
||||||
|
!isFetchingMoreEmails &&
|
||||||
|
!firstQueryLoading
|
||||||
|
) {
|
||||||
setIsFetchingMoreEmails(true);
|
setIsFetchingMoreEmails(true);
|
||||||
|
|
||||||
await fetchMore({
|
await fetchMore({
|
||||||
@ -144,7 +153,7 @@ export const EmailThreads = ({
|
|||||||
}
|
}
|
||||||
fontColor={H1TitleFontColor.Primary}
|
fontColor={H1TitleFontColor.Primary}
|
||||||
/>
|
/>
|
||||||
{!loading && (
|
{!firstQueryLoading && (
|
||||||
<Card>
|
<Card>
|
||||||
{timelineThreads?.map((thread: TimelineThread, index: number) => (
|
{timelineThreads?.map((thread: TimelineThread, index: number) => (
|
||||||
<EmailThreadPreview
|
<EmailThreadPreview
|
||||||
@ -157,7 +166,7 @@ export const EmailThreads = ({
|
|||||||
</Card>
|
</Card>
|
||||||
)}
|
)}
|
||||||
<EmailThreadFetchMoreLoader
|
<EmailThreadFetchMoreLoader
|
||||||
loading={isFetchingMoreEmails}
|
loading={isFetchingMoreEmails || firstQueryLoading}
|
||||||
onLastRowVisible={fetchMoreRecords}
|
onLastRowVisible={fetchMoreRecords}
|
||||||
/>
|
/>
|
||||||
</Section>
|
</Section>
|
||||||
|
Loading…
Reference in New Issue
Block a user