Skip to content

Commit 348765b

Browse files
committed
🩹(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.
1 parent 3257341 commit 348765b

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

src/frontend/apps/impress/src/features/docs/doc-management/api/useDuplicateDoc.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import * as Y from 'yjs';
77

88
import { APIError, errorCauses, fetchAPI } from '@/api';
99
import { toBase64 } from '@/docs/doc-editor';
10+
import { KEY_DOC_TREE } from '@/docs/doc-tree';
1011
import { KEY_LIST_DOC_VERSIONS } from '@/docs/doc-versioning';
1112

1213
import { useProviderStore } from '../stores';
@@ -85,6 +86,9 @@ export function useDuplicateDoc(options: DuplicateDocOptions) {
8586
void queryClient.resetQueries({
8687
queryKey: [KEY_LIST_DOC],
8788
});
89+
void queryClient.resetQueries({
90+
queryKey: [KEY_DOC_TREE],
91+
});
8892
void options.onSuccess?.(data, variables, context);
8993
},
9094
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export * from './useCreateChildren';
22
export * from './useDocChildren';
3+
export * from './useDocTree';
34
export * from './useMove';

src/frontend/apps/impress/src/features/docs/doc-tree/api/useDocTree.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const getDocTree = async ({ docId }: DocsTreeParams): Promise<Doc> => {
2525
return response.json() as Promise<Doc>;
2626
};
2727

28-
export const KEY_LIST_DOC_CHILDREN = 'doc-tree';
28+
export const KEY_DOC_TREE = 'doc-tree';
2929

3030
export function useDocTree(
3131
params: DocsTreeParams,
@@ -35,7 +35,7 @@ export function useDocTree(
3535
>,
3636
) {
3737
return useQuery<Doc, APIError, Doc>({
38-
queryKey: [KEY_LIST_DOC_CHILDREN, params],
38+
queryKey: [KEY_DOC_TREE, params],
3939
queryFn: () => getDocTree(params),
4040
staleTime: 0,
4141
refetchOnWindowFocus: false,

0 commit comments

Comments
 (0)