aboutsummaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/client')
-rw-r--r--src/client/DocServer.ts11
-rw-r--r--src/client/views/nodes/imageEditor/ImageEditor.tsx4
2 files changed, 7 insertions, 8 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
diff --git a/src/client/views/nodes/imageEditor/ImageEditor.tsx b/src/client/views/nodes/imageEditor/ImageEditor.tsx
index 198b8e713..abe235ad5 100644
--- a/src/client/views/nodes/imageEditor/ImageEditor.tsx
+++ b/src/client/views/nodes/imageEditor/ImageEditor.tsx
@@ -286,8 +286,8 @@ const ImageEditor = ({ imageEditorOpen, imageEditorSource, imageRootDoc, addDoc
const maskBlob = await ImageUtility.canvasToBlob(canvasMask);
const imgBlob = await ImageUtility.canvasToBlob(canvasOriginalImg);
const res = await ImageUtility.getEdit(imgBlob, maskBlob, input || 'Fill in the image in the same style', 2);
- if ((res as any).status == 'error') {
- alert((res as any).message);
+ if (res.status == 'error') {
+ alert(res.message);
}
// create first image