aboutsummaryrefslogtreecommitdiff
path: root/src/new_fields/Doc.ts
diff options
context:
space:
mode:
authorSam Wilkins <samwilkins333@gmail.com>2019-07-25 13:01:30 -0400
committerSam Wilkins <samwilkins333@gmail.com>2019-07-25 13:01:30 -0400
commit93515e3f152ad91c009a07bc316af9bb7676dd7d (patch)
tree66e94f18226ae2adeda07ff3347c59429de6400e /src/new_fields/Doc.ts
parent6c111fdc538775f9f7b04f91d0b5701fd2a1aaca (diff)
parent18a0850353b0fc55cbf7ae1d4e2763919fc78bca (diff)
Merge branch 'master' of https://github.com/browngraphicslab/Dash-Web
Diffstat (limited to 'src/new_fields/Doc.ts')
-rw-r--r--src/new_fields/Doc.ts11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts
index 64b4acb7b..0a5bdc4b7 100644
--- a/src/new_fields/Doc.ts
+++ b/src/new_fields/Doc.ts
@@ -75,8 +75,10 @@ function fetchProto(doc: Doc) {
}
}
+let updatingFromServer = false;
+
@scriptingGlobal
-@Deserializable("doc", fetchProto).withFields(["id"])
+@Deserializable("Doc", fetchProto).withFields(["id"])
export class Doc extends RefField {
constructor(id?: FieldId, forceSave?: boolean) {
super(id);
@@ -129,6 +131,9 @@ export class Doc extends RefField {
private ___fields: any = {};
private [Update] = (diff: any) => {
+ if (updatingFromServer) {
+ return;
+ }
DocServer.UpdateField(this[Id], diff);
}
@@ -150,7 +155,9 @@ export class Doc extends RefField {
}
const value = await SerializationHelper.Deserialize(set[key]);
const fKey = key.substring(7);
+ updatingFromServer = true;
this[fKey] = value;
+ updatingFromServer = false;
}
}
const unset = diff.$unset;
@@ -160,7 +167,9 @@ export class Doc extends RefField {
continue;
}
const fKey = key.substring(7);
+ updatingFromServer = true;
delete this[fKey];
+ updatingFromServer = false;
}
}
}