Skip to content

Commit bb99ab3

Browse files
Copilothotlong
andcommitted
fix: address code review feedback — fix activeFilterCount, rename useWidgetData, extract constant
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent c05fb99 commit bb99ab3

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

components/renderers/ListViewRenderer.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,18 @@ export function ListViewRenderer({
319319
/* ---- Filter handlers ---- */
320320
const handleFilterApply = useCallback(
321321
(filter: unknown) => {
322-
if (filter === null) {
322+
if (filter === null || filter === undefined) {
323323
setActiveFilterCount(0);
324+
} else if (Array.isArray(filter)) {
325+
// ObjectQL compound: ['AND', f1, f2, …] → count child filters
326+
const logic = filter[0];
327+
setActiveFilterCount(
328+
typeof logic === "string" && (logic === "AND" || logic === "OR")
329+
? filter.length - 1
330+
: 1,
331+
);
332+
} else {
333+
setActiveFilterCount(1);
324334
}
325335
onFilterChange?.(filter);
326336
},

hooks/useDashboardData.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ export interface UseDashboardDataResult {
1212
isLoading: boolean;
1313
}
1414

15+
/* ------------------------------------------------------------------ */
16+
/* Constants */
17+
/* ------------------------------------------------------------------ */
18+
19+
const DEFAULT_LIST_PAGE_SIZE = 10;
20+
1521
/* ------------------------------------------------------------------ */
1622
/* Hook */
1723
/* ------------------------------------------------------------------ */
@@ -25,7 +31,7 @@ export interface UseDashboardDataResult {
2531
*/
2632
export function useWidgetQuery(widget: DashboardWidgetMeta): WidgetDataPayload {
2733
const { data, isLoading } = useQuery(widget.object, {
28-
top: widget.type === "list" || widget.type === "table" ? 10 : 1,
34+
top: widget.type === "list" || widget.type === "table" ? DEFAULT_LIST_PAGE_SIZE : 1,
2935
enabled: !!widget.object,
3036
});
3137

@@ -108,6 +114,6 @@ export function useWidgetQuery(widget: DashboardWidgetMeta): WidgetDataPayload {
108114
* by wrapping each query in its own sub-component (see
109115
* `DashboardDataProvider` pattern in the app route layer).
110116
*/
111-
export function useSingleWidgetData(widget: DashboardWidgetMeta) {
117+
export function useWidgetData(widget: DashboardWidgetMeta) {
112118
return useWidgetQuery(widget);
113119
}

0 commit comments

Comments
 (0)