Skip to content

Commit

Permalink
fixes: sorting, clean up side effect hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
insmac committed Dec 2, 2024
1 parent 1ea0d14 commit 9b16745
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
19 changes: 8 additions & 11 deletions packages/web-console/src/scenes/Editor/Metrics/metric.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,11 @@ export const TableSelector = ({
const enterPress = useKeyPress("Enter")
const wrapperRef = useRef<HTMLDivElement | null>(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
Expand Down
5 changes: 5 additions & 0 deletions packages/web-console/src/scenes/Schema/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,11 @@ const Schema = ({
: true)
)
})
.sort((a, b) =>
a.table_name
.toLowerCase()
.localeCompare(b.table_name.toLowerCase()),
)
.map((table: QuestDB.Table) => (
<Table
designatedTimestamp={table.designatedTimestamp}
Expand Down

0 comments on commit 9b16745

Please sign in to comment.