diff options
author | Tyler Schicke <tyler_schicke@brown.edu> | 2019-05-02 03:29:02 -0400 |
---|---|---|
committer | Tyler Schicke <tyler_schicke@brown.edu> | 2019-05-02 03:29:02 -0400 |
commit | ad9111cdef77795b2eca57b62d203c21cfef3357 (patch) | |
tree | 2e5f7714118ad1d506bf09e7d723a6d311c2d38f /src/client/DocServer.ts | |
parent | 2c1cf7fd3e1d71813f23f60acb9264a4f8bf33b0 (diff) |
Various fixes:
Added a couple missing prototype ids that weren't fetched
Fixed DocServer bug that was affecting docking view
Diffstat (limited to 'src/client/DocServer.ts')
-rw-r--r-- | src/client/DocServer.ts | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/client/DocServer.ts b/src/client/DocServer.ts index 8e9f7865b..a288d394a 100644 --- a/src/client/DocServer.ts +++ b/src/client/DocServer.ts @@ -3,7 +3,7 @@ import { MessageStore } from "./../server/Message"; import { Opt } from '../new_fields/Doc'; import { Utils } from '../Utils'; import { SerializationHelper } from './util/SerializationHelper'; -import { RefField, HandleUpdate } from '../new_fields/RefField'; +import { RefField, HandleUpdate, Id } from '../new_fields/RefField'; export namespace DocServer { const _cache: { [id: string]: RefField | Promise<Opt<RefField>> } = {}; @@ -23,6 +23,9 @@ export namespace DocServer { if (cached === undefined) { const prom = Utils.EmitCallback(_socket, MessageStore.GetRefField, id).then(fieldJson => { const field = SerializationHelper.Deserialize(fieldJson); + if (_cache[id] !== undefined && !(_cache[id] instanceof Promise)) { + id; + } if (field !== undefined) { _cache[id] = field; } else { @@ -87,10 +90,9 @@ export namespace DocServer { Utils.Emit(_socket, MessageStore.UpdateField, { id, diff }); } - export function CreateField(initialState: any) { - if (!("id" in initialState)) { - throw new Error("Can't create a field on the server without an id"); - } + export function CreateField(field: RefField) { + _cache[field[Id]] = field; + const initialState = SerializationHelper.Serialize(field); Utils.Emit(_socket, MessageStore.CreateField, initialState); } |