Skip to content

Commit 6c38ef7

Browse files
committed
feat: Refactor ListView sorting logic for clarity and update QueryListItem to conditionally render disabled chip for pending queries
1 parent ac0dbf0 commit 6c38ef7

2 files changed

Lines changed: 12 additions & 11 deletions

File tree

src/components/layout/ListView.tsx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,16 @@ export function ListView({ currentView, searchTerm, queries, mutations, selected
3838
});
3939

4040
// Sort queries so inactive ones go to the end
41-
const sortedData = currentView === "queries"
42-
? [...filteredData].sort((a, b) => {
43-
const aQuery = a as QueryData;
44-
const bQuery = b as QueryData;
45-
if (!aQuery.isActive && bQuery.isActive) return 1;
46-
if (aQuery.isActive && !bQuery.isActive) return -1;
47-
return 0;
48-
})
49-
: filteredData;
41+
const sortedData =
42+
currentView === "queries"
43+
? [...filteredData].sort((a, b) => {
44+
const aQuery = a as QueryData;
45+
const bQuery = b as QueryData;
46+
if (!aQuery.isActive && bQuery.isActive) return 1;
47+
if (aQuery.isActive && !bQuery.isActive) return -1;
48+
return 0;
49+
})
50+
: filteredData;
5051

5152
// Update keyboard navigation item count when sorted data changes
5253
useEffect(() => {
@@ -74,7 +75,7 @@ export function ListView({ currentView, searchTerm, queries, mutations, selected
7475
const originalIndex = queries.indexOf(query);
7576
return (
7677
<QueryListItem
77-
key={`${query.queryKey}-${index}`}
78+
key={query.queryHash}
7879
query={query}
7980
index={originalIndex}
8081
isSelected={selectedQueryIndex === originalIndex}

src/components/query/QueryListItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export function QueryListItem({ query, index, isSelected, onSelect, staggerIndex
8080
<div className="flex-1 font-mono text-xs text-gray-700 dark:text-gray-300 break-all">{formatQueryKeyShort(query.queryKey)}</div>
8181

8282
{/* Disabled chip for pending queries */}
83-
{query.state.status === "pending" && (
83+
{query.state.status === "pending" && !query.state.isFetching && (
8484
<Chip variant="disabled" size="sm">
8585
Disabled
8686
</Chip>

0 commit comments

Comments
 (0)