🚚(frontend) move useUpdateDocLink to doc-share feature

Move the `useUpdateDocLink` hook from the
`doc-management` feature to the `doc-share` feature
to better align with its functionality related
to document sharing.
This commit is contained in:
Anthony LC
2025-10-20 21:20:42 +02:00
parent 3e5bcf96ea
commit 7d5cc4e84b
5 changed files with 7 additions and 19 deletions

View File

@@ -9,4 +9,3 @@ export * from './useDuplicateDoc';
export * from './useRestoreDoc'; export * from './useRestoreDoc';
export * from './useSubDocs'; export * from './useSubDocs';
export * from './useUpdateDoc'; export * from './useUpdateDoc';
export * from './useUpdateDocLink';

View File

@@ -3,11 +3,7 @@ import { useMutation, useQueryClient } from '@tanstack/react-query';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { APIError, errorCauses, fetchAPI } from '@/api'; import { APIError, errorCauses, fetchAPI } from '@/api';
import { useBroadcastStore } from '@/stores'; import { Doc } from '@/docs/doc-management';
import { Doc } from '../types';
import { KEY_DOC } from './useDoc';
export type UpdateDocLinkParams = Pick<Doc, 'id' | 'link_reach'> & export type UpdateDocLinkParams = Pick<Doc, 'id' | 'link_reach'> &
Partial<Pick<Doc, 'link_role'>>; Partial<Pick<Doc, 'link_role'>>;
@@ -43,22 +39,18 @@ export function useUpdateDocLink({
listInvalideQueries, listInvalideQueries,
}: UpdateDocLinkProps = {}) { }: UpdateDocLinkProps = {}) {
const queryClient = useQueryClient(); const queryClient = useQueryClient();
const { broadcast } = useBroadcastStore();
const { toast } = useToastProvider(); const { toast } = useToastProvider();
const { t } = useTranslation(); const { t } = useTranslation();
return useMutation<Doc, APIError, UpdateDocLinkParams>({ return useMutation<Doc, APIError, UpdateDocLinkParams>({
mutationFn: updateDocLink, mutationFn: updateDocLink,
onSuccess: (data, variable) => { onSuccess: (data) => {
listInvalideQueries?.forEach((queryKey) => { listInvalideQueries?.forEach((queryKey) => {
void queryClient.invalidateQueries({ void queryClient.invalidateQueries({
queryKey: [queryKey], queryKey: [queryKey],
}); });
}); });
// Broadcast to every user connected to the document
broadcast(`${KEY_DOC}-${variable.id}`);
toast( toast(
t('The document visibility has been updated.'), t('The document visibility has been updated.'),
VariantType.SUCCESS, VariantType.SUCCESS,

View File

@@ -4,12 +4,9 @@ import { css } from 'styled-components';
import { Box, Text } from '@/components'; import { Box, Text } from '@/components';
import { useCunninghamTheme } from '@/cunningham'; import { useCunninghamTheme } from '@/cunningham';
import { import { Doc, KEY_DOC, KEY_LIST_DOC } from '@/docs/doc-management';
Doc,
KEY_DOC, import { useUpdateDocLink } from '../api/useUpdateDocLink';
KEY_LIST_DOC,
useUpdateDocLink,
} from '@/docs/doc-management';
import Desync from './../assets/desynchro.svg'; import Desync from './../assets/desynchro.svg';
import Undo from './../assets/undo.svg'; import Undo from './../assets/undo.svg';

View File

@@ -112,7 +112,7 @@ export const QuickSearchGroupMember = ({
elements: members, elements: members,
endActions: undefined, endActions: undefined,
}; };
}, [membersQuery, t]); }, [membersQuery.data, t]);
return ( return (
<Box aria-label={t('List members card')} $padding={{ bottom: '3xs' }}> <Box aria-label={t('List members card')} $padding={{ bottom: '3xs' }}>

View File

@@ -19,10 +19,10 @@ import {
getDocLinkReach, getDocLinkReach,
getDocLinkRole, getDocLinkRole,
useDocUtils, useDocUtils,
useUpdateDocLink,
} from '@/docs/doc-management'; } from '@/docs/doc-management';
import { useResponsiveStore } from '@/stores'; import { useResponsiveStore } from '@/stores';
import { useUpdateDocLink } from '../api/useUpdateDocLink';
import { useTranslatedShareSettings } from '../hooks/'; import { useTranslatedShareSettings } from '../hooks/';
import { DocDesynchronized } from './DocDesynchronized'; import { DocDesynchronized } from './DocDesynchronized';