diff options
author | bob <bcz@cs.brown.edu> | 2019-02-07 16:27:51 -0500 |
---|---|---|
committer | bob <bcz@cs.brown.edu> | 2019-02-07 16:27:51 -0500 |
commit | 8d264be35a511204449c22d0a4b1754e241a3421 (patch) | |
tree | 116f149b2019873f3c3a68b9819e337f7ec30941 /src | |
parent | f2f9261c6469ed330ff9395fb97e15ca53c891f2 (diff) |
bug fix
Diffstat (limited to 'src')
-rw-r--r-- | src/Server.tsx | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/Server.tsx b/src/Server.tsx index 7eeec25e1..745634ca5 100644 --- a/src/Server.tsx +++ b/src/Server.tsx @@ -11,14 +11,14 @@ export class Server { // Call this is from within a reaction and test whether the return value is FieldWaiting. // 'hackTimeout' is here temporarily for simplicity when debugging things. public static GetField(fieldid: FIELD_ID, callback: (field: Field) => void = (f) => { }, hackTimeout: number = -1) { - if (!this.ClientFieldsCached.has(fieldid)) { + if (!this.ClientFieldsCached.get(fieldid)) { this.ClientFieldsCached.set(fieldid, FieldWaiting); //simulating a server call with a registered callback action SocketStub.SEND_FIELD_REQUEST(fieldid, - action((field: Field) => { - Server.cacheField(field); - callback(field); - }), hackTimeout); + action((field: Field) => callback(Server.cacheField(field))), + hackTimeout); + } else if (this.ClientFieldsCached.get(fieldid) != FieldWaiting) { + callback(this.ClientFieldsCached.get(fieldid) as Field); } return this.ClientFieldsCached.get(fieldid); } @@ -27,16 +27,12 @@ export class Server { public static GetDocumentField(doc: Document, key: Key) { var hackTimeout: number = key == KeyStore.Data ? (this.times++ == 0 ? 5000 : 1000) : key == KeyStore.X ? 2500 : 500; - var field = this.GetField(doc._proxies.get(key), + return this.GetField(doc._proxies.get(key), action((fieldfromserver: Field) => { doc._proxies.delete(key); - doc.fields.set(key, this.cacheField(fieldfromserver)); + doc.fields.set(key, fieldfromserver); }) , hackTimeout); - if (field != FieldWaiting) { - doc._proxies.delete(key); // perhaps another document inquired the same field - } - return field; } public static AddDocument(document: Document) { |