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.ts12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/client/DocServer.ts b/src/client/DocServer.ts
index ddc4318aa..0da4dc08d 100644
--- a/src/client/DocServer.ts
+++ b/src/client/DocServer.ts
@@ -2,6 +2,7 @@ import { runInAction } from 'mobx';
import * as rp from 'request-promise';
import * as io from 'socket.io-client';
import { Doc, Opt, UpdatingFromServer } from '../fields/Doc';
+import { FieldLoader } from '../fields/FieldLoader';
import { HandleUpdate, Id, Parent } from '../fields/FieldSymbols';
import { ObjectField } from '../fields/ObjectField';
import { RefField } from '../fields/RefField';
@@ -352,23 +353,30 @@ export namespace DocServer {
// fields for the given ids. This returns a promise, which, when resolved, indicates that all the JSON serialized versions of
// the fields have been returned from the server
console.log('Requesting ' + requestedIds.length + ' fields');
+ FieldLoader.active && runInAction(() => (FieldLoader.ServerLoadStatus.requested = requestedIds.length));
const getSerializedFields: Promise<any> = Utils.EmitCallback(_socket, MessageStore.GetRefFields, requestedIds);
// 3) when the serialized RefFields have been received, go head and begin deserializing them into objects.
// Here, once deserialized, we also invoke .proto to 'load' the documents' prototypes, which ensures that all
// future .proto calls on the Doc won't have to go farther than the cache to get their actual value.
+ let retrieved = 0;
const fields: { [id: string]: RefField } = {};
await getSerializedFields.then(async fieldvals => {
console.log('deserializing ' + fieldvals.length + ' fields');
const proms: Promise<void>[] = [];
- runInAction(() => {
+ await runInAction(async () => {
for (const field of fieldvals) {
const cached = _cache[field.id];
if (!cached) {
+ retrieved++;
+ if (FieldLoader.active && retrieved % 150 === 0) {
+ runInAction(() => (FieldLoader.ServerLoadStatus.retrieved = retrieved));
+ await new Promise(res => setTimeout(res));
+ }
console.log('<');
// deserialize
- const prom = SerializationHelper.Deserialize(field).then(deserialized => {
+ const prom = SerializationHelper.Deserialize(field).then(async deserialized => {
fields[field.id] = deserialized;
//overwrite or delete any promises (that we inserted as flags