diff --git a/packages/core/src/search/search.test.ts b/packages/core/src/search/search.test.ts index 27f00a7c..7ae1f6ae 100644 --- a/packages/core/src/search/search.test.ts +++ b/packages/core/src/search/search.test.ts @@ -741,6 +741,7 @@ describe('SearchService', () => { // Search files recursively const resultRecursive = await searchService.search(rootFolder.id, { + conditions: [], recursively: true, assetType: 'file', operator: 'AND', @@ -752,6 +753,7 @@ describe('SearchService', () => { // Search files non-recursively const resultNonRecursive = await searchService.search(rootFolder.id, { + conditions: [], recursively: false, assetType: 'file', operator: 'AND', @@ -773,6 +775,8 @@ describe('SearchService', () => { return [{ count: 2500n }] } // For main query, just run it or return mock + // We must cast to any because we are proxying the raw sql parameter + // eslint-disable-next-line @typescript-eslint/no-explicit-any return target.$queryRaw(prismaSql as any) } } @@ -784,10 +788,14 @@ describe('SearchService', () => { }, }) + // We must cast mockPrisma proxy as any because the type signature of SearchService + // expects a full PrismaClient instance, whereas we only mocked $queryRaw. + // eslint-disable-next-line @typescript-eslint/no-explicit-any const localSearchService = new SearchService(mockPrisma as any) const { rootFolder } = await setupBasicAssets() const result = await localSearchService.search(rootFolder.id, { + conditions: [], recursively: true, assetType: 'file', operator: 'AND', diff --git a/packages/core/src/search/search.ts b/packages/core/src/search/search.ts index 4b64bb64..ce44da81 100644 --- a/packages/core/src/search/search.ts +++ b/packages/core/src/search/search.ts @@ -191,7 +191,9 @@ export class SearchService { if (totalCount < 2000) { countBuilder.select(Prisma.sql`SUM(COALESCE(a.size_byte, 0))::bigint as sum`) - const sumRes = await this.prismaClient.$queryRaw<{ sum: bigint | null }[]>(countBuilder.build()) + const sumRes = await this.prismaClient.$queryRaw<{ sum: bigint | null }[]>( + countBuilder.build(), + ) pageInfo.totalSize = Number(sumRes[0]?.sum || 0) } else { pageInfo.totalSize = -1 @@ -380,7 +382,9 @@ export class SearchService { if (totalCount < 2000) { countBuilder.select(Prisma.sql`SUM(COALESCE(a.size_byte, 0))::bigint as sum`) - const sumRes = await this.prismaClient.$queryRaw<{ sum: bigint | null }[]>(countBuilder.build()) + const sumRes = await this.prismaClient.$queryRaw<{ sum: bigint | null }[]>( + countBuilder.build(), + ) pageInfo.totalSize = Number(sumRes[0]?.sum || 0) } else { pageInfo.totalSize = -1 @@ -413,7 +417,9 @@ export class SearchService { countBuilder.addWhere(Prisma.sql`a.name ILIKE ${'%' + valStr + '%'}`) } - const sumRes = await this.prismaClient.$queryRaw<{ sum: bigint | null }[]>(countBuilder.build()) + const sumRes = await this.prismaClient.$queryRaw<{ sum: bigint | null }[]>( + countBuilder.build(), + ) pageInfo.totalSize = Number(sumRes[0]?.sum || 0) } else { pageInfo.totalSize = -1 diff --git a/packages/webui/components/file-browser/file-browser.tsx b/packages/webui/components/file-browser/file-browser.tsx index b943b2c4..8f1b2acd 100644 --- a/packages/webui/components/file-browser/file-browser.tsx +++ b/packages/webui/components/file-browser/file-browser.tsx @@ -824,7 +824,6 @@ export function FileBrowser({ handleEmptyAreaClick={handleEmptyAreaClick} dragState={dragState} sort={sort} - scrollContainerRef={scrollContainerRef} /> ) : ( )} - {formatCount(count, !isFolder)}{showSize ? ` • ${formatSize(size)}` : ''} + {formatCount(count, !isFolder)} + {showSize ? ` • ${formatSize(size)}` : ''} diff --git a/packages/webui/components/file-browser/list-view.tsx b/packages/webui/components/file-browser/list-view.tsx index 17a4d398..188c4915 100644 --- a/packages/webui/components/file-browser/list-view.tsx +++ b/packages/webui/components/file-browser/list-view.tsx @@ -144,7 +144,6 @@ interface FileBrowserListViewProps { handleEmptyAreaClick: (e: React.MouseEvent) => void dragState?: DragState sort?: SearchSort - scrollContainerRef: React.RefObject } export function FileBrowserListView({ @@ -173,7 +172,6 @@ export function FileBrowserListView({ handleEmptyAreaClick, dragState, sort, - scrollContainerRef, }: FileBrowserListViewProps) { const [columnSizing, setColumnSizing] = useState>({}) @@ -253,9 +251,11 @@ export function FileBrowserListView({ return list }, [foldersExpanded, filesExpanded, folders.length, files.length, totalFolders, totalFiles]) + const localScrollRef = React.useRef(null) + const rowVirtualizer = useVirtualizer({ count: items.length, - getScrollElement: () => scrollContainerRef.current, + getScrollElement: () => localScrollRef.current, estimateSize: () => 40, overscan: 10, }) @@ -305,7 +305,7 @@ export function FileBrowserListView({ ]) return ( - + - {formatCount(count, !isFolder)}{showSize ? ` • ${formatSize(size)}` : ''} + {formatCount(count, !isFolder)} + {showSize ? ` • ${formatSize(size)}` : ''}