🚚(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:
@@ -9,4 +9,3 @@ export * from './useDuplicateDoc';
|
||||
export * from './useRestoreDoc';
|
||||
export * from './useSubDocs';
|
||||
export * from './useUpdateDoc';
|
||||
export * from './useUpdateDocLink';
|
||||
|
||||
@@ -3,11 +3,7 @@ import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { APIError, errorCauses, fetchAPI } from '@/api';
|
||||
import { useBroadcastStore } from '@/stores';
|
||||
|
||||
import { Doc } from '../types';
|
||||
|
||||
import { KEY_DOC } from './useDoc';
|
||||
import { Doc } from '@/docs/doc-management';
|
||||
|
||||
export type UpdateDocLinkParams = Pick<Doc, 'id' | 'link_reach'> &
|
||||
Partial<Pick<Doc, 'link_role'>>;
|
||||
@@ -43,22 +39,18 @@ export function useUpdateDocLink({
|
||||
listInvalideQueries,
|
||||
}: UpdateDocLinkProps = {}) {
|
||||
const queryClient = useQueryClient();
|
||||
const { broadcast } = useBroadcastStore();
|
||||
const { toast } = useToastProvider();
|
||||
const { t } = useTranslation();
|
||||
|
||||
return useMutation<Doc, APIError, UpdateDocLinkParams>({
|
||||
mutationFn: updateDocLink,
|
||||
onSuccess: (data, variable) => {
|
||||
onSuccess: (data) => {
|
||||
listInvalideQueries?.forEach((queryKey) => {
|
||||
void queryClient.invalidateQueries({
|
||||
queryKey: [queryKey],
|
||||
});
|
||||
});
|
||||
|
||||
// Broadcast to every user connected to the document
|
||||
broadcast(`${KEY_DOC}-${variable.id}`);
|
||||
|
||||
toast(
|
||||
t('The document visibility has been updated.'),
|
||||
VariantType.SUCCESS,
|
||||
@@ -4,12 +4,9 @@ import { css } from 'styled-components';
|
||||
|
||||
import { Box, Text } from '@/components';
|
||||
import { useCunninghamTheme } from '@/cunningham';
|
||||
import {
|
||||
Doc,
|
||||
KEY_DOC,
|
||||
KEY_LIST_DOC,
|
||||
useUpdateDocLink,
|
||||
} from '@/docs/doc-management';
|
||||
import { Doc, KEY_DOC, KEY_LIST_DOC } from '@/docs/doc-management';
|
||||
|
||||
import { useUpdateDocLink } from '../api/useUpdateDocLink';
|
||||
|
||||
import Desync from './../assets/desynchro.svg';
|
||||
import Undo from './../assets/undo.svg';
|
||||
|
||||
@@ -112,7 +112,7 @@ export const QuickSearchGroupMember = ({
|
||||
elements: members,
|
||||
endActions: undefined,
|
||||
};
|
||||
}, [membersQuery, t]);
|
||||
}, [membersQuery.data, t]);
|
||||
|
||||
return (
|
||||
<Box aria-label={t('List members card')} $padding={{ bottom: '3xs' }}>
|
||||
|
||||
@@ -19,10 +19,10 @@ import {
|
||||
getDocLinkReach,
|
||||
getDocLinkRole,
|
||||
useDocUtils,
|
||||
useUpdateDocLink,
|
||||
} from '@/docs/doc-management';
|
||||
import { useResponsiveStore } from '@/stores';
|
||||
|
||||
import { useUpdateDocLink } from '../api/useUpdateDocLink';
|
||||
import { useTranslatedShareSettings } from '../hooks/';
|
||||
|
||||
import { DocDesynchronized } from './DocDesynchronized';
|
||||
|
||||
Reference in New Issue
Block a user