mirror of
https://github.com/docmost/docmost.git
synced 2026-05-18 23:44:24 +08:00
de60aa7e61
* feat: synced blocks (transclusion) * fix:remove name * make placeholders smaller * feat: enforce strict transclusion schema * fix: scope synced blocks to workspace, gate unsync on edit permission * fix collab module error
33 lines
820 B
TypeScript
33 lines
820 B
TypeScript
import { useMutation, useQuery } from "@tanstack/react-query";
|
|
import {
|
|
listReferences,
|
|
unsyncReference,
|
|
} from "../services/transclusion-api";
|
|
|
|
export function useReferencesQuery(
|
|
sourcePageId: string | null,
|
|
transclusionId: string | null,
|
|
enabled: boolean,
|
|
) {
|
|
return useQuery({
|
|
queryKey: ["transclusion-references", sourcePageId, transclusionId],
|
|
queryFn: () =>
|
|
listReferences({
|
|
sourcePageId: sourcePageId!,
|
|
transclusionId: transclusionId!,
|
|
}),
|
|
enabled: enabled && !!sourcePageId && !!transclusionId,
|
|
staleTime: 10 * 1000,
|
|
});
|
|
}
|
|
|
|
export function useUnsyncReferenceMutation() {
|
|
return useMutation({
|
|
mutationFn: (params: {
|
|
referencePageId: string;
|
|
sourcePageId: string;
|
|
transclusionId: string;
|
|
}) => unsyncReference(params),
|
|
});
|
|
}
|