Browse Source

fix: merging data error when removing/moving multiple nodes/edges

master
smallstonesk 4 years ago
parent
commit
1f09df49b2
  1. 24
      packages/core/src/mods/flowChart/registerServerStorage.ts

24
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');

Loading…
Cancel
Save