add search stats
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import { SearchedUserFilesList } from '@/app/ui/search/searched-user-files-list';
|
||||
import { SearchedGlobalFilesList } from '@/app/ui/search/searched-global-files-list';
|
||||
import { useCallback, useState, useImperativeHandle } from 'react';
|
||||
import { searchUserFiles, searchGlobalFiles } from '@/app/actions/fileEntity';
|
||||
import { fa } from 'zod/v4/locales';
|
||||
import { searchUserFiles, searchGlobalFiles } from '@/app/actions/searchActions';
|
||||
import { useQueryClient } from '@tanstack/react-query';
|
||||
|
||||
export function FileSearchPanel({ fileId, ref }: { fileId: string | null, ref: any }) {
|
||||
const [searchedUserFiles, setSearchedUserFiles] = useState<string[]>([]);
|
||||
@@ -10,6 +10,7 @@ export function FileSearchPanel({ fileId, ref }: { fileId: string | null, ref: a
|
||||
const [searchedGlobalFiles, setSearchedGlobalFiles] = useState<string[]>([]);
|
||||
const [searchedGlobalFilesShowNull, setSearchedGlobalFilesShowNull] = useState<boolean>(false);
|
||||
const [loading, setLoading] = useState<boolean>(false);
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
useImperativeHandle(ref, () => ({
|
||||
clearList: () => {
|
||||
@@ -45,6 +46,7 @@ export function FileSearchPanel({ fileId, ref }: { fileId: string | null, ref: a
|
||||
|
||||
try {
|
||||
let result = await searchGlobalFiles(fileId);
|
||||
console.log(result);
|
||||
if (result.images.length) {
|
||||
setSearchedGlobalFiles(result.images);
|
||||
} else {
|
||||
@@ -53,6 +55,8 @@ export function FileSearchPanel({ fileId, ref }: { fileId: string | null, ref: a
|
||||
} catch (error) {
|
||||
|
||||
} finally {
|
||||
await queryClient.invalidateQueries({ queryKey: ['userData'] });
|
||||
await queryClient.invalidateQueries({ queryKey: ['userSearchData'] });
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user