🩹(frontend) refresh tree after duplicate
After duplicating a document, the tree is now refreshed to reflect the new structure. This ensures that the user sees the updated document tree immediately after the duplication action.
This commit is contained in:
@@ -7,6 +7,7 @@ import * as Y from 'yjs';
|
||||
|
||||
import { APIError, errorCauses, fetchAPI } from '@/api';
|
||||
import { toBase64 } from '@/docs/doc-editor';
|
||||
import { KEY_DOC_TREE } from '@/docs/doc-tree';
|
||||
import { KEY_LIST_DOC_VERSIONS } from '@/docs/doc-versioning';
|
||||
|
||||
import { useProviderStore } from '../stores';
|
||||
@@ -85,6 +86,9 @@ export function useDuplicateDoc(options: DuplicateDocOptions) {
|
||||
void queryClient.resetQueries({
|
||||
queryKey: [KEY_LIST_DOC],
|
||||
});
|
||||
void queryClient.resetQueries({
|
||||
queryKey: [KEY_DOC_TREE],
|
||||
});
|
||||
void options.onSuccess?.(data, variables, context);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
export * from './useCreateChildren';
|
||||
export * from './useDocChildren';
|
||||
export * from './useDocTree';
|
||||
export * from './useMove';
|
||||
|
||||
@@ -25,7 +25,7 @@ export const getDocTree = async ({ docId }: DocsTreeParams): Promise<Doc> => {
|
||||
return response.json() as Promise<Doc>;
|
||||
};
|
||||
|
||||
export const KEY_LIST_DOC_CHILDREN = 'doc-tree';
|
||||
export const KEY_DOC_TREE = 'doc-tree';
|
||||
|
||||
export function useDocTree(
|
||||
params: DocsTreeParams,
|
||||
@@ -35,7 +35,7 @@ export function useDocTree(
|
||||
>,
|
||||
) {
|
||||
return useQuery<Doc, APIError, Doc>({
|
||||
queryKey: [KEY_LIST_DOC_CHILDREN, params],
|
||||
queryKey: [KEY_DOC_TREE, params],
|
||||
queryFn: () => getDocTree(params),
|
||||
staleTime: 0,
|
||||
refetchOnWindowFocus: false,
|
||||
|
||||
Reference in New Issue
Block a user