diff options
author | bobzel <zzzman@gmail.com> | 2020-10-22 10:45:12 -0400 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2020-10-22 10:45:12 -0400 |
commit | f215eaa1c065585f375836a92a3ebf50d74a8bb3 (patch) | |
tree | 13c2d68cf88f1894e7802d73279a8ea580535fc4 /src/fields/util.ts | |
parent | 426094fa4dfbdab19b2cb99daf90438e884094b1 (diff) |
fixed undo
Diffstat (limited to 'src/fields/util.ts')
-rw-r--r-- | src/fields/util.ts | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/fields/util.ts b/src/fields/util.ts index af743d9f2..ecb3fb343 100644 --- a/src/fields/util.ts +++ b/src/fields/util.ts @@ -379,12 +379,12 @@ export function updateFunction(target: any, prop: any, value: any, receiver: any diff?.op === "$addToSet" ? { redo: () => { - receiver[prop].push(...diff.items.map((item: any) => item.hasOwnProperty("value") ? item.value() : item)); + receiver[prop].push(...diff.items.map((item: any) => item.value ? item.value() : item)); lastValue = ObjectField.MakeCopy(receiver[prop]); }, undo: action(() => { diff.items.forEach((item: any) => { - const ind = receiver[prop].indexOf(item.hasOwnProperty("value") ? item.value() : item); + const ind = receiver[prop].indexOf(item.value ? item.value() : item); ind !== -1 && receiver[prop].splice(ind, 1); }); lastValue = ObjectField.MakeCopy(receiver[prop]); @@ -394,15 +394,15 @@ export function updateFunction(target: any, prop: any, value: any, receiver: any { redo: action(() => { diff.items.forEach((item: any) => { - const ind = receiver[prop].indexOf(item.hasOwnProperty("value") ? item.value() : item); + const ind = receiver[prop].indexOf(item.value ? item.value() : item); ind !== -1 && receiver[prop].splice(ind, 1); }); lastValue = ObjectField.MakeCopy(receiver[prop]); }), undo: () => { diff.items.forEach((item: any) => { - const ind = (prevValue as List<any>).indexOf(item.hasOwnProperty("value") ? item.value() : item); - ind !== -1 && receiver[prop].indexOf(item.hasOwnProperty("value") ? item.value() : item) === -1 && receiver[prop].splice(ind, 0, item); + const ind = (prevValue as List<any>).indexOf(item.value ? item.value() : item); + ind !== -1 && receiver[prop].indexOf(item.value ? item.value() : item) === -1 && receiver[prop].splice(ind, 0, item); }); lastValue = ObjectField.MakeCopy(receiver[prop]); } |