mirror of
https://github.com/twentyhq/twenty.git
synced 2024-11-24 06:48:42 +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,
|
||||
} 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>
|
||||
|
Loading…
Reference in New Issue
Block a user