Fix: Fixed the issue that the page crashed when the node ID was the same as the combo ID #4180 (#4191)

### What problem does this PR solve?

Fix: Fixed the issue that the page crashed when the node ID was the same
as the combo ID #4180

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
balibabu
2024-12-23 18:13:56 +08:00
committed by GitHub
parent 8d73cf6f02
commit cf62230548
8 changed files with 11 additions and 408 deletions

View File

@ -1,4 +1,5 @@
import { isEmpty } from 'lodash';
import { v4 as uuid } from 'uuid';
class KeyGenerator {
idx = 0;
@ -64,16 +65,22 @@ export const isDataExist = (data: any) => {
export const buildNodesAndCombos = (nodes: any[]) => {
const combos: any[] = [];
const nextNodes = nodes.map((x) => {
nodes.forEach((x) => {
const combo = Array.isArray(x?.communities) ? x.communities[0] : undefined;
if (combo && combos.every((y) => y.id !== combo)) {
if (combo && combos.every((y) => y.data.label !== combo)) {
combos.push({
id: combo,
id: uuid(),
data: {
label: combo,
},
});
}
});
const nextNodes = nodes.map((x) => {
return {
...x,
combo,
combo: combos.find((y) => y.data.label === x.id)?.id,
};
});