aboutsummaryrefslogtreecommitdiff
path: root/src/new_fields/Doc.ts
diff options
context:
space:
mode:
authorTyler Schicke <tyler_schicke@brown.edu>2019-05-01 02:22:00 -0400
committerTyler Schicke <tyler_schicke@brown.edu>2019-05-01 02:22:00 -0400
commit5d1a60b3df65b801de504c3d7b08d6a1fc9ef03b (patch)
tree012b04720e546af3196ccdb984bef1147ba34183 /src/new_fields/Doc.ts
parent976a4d835840e08f3dfd114757d7cddda5614b83 (diff)
Added collaboration functionality
Diffstat (limited to 'src/new_fields/Doc.ts')
-rw-r--r--src/new_fields/Doc.ts17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts
index b2979af11..6162b3c76 100644
--- a/src/new_fields/Doc.ts
+++ b/src/new_fields/Doc.ts
@@ -8,7 +8,7 @@ import { UndoManager, undoBatch } from "../client/util/UndoManager";
import { listSpec } from "./Schema";
import { List } from "./List";
import { ObjectField, Parent, OnUpdate } from "./ObjectField";
-import { RefField, FieldId, Id } from "./RefField";
+import { RefField, FieldId, Id, HandleUpdate } from "./RefField";
import { Docs } from "../client/documents/Documents";
export function IsField(field: any): field is Field {
@@ -86,6 +86,21 @@ export class Doc extends RefField {
private [SelfProxy]: any;
public [WidthSym] = () => NumCast(this.__fields.width); // bcz: is this the right way to access width/height? it didn't work with : this.width
public [HeightSym] = () => NumCast(this.__fields.height);
+
+ public [HandleUpdate](diff: any) {
+ console.log(diff);
+ const set = diff.$set;
+ if (set) {
+ for (const key in set) {
+ if (!key.startsWith("fields.")) {
+ continue;
+ }
+ const value = SerializationHelper.Deserialize(set[key]);
+ const fKey = key.substring(7);
+ this[fKey] = value;
+ }
+ }
+ }
}
export namespace Doc {