client: fix get version data

This commit is contained in:
fantasticit 2022-05-26 13:35:04 +08:00
parent 86d8cdac69
commit add3f93ebe
1 changed files with 1 additions and 7 deletions

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); const { data, loading, error, refresh } = useDocumentVersion(documentId, { enabled: visible });
const [selectedVersion, setSelectedVersion] = useState(null); const [selectedVersion, setSelectedVersion] = useState(null);
const editor = useEditor({ const editor = useEditor({
@ -52,12 +52,6 @@ export const DocumentVersion: React.FC<IProps> = ({ documentId, disabled = false
close(); close();
}, [selectedVersion, close, onSelect]); }, [selectedVersion, close, onSelect]);
useEffect(() => {
if (visible) {
refresh();
}
}, [visible, refresh]);
useEffect(() => { useEffect(() => {
if (!editor) return; if (!editor) return;
if (!data.length) return; if (!data.length) return;