Skip to content

Commit 312259b

Browse files
authored
chore: user v2 content count query for search (supabase#39869)
* chore: user v2 content count query for search Instead of using two different endpoint versions, we can rely on v2 for all cases. * Update SearchList.tsx
1 parent af48b1c commit 312259b

File tree

3 files changed

+5
-9
lines changed

3 files changed

+5
-9
lines changed

apps/studio/components/layouts/SQLEditorLayout/SQLEditorNavV2/SearchList.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,12 @@ export const SearchList = ({ search }: SearchListProps) => {
4545
const { data: count, isLoading: isLoadingCount } = useContentCountQuery(
4646
{
4747
projectRef,
48-
cumulative: true,
4948
type: 'sql',
5049
name: search,
5150
},
5251
{ keepPreviousData: true }
5352
)
54-
const totalNumber = (count as unknown as { count: number })?.count ?? 0
53+
const totalNumber = count ? count.private + count.shared : 0
5554

5655
const snippets = useMemo(
5756
// [Joshen] Set folder_id to null to ensure flat list

apps/studio/data/content/content-count-query.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ import { contentKeys } from './keys'
88
type GetContentCountVariables =
99
operations['ContentController_getContentCountV2']['parameters']['query'] & {
1010
projectRef?: string
11-
cumulative?: boolean
1211
}
1312

1413
export async function getContentCount(
15-
{ projectRef, cumulative, type, name }: GetContentCountVariables,
14+
{ projectRef, type, name }: GetContentCountVariables,
1615
signal?: AbortSignal
1716
) {
1817
if (typeof projectRef === 'undefined') throw new Error('projectRef is required')
@@ -25,7 +24,7 @@ export async function getContentCount(
2524
...(name && { name }),
2625
},
2726
},
28-
...(cumulative ? {} : { headers: { Version: '2' } }),
27+
headers: { Version: '2' },
2928
signal,
3029
})
3130

@@ -37,15 +36,14 @@ export type ContentIdData = Awaited<ReturnType<typeof getContentCount>>
3736
export type ContentIdError = ResponseError
3837

3938
export const useContentCountQuery = <TData = ContentIdData>(
40-
{ projectRef, cumulative, type, name }: GetContentCountVariables,
39+
{ projectRef, type, name }: GetContentCountVariables,
4140
{ enabled = true, ...options }: UseQueryOptions<ContentIdData, ContentIdError, TData> = {}
4241
) =>
4342
useQuery<ContentIdData, ContentIdError, TData>(
4443
contentKeys.count(projectRef, type, {
45-
cumulative,
4644
name,
4745
}),
48-
({ signal }) => getContentCount({ projectRef, cumulative, type, name }, signal),
46+
({ signal }) => getContentCount({ projectRef, type, name }, signal),
4947
{
5048
enabled: enabled && typeof projectRef !== 'undefined',
5149
...options,

apps/studio/data/content/keys.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ export const contentKeys = {
3737
projectRef: string | undefined,
3838
type?: string,
3939
options?: {
40-
cumulative?: boolean
4140
visibility?: string
4241
favorite?: boolean
4342
name?: string

0 commit comments

Comments
 (0)