fix: remove updateCollection

This commit is contained in:
chenos 2023-04-24 23:40:34 +08:00
parent e087be887b
commit fb997bc6b3
2 changed files with 19 additions and 10 deletions

View File

@ -74,7 +74,7 @@ const CurrentFields = (props) => {
const { resource, targetKey } = props.collectionResource || {}; const { resource, targetKey } = props.collectionResource || {};
const { [targetKey]: filterByTk, titleField } = useRecord(); const { [targetKey]: filterByTk, titleField } = useRecord();
const [loadingRecord, setLoadingRecord] = React.useState<any>(null); const [loadingRecord, setLoadingRecord] = React.useState<any>(null);
const { updateCollection } = useCollectionManager(); const { updateCollection, refreshCM } = useCollectionManager();
const columns: TableColumnProps<any>[] = [ const columns: TableColumnProps<any>[] = [
{ {
@ -100,11 +100,12 @@ const CurrentFields = (props) => {
resource resource
.update({ filterByTk, values: { titleField: checked ? record.name : 'id' } }) .update({ filterByTk, values: { titleField: checked ? record.name : 'id' } })
.then(async () => { .then(async () => {
const data = await props.refreshAsync(); await props.refreshAsync();
if (data?.data) { // if (data?.data) {
updateCollection(data.data); // // updateCollection(data.data);
} // }
setLoadingRecord(null); setLoadingRecord(null);
refreshCM();
}) })
.catch((err) => { .catch((err) => {
setLoadingRecord(null); setLoadingRecord(null);
@ -180,7 +181,7 @@ const InheritFields = (props) => {
const { [targetKey]: filterByTk, titleField, name } = useRecord(); const { [targetKey]: filterByTk, titleField, name } = useRecord();
const [loadingRecord, setLoadingRecord] = React.useState(null); const [loadingRecord, setLoadingRecord] = React.useState(null);
const { t } = useTranslation(); const { t } = useTranslation();
const { updateCollection } = useCollectionManager(); const { updateCollection, refreshCM } = useCollectionManager();
const columns: TableColumnProps<any>[] = [ const columns: TableColumnProps<any>[] = [
{ {
@ -206,11 +207,12 @@ const InheritFields = (props) => {
resource resource
.update({ filterByTk, values: { titleField: checked ? record.name : 'id' } }) .update({ filterByTk, values: { titleField: checked ? record.name : 'id' } })
.then(async () => { .then(async () => {
const data = await props.refreshAsync(); await props.refreshAsync();
if (data?.data) { // if (data?.data) {
updateCollection(data.data); // updateCollection(data.data);
} // }
setLoadingRecord(null); setLoadingRecord(null);
refreshCM();
}) })
.catch((err) => { .catch((err) => {
setLoadingRecord(null); setLoadingRecord(null);

View File

@ -20905,6 +20905,13 @@ react-drag-listview@^0.1.9:
babel-runtime "^6.26.0" babel-runtime "^6.26.0"
prop-types "^15.5.8" prop-types "^15.5.8"
react-error-boundary@^3.1.4:
version "3.1.4"
resolved "https://registry.npmjs.org/react-error-boundary/-/react-error-boundary-3.1.4.tgz#255db92b23197108757a888b01e5b729919abde0"
integrity sha512-uM9uPzZJTF6wRQORmSrvOIgt4lJ9MC1sNgEOj2XGsDTRE4kmpWxg7ENK9EWNKJRMAOY9z0MuF4yIfl6gp4sotA==
dependencies:
"@babel/runtime" "^7.12.5"
react-error-boundary@^4.0.3: react-error-boundary@^4.0.3:
version "4.0.3" version "4.0.3"
resolved "https://registry.npmmirror.com/react-error-boundary/-/react-error-boundary-4.0.3.tgz#f811497c06d53ea1206817ee82c6e5c6a27becd9" resolved "https://registry.npmmirror.com/react-error-boundary/-/react-error-boundary-4.0.3.tgz#f811497c06d53ea1206817ee82c6e5c6a27becd9"