client: fix data fetch

pull/60/head
fantasticit 2022-05-26 12:59:11 +08:00
parent 0fd93c31e6
commit 04ae4949e9
3 changed files with 3 additions and 5 deletions

View File

@ -51,9 +51,7 @@ export const DocumentCollaboration: React.FC<IProps> = ({ wikiId, documentId, di
const toastedUsersRef = useRef<Array<IUser['id']>>([]); const toastedUsersRef = useRef<Array<IUser['id']>>([]);
const { user: currentUser } = useUser(); const { user: currentUser } = useUser();
const [visible, toggleVisible] = useToggle(false); const [visible, toggleVisible] = useToggle(false);
const { users, loading, error, addUser, updateUser, deleteUser } = useDoumentMembers(documentId, { const { users, loading, error, addUser, updateUser, deleteUser } = useDoumentMembers(documentId);
enabled: visible,
});
const [inviteUser, setInviteUser] = useState(''); const [inviteUser, setInviteUser] = useState('');
const [collaborationUsers, setCollaborationUsers] = useState([]); const [collaborationUsers, setCollaborationUsers] = useState([]);

View File

@ -24,7 +24,7 @@ const { Title, Text } = Typography;
export const DocumentVersion: React.FC<IProps> = ({ documentId, disabled = false, onSelect }) => { export const DocumentVersion: React.FC<IProps> = ({ documentId, disabled = false, onSelect }) => {
const { isMobile } = IsOnMobile.useHook(); const { isMobile } = IsOnMobile.useHook();
const [visible, toggleVisible] = useToggle(false); const [visible, toggleVisible] = useToggle(false);
const { data, loading, error, refresh } = useDocumentVersion(documentId, { enabled: visible }); const { data, loading, error, refresh } = useDocumentVersion(documentId);
const [selectedVersion, setSelectedVersion] = useState(null); const [selectedVersion, setSelectedVersion] = useState(null);
const editor = useEditor({ const editor = useEditor({

View File

@ -206,7 +206,7 @@ export const getDocumentVersion = (
*/ */
export const useDocumentVersion = ( export const useDocumentVersion = (
documentId, documentId,
options: UseQueryOptions<Array<{ version: string; data: string; createUser: IUser }>> options: UseQueryOptions<Array<{ version: string; data: string; createUser: IUser }>> = {}
) => { ) => {
const { data, error, isLoading, refetch } = useQuery( const { data, error, isLoading, refetch } = useQuery(
DocumentApiDefinition.getVersionById.client(documentId), DocumentApiDefinition.getVersionById.client(documentId),