diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/client/DocServer.ts | 13 | ||||
-rw-r--r-- | src/new_fields/util.ts | 2 |
2 files changed, 10 insertions, 5 deletions
diff --git a/src/client/DocServer.ts b/src/client/DocServer.ts index a288d394a..e2f9b3601 100644 --- a/src/client/DocServer.ts +++ b/src/client/DocServer.ts @@ -21,12 +21,10 @@ export namespace DocServer { export async function GetRefField(id: string): Promise<Opt<RefField>> { let cached = _cache[id]; if (cached === undefined) { - const prom = Utils.EmitCallback(_socket, MessageStore.GetRefField, id).then(fieldJson => { + const prom = Utils.EmitCallback(_socket, MessageStore.GetRefField, id).then(async fieldJson => { const field = SerializationHelper.Deserialize(fieldJson); - if (_cache[id] !== undefined && !(_cache[id] instanceof Promise)) { - id; - } if (field !== undefined) { + await field.proto; _cache[id] = field; } else { delete _cache[id]; @@ -65,6 +63,7 @@ export namespace DocServer { fieldMap[field.id] = SerializationHelper.Deserialize(field); } } + return fieldMap; }); requestedIds.forEach(id => _cache[id] = prom.then(fields => fields[id])); @@ -78,6 +77,12 @@ export namespace DocServer { } map[id] = field; }); + await Promise.all(requestedIds.map(async id => { + const field = fields[id]; + if (field) { + await (field as any).proto; + } + })); const otherFields = await Promise.all(promises); waitingIds.forEach((id, index) => map[id] = otherFields[index]); return map; diff --git a/src/new_fields/util.ts b/src/new_fields/util.ts index 3a16a6b42..d94994a07 100644 --- a/src/new_fields/util.ts +++ b/src/new_fields/util.ts @@ -73,7 +73,7 @@ export function getField(target: any, prop: string | number, ignoreProto: boolea if (field instanceof ProxyField) { return field.value(callback); } - if (field === undefined && !ignoreProto) { + if (field === undefined && !ignoreProto && prop !== "proto") { const proto = getField(target, "proto", true); if (proto instanceof Doc) { return getProtoField(proto, prop, callback); |