aboutsummaryrefslogtreecommitdiff
path: root/src/client/DocServer.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/DocServer.ts')
-rw-r--r--src/client/DocServer.ts11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/client/DocServer.ts b/src/client/DocServer.ts
index c644308b7..e3c4609c0 100644
--- a/src/client/DocServer.ts
+++ b/src/client/DocServer.ts
@@ -277,11 +277,11 @@ export namespace DocServer {
const fetchDocPromises: Map<string, Promise<Opt<Doc>>> = new Map(); // { p: Promise<Doc>; id: string }[] = []; // promises to fetch the value for a requested Doc
// Determine which requested documents need to be fetched
- // eslint-disable-next-line no-restricted-syntax
for (const id of ids.filter(filterid => filterid)) {
if (_cache[id] === undefined) {
// EMPTY CACHE - make promise that we resolve after all batch-requested Docs have been fetched and deserialized and we know we have this Doc
- const fetchPromise = new Promise<Opt<Doc>>(res =>
+ // eslint-disable-next-line no-loop-func
+ _cache[id] = new Promise<Opt<Doc>>(res =>
allCachesFilledPromise.then(() => {
// if all Docs have been cached, then we can be sure the fetched Doc has been found and cached. So return it to anyone who had been awaiting it.
const cache = _cache[id];
@@ -289,8 +289,7 @@ export namespace DocServer {
res(cache instanceof Doc ? cache : undefined);
})
);
- // eslint-disable-next-line no-loop-func
- fetchDocPromises.set(id, (_cache[id] = fetchPromise));
+ fetchDocPromises.set(id, _cache[id]);
uncachedRequestedIds.push(id); // add to list of Doc requests from server
}
// else CACHED => do nothing, Doc or promise of Doc is already in cache
@@ -307,11 +306,11 @@ export namespace DocServer {
let processed = 0;
console.log('Retrieved ' + serializedFields.length + ' fields');
// After the serialized Docs have been received, deserialize them into objects.
- // eslint-disable-next-line no-restricted-syntax
for (const field of serializedFields) {
- // eslint-disable-next-line no-await-in-loop
++processed % 150 === 0 &&
+ // eslint-disable-next-line no-await-in-loop
(await new Promise<number>(
+ // eslint-disable-next-line no-loop-func
res =>
setTimeout(action(() => res(FieldLoader.ServerLoadStatus.retrieved = processed))) // prettier-ignore
)); // force loading to yield to splash screen rendering to update progress