aboutsummaryrefslogtreecommitdiff
path: root/src/fields
diff options
context:
space:
mode:
authorGeireann Lindfield Roberts <60007097+geireann@users.noreply.github.com>2020-10-22 19:23:07 +0800
committerGeireann Lindfield Roberts <60007097+geireann@users.noreply.github.com>2020-10-22 19:23:07 +0800
commit9e292278980606062db08df91706ca4d5b78abde (patch)
treefec75dbdf36098b537522b2f4ed67607cd920309 /src/fields
parent35e33edd138009af5a9f3e22493e67bccccb251e (diff)
parent93ff528ebce3ac970fa7a5d299fd3bfbc2ee021e (diff)
Merge branch 'master' into presentation_v1
Diffstat (limited to 'src/fields')
-rw-r--r--src/fields/util.ts16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/fields/util.ts b/src/fields/util.ts
index a374c7f54..af743d9f2 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.value()));
+ receiver[prop].push(...diff.items.map((item: any) => item.hasOwnProperty("value") ? item.value() : item));
lastValue = ObjectField.MakeCopy(receiver[prop]);
},
undo: action(() => {
- diff.items.forEach((doc: any) => {
- const ind = receiver[prop].indexOf(doc.value());
+ diff.items.forEach((item: any) => {
+ const ind = receiver[prop].indexOf(item.hasOwnProperty("value") ? item.value() : item);
ind !== -1 && receiver[prop].splice(ind, 1);
});
lastValue = ObjectField.MakeCopy(receiver[prop]);
@@ -393,16 +393,16 @@ export function updateFunction(target: any, prop: any, value: any, receiver: any
diff?.op === "$remFromSet" ?
{
redo: action(() => {
- diff.items.forEach((doc: any) => {
- const ind = receiver[prop].indexOf(doc.value());
+ diff.items.forEach((item: any) => {
+ const ind = receiver[prop].indexOf(item.hasOwnProperty("value") ? item.value() : item);
ind !== -1 && receiver[prop].splice(ind, 1);
});
lastValue = ObjectField.MakeCopy(receiver[prop]);
}),
undo: () => {
- diff.items.map((item: any) => {
- const ind = (prevValue as List<any>).indexOf(diff.items[0].value());
- ind !== -1 && receiver[prop].indexOf(diff.items[0].value()) === -1 && receiver[prop].splice(ind, 0, item);
+ 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);
});
lastValue = ObjectField.MakeCopy(receiver[prop]);
}