mirror of
https://github.com/docmost/docmost.git
synced 2026-08-28 09:17:06 +08:00
cleanup tsvector usage
This commit is contained in:
@@ -44,7 +44,7 @@ export function KanbanColumn({
|
||||
[viewFilter, groupByPropertyId, column.key],
|
||||
);
|
||||
|
||||
const rowsQuery = useBaseRowsQuery(pageId, filter, undefined, undefined);
|
||||
const rowsQuery = useBaseRowsQuery(pageId, filter, undefined);
|
||||
const createCard = useKanbanCreateCardMutation();
|
||||
|
||||
const rows = useMemo(() => {
|
||||
|
||||
@@ -24,7 +24,6 @@ import {
|
||||
DeleteRowsInput,
|
||||
ReorderRowInput,
|
||||
FilterNode,
|
||||
SearchSpec,
|
||||
ViewSortConfig,
|
||||
RowReferences,
|
||||
NO_VALUE_CHOICE_ID,
|
||||
@@ -59,14 +58,12 @@ export function baseRowsQueryKey(
|
||||
pageId: string | undefined,
|
||||
filter: FilterNode | undefined,
|
||||
sorts: ViewSortConfig[] | undefined,
|
||||
search: SearchSpec | undefined,
|
||||
) {
|
||||
return [
|
||||
"base-rows",
|
||||
pageId,
|
||||
normalizeFilter(filter),
|
||||
sorts?.length ? sorts : undefined,
|
||||
search?.query ? search : undefined,
|
||||
] as const;
|
||||
}
|
||||
|
||||
@@ -87,21 +84,18 @@ export function useBaseRowsQuery(
|
||||
pageId: string | undefined,
|
||||
filter?: FilterNode,
|
||||
sorts?: ViewSortConfig[],
|
||||
search?: SearchSpec,
|
||||
) {
|
||||
const activeFilter = normalizeFilter(filter);
|
||||
const activeSorts = sorts?.length ? sorts : undefined;
|
||||
const activeSearch = search?.query ? search : undefined;
|
||||
|
||||
const query = useInfiniteQuery({
|
||||
queryKey: baseRowsQueryKey(pageId, filter, sorts, search),
|
||||
queryKey: baseRowsQueryKey(pageId, filter, sorts),
|
||||
queryFn: ({ pageParam }) =>
|
||||
listRows(pageId!, {
|
||||
cursor: pageParam,
|
||||
limit: 100,
|
||||
filter: activeFilter,
|
||||
sorts: activeSorts,
|
||||
search: activeSearch,
|
||||
}),
|
||||
enabled: !!pageId,
|
||||
initialPageParam: undefined as string | undefined,
|
||||
@@ -428,7 +422,6 @@ type KanbanMoveCardInput = {
|
||||
groupByPropertyId: string;
|
||||
destChoiceValue: string | null;
|
||||
position: string;
|
||||
search?: SearchSpec;
|
||||
};
|
||||
|
||||
type KanbanMoveCardContext = {
|
||||
@@ -447,12 +440,12 @@ export function useKanbanMoveCardMutation() {
|
||||
requestId: newRequestId(),
|
||||
}),
|
||||
onMutate: async (variables) => {
|
||||
const { pageId, rowId, sourceColumnFilter, destColumnFilter, columnChanged, groupByPropertyId, destChoiceValue, position, search } = variables;
|
||||
const { pageId, rowId, sourceColumnFilter, destColumnFilter, columnChanged, groupByPropertyId, destChoiceValue, position } = variables;
|
||||
|
||||
await queryClient.cancelQueries({ queryKey: ["base-rows", pageId] });
|
||||
|
||||
const sourceKey = baseRowsQueryKey(pageId, sourceColumnFilter, undefined, search);
|
||||
const destKey = baseRowsQueryKey(pageId, destColumnFilter, undefined, search);
|
||||
const sourceKey = baseRowsQueryKey(pageId, sourceColumnFilter, undefined);
|
||||
const destKey = baseRowsQueryKey(pageId, destColumnFilter, undefined);
|
||||
|
||||
const sourceSnapshot = queryClient.getQueryData<InfiniteData<IBaseRowsPage>>(sourceKey);
|
||||
const destSnapshot = queryClient.getQueryData<InfiniteData<IBaseRowsPage>>(destKey);
|
||||
@@ -531,7 +524,6 @@ type KanbanCreateCardInput = {
|
||||
groupByPropertyId: string;
|
||||
columnKey: string;
|
||||
position?: string;
|
||||
search?: SearchSpec;
|
||||
};
|
||||
|
||||
export function useKanbanCreateCardMutation() {
|
||||
@@ -545,8 +537,8 @@ export function useKanbanCreateCardMutation() {
|
||||
requestId: newRequestId(),
|
||||
}),
|
||||
onSuccess: (newRow, variables) => {
|
||||
const { pageId, destColumnFilter, search } = variables;
|
||||
const destKey = baseRowsQueryKey(pageId, destColumnFilter, undefined, search);
|
||||
const { pageId, destColumnFilter } = variables;
|
||||
const destKey = baseRowsQueryKey(pageId, destColumnFilter, undefined);
|
||||
queryClient.setQueryData<InfiniteData<IBaseRowsPage>>(destKey, (old) => {
|
||||
if (!old) return old;
|
||||
const lastPageIndex = old.pages.length - 1;
|
||||
|
||||
@@ -21,7 +21,6 @@ import {
|
||||
DeleteViewInput,
|
||||
UpdatePropertyResult,
|
||||
FilterNode,
|
||||
SearchSpec,
|
||||
ViewSortConfig,
|
||||
RowReferences,
|
||||
} from "@/ee/base/types/base.types";
|
||||
@@ -146,7 +145,6 @@ export async function listRows(
|
||||
limit?: number;
|
||||
filter?: FilterNode;
|
||||
sorts?: ViewSortConfig[];
|
||||
search?: SearchSpec;
|
||||
},
|
||||
): Promise<IBaseRowsPage> {
|
||||
const req = await api.post("/bases/rows", { pageId, ...params });
|
||||
|
||||
@@ -188,11 +188,6 @@ export type FilterGroup = {
|
||||
|
||||
export type FilterNode = FilterCondition | FilterGroup;
|
||||
|
||||
export type SearchSpec = {
|
||||
query: string;
|
||||
mode?: 'trgm' | 'fts';
|
||||
};
|
||||
|
||||
export const NO_VALUE_CHOICE_ID = '__no_value';
|
||||
|
||||
export const KANBAN_CARD_DRAG_TYPE = "base-kanban-card";
|
||||
|
||||
Reference in New Issue
Block a user