From 2213a73095271fecdb83d35d3cd1e53a3c1d75ed Mon Sep 17 00:00:00 2001 From: Tyler Schicke Date: Wed, 31 Jul 2019 04:00:02 -0400 Subject: Hopefully fixed deserialization bug --- src/client/DocServer.ts | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'src/client/DocServer.ts') diff --git a/src/client/DocServer.ts b/src/client/DocServer.ts index 258acd9cd..de9304858 100644 --- a/src/client/DocServer.ts +++ b/src/client/DocServer.ts @@ -124,16 +124,17 @@ export namespace DocServer { // future .proto calls on the Doc won't have to go farther than the cache to get their actual value. const deserializeField = getSerializedField.then(async fieldJson => { // deserialize - const field = await SerializationHelper.Deserialize(fieldJson); + const field = await SerializationHelper.Deserialize(fieldJson, val => { + if (val !== undefined) { + _cache[id] = field; + } else { + delete _cache[id]; + } + }); + return field; // either way, overwrite or delete any promises cached at this id (that we inserted as flags // to indicate that the field was in the process of being fetched). Now everything // should be an actual value within or entirely absent from the cache. - if (field !== undefined) { - _cache[id] = field; - } else { - delete _cache[id]; - } - return field; }); // here, indicate that the document associated with this id is currently // being retrieved and cached @@ -217,7 +218,13 @@ export namespace DocServer { for (const field of fields) { if (field !== undefined) { // deserialize - let deserialized = await SerializationHelper.Deserialize(field); + let deserialized = await SerializationHelper.Deserialize(field, val => { + if (val !== undefined) { + _cache[field.id] = field; + } else { + delete _cache[field.id]; + } + }); fieldMap[field.id] = deserialized; // adds to a list of promises that will be awaited asynchronously // protosToLoad.push(deserialized.proto); -- cgit v1.2.3-70-g09d2 From 99e572671de99fb1bf974210834803fa5399db49 Mon Sep 17 00:00:00 2001 From: Tyler Schicke Date: Wed, 31 Jul 2019 04:31:15 -0400 Subject: Third times the charm? --- src/client/DocServer.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/client/DocServer.ts') diff --git a/src/client/DocServer.ts b/src/client/DocServer.ts index de9304858..afd7878f2 100644 --- a/src/client/DocServer.ts +++ b/src/client/DocServer.ts @@ -215,21 +215,23 @@ export namespace DocServer { const deserializeFields = getSerializedFields.then(async fields => { const fieldMap: { [id: string]: RefField } = {}; // const protosToLoad: any = []; + const proms: Promise[] = []; for (const field of fields) { if (field !== undefined) { // deserialize - let deserialized = await SerializationHelper.Deserialize(field, val => { + let prom = SerializationHelper.Deserialize(field, val => { if (val !== undefined) { _cache[field.id] = field; } else { delete _cache[field.id]; } - }); - fieldMap[field.id] = deserialized; + }).then(deserialized => fieldMap[field.id] = deserialized); + proms.push(prom); // adds to a list of promises that will be awaited asynchronously // protosToLoad.push(deserialized.proto); } } + await Promise.all(proms); // this actually handles the loading of prototypes // await Promise.all(protosToLoad); return fieldMap; -- cgit v1.2.3-70-g09d2 From f2fab81888cfd9d961b234d6ee35eb4f095c7ede Mon Sep 17 00:00:00 2001 From: bob Date: Wed, 31 Jul 2019 08:09:45 -0400 Subject: fix for library doc not stretching? --- src/client/DocServer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/client/DocServer.ts') diff --git a/src/client/DocServer.ts b/src/client/DocServer.ts index afd7878f2..fc39fa364 100644 --- a/src/client/DocServer.ts +++ b/src/client/DocServer.ts @@ -126,7 +126,7 @@ export namespace DocServer { // deserialize const field = await SerializationHelper.Deserialize(fieldJson, val => { if (val !== undefined) { - _cache[id] = field; + _cache[id] = val; } else { delete _cache[id]; } -- cgit v1.2.3-70-g09d2