Skip to content

Commit

Permalink
fix: Count call on timeRange change
Browse files Browse the repository at this point in the history
  • Loading branch information
praveen5959 committed Jan 8, 2025
1 parent 9755746 commit fa78d0c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/pages/Stream/Views/Explore/useLogsFetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@ const useLogsFetcher = (props: { isStoreSyncing: boolean }) => {
const { currentOffset, currentPage, pageData, totalCount } = tableOpts;
const { getQueryData, loading: logsLoading, error: errorMessage } = useQueryLogs();

const { refetchCount, isCountLoading, isCountRefetching } = useFetchCount();
const { isCountLoading, isCountRefetching } = useFetchCount();
const hasContentLoaded = !isCountLoading && !logsLoading && !isCountRefetching;
const hasNoData = hasContentLoaded && !errorMessage && pageData.length === 0;
const showTable = hasContentLoaded && !hasNoData && !errorMessage;

useEffect(() => {
setAppStore(syncTimeRange);
setLogsStore(setCleanStoreForStreamChange);
refetchCount();
}, [currentStream]);

useEffect(() => {
Expand Down
10 changes: 8 additions & 2 deletions src/pages/Stream/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { useParams } from 'react-router-dom';
import { STREAM_VIEWS } from '@/constants/routes';
import LogsView from './Views/Explore/LogsView';
import useParamsController from './hooks/useParamsController';
import { useFetchCount } from '@/hooks/useQueryResult';

const { streamChangeCleanup, toggleSideBar } = streamStoreReducers;

Expand All @@ -24,18 +25,23 @@ const Stream: FC = () => {
const [currentStream] = useAppStore((store) => store.currentStream);
const { isStoreSynced } = useParamsController();
const [maximized] = useAppStore((store) => store.maximized);
const [timeRange] = useAppStore((store) => store.timeRange);
const [instanceConfig] = useAppStore((store) => store.instanceConfig);
const [, setStreamStore] = useStreamStore((store) => store.sideBarOpen);
const { refetchCount } = useFetchCount();

useHotkeys([['mod+/', () => setStreamStore((store) => toggleSideBar(store))]]);

useEffect(() => {
if (isStoreSynced) {
if (!_.isEmpty(currentStream)) {
if (view === 'explore') setStreamStore(streamChangeCleanup);
if (view === 'explore') {
setStreamStore(streamChangeCleanup);
refetchCount();
}
}
}
}, [isStoreSynced, currentStream]);
}, [isStoreSynced, currentStream, timeRange]);

const sideBarWidth = SECONDARY_SIDEBAR_WIDTH;

Expand Down

0 comments on commit fa78d0c

Please sign in to comment.