Skip to content

Commit aae18b2

Browse files
committed
Fixed more coderabbit review comments for some scenario it suggested
1 parent 1829dee commit aae18b2

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

web/pgadmin/tools/sqleditor/static/js/components/sections/GeometryViewer.jsx

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -511,17 +511,7 @@ export function GeometryViewer({rows, columns, column}) {
511511
if (currentColumnKey === prevState.columnKey &&
512512
currentColumnNames === prevState.columnNames &&
513513
rows.length > 0) {
514-
let newSelectedRowData;
515-
if (prevState.selectedRowData.length === 0) {
516-
// No previous selection, show all rows
517-
newSelectedRowData = rows;
518-
} else if (prevState.selectedRowData.length < rows.length) {
519-
const matched = matchRowSelection(prevState.selectedRowData, rows, pkColumn, columns);
520-
newSelectedRowData = matched.length > 0 ? matched : rows;
521-
} else {
522-
newSelectedRowData = rows;
523-
}
524-
prevStateRef.current.selectedRowData = newSelectedRowData;
514+
prevStateRef.current.selectedRowData = displayRows;
525515
}
526516
}, [currentColumnKey, currentColumnNames, rows, pkColumn, columns]);
527517

@@ -532,10 +522,15 @@ export function GeometryViewer({rows, columns, column}) {
532522
if (currentColumnKey !== prevState.columnKey || currentColumnNames !== prevState.columnNames) {
533523
return rows;
534524
}
535-
536-
const selected = prevState.selectedRowData;
537-
return selected.length > 0 && selected.length < rows.length ? selected : rows;
538-
}, [rows, currentColumnKey, currentColumnNames]);
525+
526+
const prevSelected = prevState.selectedRowData;
527+
if (prevSelected.length === 0) return rows;
528+
if (prevSelected.length < rows.length) {
529+
const matched = matchRowSelection(prevSelected, rows, pkColumn, columns);
530+
return matched.length > 0 ? matched : rows;
531+
}
532+
return rows;
533+
}, [rows, currentColumnKey, currentColumnNames, pkColumn, columns]);
539534

540535
// Parse geometry data only when needed
541536
const data = React.useMemo(() => {

0 commit comments

Comments
 (0)