Fixed bug with corrupted map state on token deletion
This commit is contained in:
+10
-1
@@ -1,8 +1,17 @@
|
||||
import { applyChange, revertChange, diff as deepDiff } from "deep-diff";
|
||||
import get from "lodash.get";
|
||||
|
||||
export function applyChanges(target, changes) {
|
||||
for (let change of changes) {
|
||||
applyChange(target, true, change);
|
||||
if (change.path && (change.kind === "E" || change.kind === "A")) {
|
||||
// If editing an object or array ensure that the value exists
|
||||
const valid = get(target, change.path) !== undefined;
|
||||
if (valid) {
|
||||
applyChange(target, true, change);
|
||||
}
|
||||
} else {
|
||||
applyChange(target, true, change);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user