refactor(core): add warning if trying to duplicate an element
Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
@@ -114,9 +114,13 @@ export const applyChanges = <
|
||||
| NodeRemoveChange
|
||||
| EdgeRemoveChange
|
||||
)[]
|
||||
|
||||
addRemoveChanges.forEach((change) => {
|
||||
if (change.type === 'add') {
|
||||
elements.push(<T>change.item)
|
||||
const index = elements.findIndex((el) => el.id === change.item.id)
|
||||
|
||||
if (index === -1) elements.push(<T>change.item)
|
||||
else warn(`${isNode(change.item) ? `Node` : `Edge`} with id ${change.item.id} already exists`)
|
||||
} else if (change.type === 'remove') {
|
||||
const index = elements.findIndex((el) => el.id === change.id)
|
||||
if (index !== -1) elements.splice(index, 1)
|
||||
|
||||
Reference in New Issue
Block a user