diff --git a/packages/core/src/mods/flowChart/registerServerStorage.ts b/packages/core/src/mods/flowChart/registerServerStorage.ts index c303553..4c7390b 100644 --- a/packages/core/src/mods/flowChart/registerServerStorage.ts +++ b/packages/core/src/mods/flowChart/registerServerStorage.ts @@ -17,26 +17,28 @@ const validate = (type: string, data: any) => { } }; -const enqueue = (type: string, actionType: ActionType, data: any) => { - if (!validate(type, data)) { +const enqueue = (cellType: string, actionType: ActionType, data: any) => { + if (!validate(cellType, data)) { return; } - const foundIndex = memQueue.findIndex( - (item) => item.type === type && item.actionType === actionType - ); + const foundIndex = memQueue.findIndex((item) => ( + item.type === cellType && + item.actionType === actionType && + item.data.id === data.id + )); if (foundIndex > -1) { const deleted = memQueue.splice(foundIndex, 1)[0]; - data = merge(deleted, data); + merge(deleted.data, data); } - memQueue.push({ type, actionType, data }); + memQueue.push({ type: cellType, actionType, data }); }; -let modifyActionTimer = -1; -const save = (flowChart: Graph, type: string, actionType: ActionType, data: any) => { - enqueue(type, actionType, data); +let modifyActionTimer: number = -1; +const save = (flowChart: Graph, cellType: string, actionType: ActionType, data: any) => { + enqueue(cellType, actionType, data); clearTimeout(modifyActionTimer); - modifyActionTimer = setTimeout(() => { + modifyActionTimer = window.setTimeout(() => { const pushedActions = memQueue.slice(0); if (pushedActions.length > 0) { flowChart.trigger('graph:change:modify');