From 9b16745622ccf269f9eabc05cb190628545afdca Mon Sep 17 00:00:00 2001 From: Maciej Bodek Date: Mon, 2 Dec 2024 13:19:02 +0100 Subject: [PATCH] fixes: sorting, clean up side effect hooks --- packages/browser-tests/questdb | 2 +- .../src/scenes/Editor/Metrics/metric.tsx | 19 ++++++++----------- .../scenes/Editor/Metrics/table-selector.tsx | 8 +++++--- .../web-console/src/scenes/Schema/index.tsx | 5 +++++ 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/packages/browser-tests/questdb b/packages/browser-tests/questdb index a80a38285..04e3e945a 160000 --- a/packages/browser-tests/questdb +++ b/packages/browser-tests/questdb @@ -1 +1 @@ -Subproject commit a80a38285cee87227e4cc881fb5cdf97be558449 +Subproject commit 04e3e945a9b7ac803b645dfc122da879d510fa9e diff --git a/packages/web-console/src/scenes/Editor/Metrics/metric.tsx b/packages/web-console/src/scenes/Editor/Metrics/metric.tsx index d3f3a35b6..deae1d11e 100644 --- a/packages/web-console/src/scenes/Editor/Metrics/metric.tsx +++ b/packages/web-console/src/scenes/Editor/Metrics/metric.tsx @@ -216,20 +216,11 @@ export const Metric = ({ useEffect(() => { metricDurationRef.current = metricDuration + if (metric.tableId) { fetchMetric() setupListeners() } - }, [metricDuration, metric.tableId]) - - const focusListener = useCallback(() => { - if (focusListenerRef.current) { - fetchMetric() - } - }, [metric.tableId]) - - useEffect(() => { - setupListeners() return () => { if (intervalRef.current) { @@ -240,7 +231,13 @@ export const Metric = ({ focusListenerRef.current = false } } - }, [autoRefreshTables]) + }, [autoRefreshTables, metricDuration, metric.tableId]) + + const focusListener = useCallback(() => { + if (focusListenerRef.current) { + fetchMetric() + } + }, [metric.tableId]) if (!data && !loading && metric.tableId) return ( diff --git a/packages/web-console/src/scenes/Editor/Metrics/table-selector.tsx b/packages/web-console/src/scenes/Editor/Metrics/table-selector.tsx index 444df2f2c..534ed252f 100644 --- a/packages/web-console/src/scenes/Editor/Metrics/table-selector.tsx +++ b/packages/web-console/src/scenes/Editor/Metrics/table-selector.tsx @@ -98,9 +98,11 @@ export const TableSelector = ({ const enterPress = useKeyPress("Enter") const wrapperRef = useRef(null) - const filteredOptions = options.filter((option) => - query ? option.label.toLowerCase().includes(query.toLowerCase()) : true, - ) + const filteredOptions = options + .filter((option) => + query ? option.label.toLowerCase().includes(query.toLowerCase()) : true, + ) + .sort((a, b) => a.label.toLowerCase().localeCompare(b.label.toLowerCase())) useEffect(() => { if (!inputRef.current) return diff --git a/packages/web-console/src/scenes/Schema/index.tsx b/packages/web-console/src/scenes/Schema/index.tsx index 3b4f5d32b..499b46475 100644 --- a/packages/web-console/src/scenes/Schema/index.tsx +++ b/packages/web-console/src/scenes/Schema/index.tsx @@ -347,6 +347,11 @@ const Schema = ({ : true) ) }) + .sort((a, b) => + a.table_name + .toLowerCase() + .localeCompare(b.table_name.toLowerCase()), + ) .map((table: QuestDB.Table) => (