From ac7583322cb50eaba4547f83cfc1cc068ecdb309 Mon Sep 17 00:00:00 2001 From: Koustav Date: Sun, 18 Aug 2024 10:49:30 +0530 Subject: [PATCH] fix: fetch count when new logs are being fetched --- src/pages/Stream/Views/Explore/Footer.tsx | 14 +++----------- src/pages/Stream/Views/Explore/JSONView.tsx | 9 +++++++-- src/pages/Stream/Views/Explore/LogsView.tsx | 7 +++++-- src/pages/Stream/Views/Explore/StaticLogTable.tsx | 9 +++++++-- src/pages/Stream/Views/Explore/useLogsFetcher.ts | 4 +++- 5 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/pages/Stream/Views/Explore/Footer.tsx b/src/pages/Stream/Views/Explore/Footer.tsx index 53eba707..f9a05902 100644 --- a/src/pages/Stream/Views/Explore/Footer.tsx +++ b/src/pages/Stream/Views/Explore/Footer.tsx @@ -1,4 +1,4 @@ -import { FC, useCallback, useState, useEffect } from 'react'; +import { FC, useCallback } from 'react'; import { useLogsStore, logsStoreReducers, LOAD_LIMIT, LOG_QUERY_LIMITS } from '../../providers/LogsProvider'; import { useAppStore } from '@/layouts/MainLayout/providers/AppProvider'; import { usePagination } from '@mantine/hooks'; @@ -10,7 +10,6 @@ import { HumanizeNumber } from '@/utils/formatBytes'; import IconButton from '@/components/Button/IconButton'; import { IconDownload, IconSelector } from '@tabler/icons-react'; import useMountedState from '@/hooks/useMountedState'; -import { useQueryResult } from '@/hooks/useQueryResult'; import classes from '../../styles/Footer.module.css'; const { setPageAndPageData, setCurrentPage, setCurrentOffset, makeExportData } = logsStoreReducers; @@ -93,18 +92,11 @@ const LimitControl: FC = () => { ); }; -const Footer = (props: { loaded: boolean; hasNoData: boolean }) => { - const [isFetchingCount, setIsFetchingCount] = useState(false); +const Footer = (props: { loaded: boolean; hasNoData: boolean; isFetchingCount: boolean }) => { const [currentStream] = useAppStore((store) => store.currentStream); const [tableOpts, setLogsStore] = useLogsStore((store) => store.tableOpts); const [filteredData] = useLogsStore((store) => store.data.filteredData); const { totalPages, currentOffset, currentPage, perPage, headers, totalCount } = tableOpts; - const { useFetchFooterCount } = useQueryResult(); - - const { footerCountLoading, footerCountRefetching } = useFetchFooterCount(); - useEffect(() => { - setIsFetchingCount(footerCountLoading || footerCountRefetching); - }, [footerCountLoading, footerCountRefetching]); const onPageChange = useCallback((page: number) => { setLogsStore((store) => setPageAndPageData(store, page)); @@ -147,7 +139,7 @@ const Footer = (props: { loaded: boolean; hasNoData: boolean }) => { diff --git a/src/pages/Stream/Views/Explore/JSONView.tsx b/src/pages/Stream/Views/Explore/JSONView.tsx index 62554aaf..e2a9bd18 100644 --- a/src/pages/Stream/Views/Explore/JSONView.tsx +++ b/src/pages/Stream/Views/Explore/JSONView.tsx @@ -174,7 +174,12 @@ const TableContainer = (props: { children: ReactNode }) => { return {props.children}; }; -const JsonView = (props: { errorMessage: string | null; hasNoData: boolean; showTable: boolean }) => { +const JsonView = (props: { + errorMessage: string | null; + hasNoData: boolean; + showTable: boolean; + isFetchingCount: boolean; +}) => { const [maximized] = useAppStore((store) => store.maximized); const { errorMessage, hasNoData, showTable } = props; @@ -209,7 +214,7 @@ const JsonView = (props: { errorMessage: string | null; hasNoData: boolean; show ) : ( )} -