fix: don't show ellipses on search when query is in-flight (#723)

This commit is contained in:
Aaron Knudtson 2025-03-31 18:15:37 -04:00 committed by GitHub
parent 5a10ae1d47
commit 6864836329
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 26 additions and 14 deletions

View file

@ -0,0 +1,5 @@
---
"@hyperdx/app": patch
---
fix: don't show ellipses on search when query is in-flight

View file

@ -132,26 +132,33 @@ function SearchTotalCount({
granularity,
limit: { limit: 100000 },
};
const {
data: totalCountData,
isLoading,
isError,
} = useQueriedChartConfig(queriedConfig, {
queryKey: [queryKeyPrefix, queriedConfig],
staleTime: 1000 * 60 * 5,
refetchOnWindowFocus: false,
});
const { data: totalCountData, isError } = useQueriedChartConfig(
queriedConfig,
{
queryKey: [queryKeyPrefix, queriedConfig],
staleTime: 1000 * 60 * 5,
refetchOnWindowFocus: false,
},
);
const totalCount = useMemo(() => {
return totalCountData?.data?.reduce(
(p: number, v: any) => p + Number.parseInt(v['count()']),
0,
const [totalCount, setTotalCount] = useState<number | null>(null);
useEffect(() => {
if (!totalCountData) {
// if totalCount already exists, set to that. Else, set to null
setTotalCount(totalCount ?? null);
return;
}
setTotalCount(
totalCountData?.data?.reduce(
(p: number, v: any) => p + Number.parseInt(v['count()']),
0,
),
);
}, [totalCountData]);
return (
<Text size="xs" c="gray.4" mb={4}>
{isLoading ? (
{!totalCount ? (
<span className="effect-pulse">&middot;&middot;&middot; Results</span>
) : totalCount !== null && !isError ? (
`${totalCount} Results`