fix: source collections not updated during synchronization in view collection (#2480)

This commit is contained in:
katherinehhh 2023-08-18 15:17:18 +08:00 committed by GitHub
parent 1977e00414
commit 2ea97541c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -30,6 +30,7 @@ const PreviewCom = (props) => {
const [loading, setLoading] = useState(false);
const [dataSource, setDataSource] = useState([]);
const [sourceFields, setSourceFields] = useState([]);
const [sourceCollections, setSourceCollections] = useState(sources);
const field: any = useField();
const form = useForm();
const { getCollection, getInterface, getCollectionFields, getInheritCollections, getParentCollectionFields } =
@ -38,7 +39,7 @@ const PreviewCom = (props) => {
const initOptions = getOptions().filter((v) => !['relation', 'systemInfo'].includes(v.key));
useEffect(() => {
const data = [];
sources.forEach((item) => {
sourceCollections.forEach((item) => {
const collection = getCollection(item);
const inherits = getInheritCollections(item);
const result = inherits.map((v) => {
@ -70,8 +71,7 @@ const PreviewCom = (props) => {
});
});
setSourceFields(data);
}, [sources, databaseView]);
}, [sourceCollections, databaseView]);
useEffect(() => {
if (databaseView) {
setLoading(true);
@ -92,6 +92,7 @@ const PreviewCom = (props) => {
field.value = fieldsData;
setDataSource(fieldsData);
form.setValuesIn('sources', data.data?.sources);
setSourceCollections(data.data?.sources);
}
}).catch;
}