client: fix data fetch

This commit is contained in:
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 { user: currentUser } = useUser();
const [visible, toggleVisible] = useToggle(false);
const { users, loading, error, addUser, updateUser, deleteUser } = useDoumentMembers(documentId, {
enabled: visible,
});
const { users, loading, error, addUser, updateUser, deleteUser } = useDoumentMembers(documentId);
const [inviteUser, setInviteUser] = 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 }) => {
const { isMobile } = IsOnMobile.useHook();
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 editor = useEditor({

View File

@ -206,7 +206,7 @@ export const getDocumentVersion = (
*/
export const useDocumentVersion = (
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(
DocumentApiDefinition.getVersionById.client(documentId),