feat(search-ui): optimize search UI

This commit is contained in:
rustmailer
2026-01-19 01:52:07 +08:00
parent 48f8092b5a
commit 0d20a9676a
33 changed files with 2129 additions and 450 deletions
+2 -2
View File
@@ -17,7 +17,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
import { get_top_tags } from '@/api/search/api';
import { get_tags } from '@/api/search/api';
import { useQuery } from '@tanstack/react-query';
import React from 'react';
@@ -45,7 +45,7 @@ export function useAvailableTags(): UseAvailableTagsResult {
refetch,
} = useQuery<TagCount[]>({
queryKey: ['all-tags'],
queryFn: get_top_tags,
queryFn: get_tags,
staleTime: 60 * 1000,
retry: false,
refetchOnWindowFocus: false,
+26
View File
@@ -0,0 +1,26 @@
import { useMemo } from 'react';
import { useQuery } from '@tanstack/react-query';
import { get_contacts } from '@/api/search/api';
export const useContacts = (searchTerm: string = "") => {
const { data: allContacts = [], isLoading, isError } = useQuery({
queryKey: ['contacts', 'all'],
queryFn: get_contacts,
staleTime: 1000 * 60 * 10,
gcTime: 1000 * 60 * 30,
});
const filtered = useMemo(() => {
if (!searchTerm) return allContacts;
const lower = searchTerm.toLowerCase();
return allContacts.filter(email =>
email.toLowerCase().includes(lower)
);
}, [allContacts, searchTerm]);
return {
contacts: filtered,
isLoading,
isError
};
};
+2 -1
View File
@@ -92,6 +92,7 @@ export function useSearchMessages() {
setPage,
onSubmit,
reset,
filter
filter,
setFilter
};
}