mirror of
https://github.com/docmost/docmost.git
synced 2025-11-13 11:02:37 +10:00
* Work on mentions * fix: properly parse page slug * fix editor suggestion bugs * mentions must start with whitespace * add icon to page mention render * feat: backlinks - WIP * UI - WIP * permissions check * use FTS for page suggestion * cleanup * WIP * page title fallback * feat: handle internal link paste * link styling * WIP * Switch back to LIKE operator for search suggestion * WIP * scope to workspaceId * still create link for pages not found * select necessary columns * cleanups
33 lines
856 B
TypeScript
33 lines
856 B
TypeScript
import { useQuery, UseQueryResult } from "@tanstack/react-query";
|
|
import {
|
|
searchPage,
|
|
searchSuggestions,
|
|
} from "@/features/search/services/search-service";
|
|
import {
|
|
IPageSearch,
|
|
IPageSearchParams,
|
|
ISuggestionResult,
|
|
SearchSuggestionParams,
|
|
} from "@/features/search/types/search.types";
|
|
|
|
export function usePageSearchQuery(
|
|
params: IPageSearchParams,
|
|
): UseQueryResult<IPageSearch[], Error> {
|
|
return useQuery({
|
|
queryKey: ["page-search", params],
|
|
queryFn: () => searchPage(params),
|
|
enabled: !!params.query,
|
|
});
|
|
}
|
|
|
|
export function useSearchSuggestionsQuery(
|
|
params: SearchSuggestionParams,
|
|
): UseQueryResult<ISuggestionResult, Error> {
|
|
return useQuery({
|
|
queryKey: ["search-suggestion", params.query],
|
|
staleTime: 60 * 1000, // 1min
|
|
queryFn: () => searchSuggestions(params),
|
|
enabled: !!params.query,
|
|
});
|
|
}
|