From 5d1a60b3df65b801de504c3d7b08d6a1fc9ef03b Mon Sep 17 00:00:00 2001 From: Tyler Schicke Date: Wed, 1 May 2019 02:22:00 -0400 Subject: Added collaboration functionality --- src/client/DocServer.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/client/DocServer.ts') diff --git a/src/client/DocServer.ts b/src/client/DocServer.ts index 31a50adbd..1d73abd1f 100644 --- a/src/client/DocServer.ts +++ b/src/client/DocServer.ts @@ -81,6 +81,9 @@ export namespace DocServer { } export function UpdateField(id: string, diff: any) { + if (id === updatingId) { + return; + } Utils.Emit(_socket, MessageStore.UpdateField, { id, diff }); } @@ -91,6 +94,7 @@ export namespace DocServer { Utils.Emit(_socket, MessageStore.CreateField, initialState); } + let updatingId: string | undefined; function respondToUpdate(diff: any) { const id = diff.id; if (id === undefined) { @@ -103,7 +107,9 @@ export namespace DocServer { } const handler = f[HandleUpdate]; if (handler) { - handler(diff); + updatingId = id; + handler.call(f, diff.diff); + updatingId = undefined; } }; if (field instanceof Promise) { -- cgit v1.2.3-70-g09d2