aboutsummaryrefslogtreecommitdiff
path: root/src/client/DocServer.ts
diff options
context:
space:
mode:
authorTyler Schicke <tschicke@gmail.com>2019-07-31 04:00:02 -0400
committerTyler Schicke <tschicke@gmail.com>2019-07-31 04:00:02 -0400
commit2213a73095271fecdb83d35d3cd1e53a3c1d75ed (patch)
tree3193c396ec8ff9c8be57db2fea421556a9d188a2 /src/client/DocServer.ts
parentb6fa309cea934d250fe992e70e1e268f344659b5 (diff)
Hopefully fixed deserialization bug
Diffstat (limited to 'src/client/DocServer.ts')
-rw-r--r--src/client/DocServer.ts23
1 files changed, 15 insertions, 8 deletions
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);