mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 10:26:45 +00:00
fix: drop repeated "Connect data blocks" (#1763)
This commit is contained in:
parent
03f845246e
commit
cba7de55d8
@ -5,6 +5,7 @@ import { SharedFilter, mergeFilter } from '../block-provider/SharedFilterProvide
|
|||||||
import { CollectionFieldOptions, useCollection } from '../collection-manager';
|
import { CollectionFieldOptions, useCollection } from '../collection-manager';
|
||||||
import { removeNullCondition } from '../schema-component';
|
import { removeNullCondition } from '../schema-component';
|
||||||
import { useAssociatedFields } from './utils';
|
import { useAssociatedFields } from './utils';
|
||||||
|
import { uniqBy } from 'lodash';
|
||||||
|
|
||||||
type Collection = ReturnType<typeof useCollection>;
|
type Collection = ReturnType<typeof useCollection>;
|
||||||
|
|
||||||
@ -133,8 +134,8 @@ export const useFilterBlock = () => {
|
|||||||
existingBlock.defaultFilter = block.defaultFilter;
|
existingBlock.defaultFilter = block.defaultFilter;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// 由于 setDataBlocks 是异步操作,所以上面的 existingBlock 在判断时有可能用的是旧的 dataBlocks,所以下面还需要根据 uid 进行去重操作
|
||||||
setDataBlocks((prev) => [...prev, block]);
|
setDataBlocks((prev) => uniqBy([...prev, block], 'uid'));
|
||||||
};
|
};
|
||||||
const getDataBlocks = () => dataBlocks;
|
const getDataBlocks = () => dataBlocks;
|
||||||
const removeDataBlock = (uid: string) => {
|
const removeDataBlock = (uid: string) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user