diff options
| author | Bob Zeleznik <zzzman@gmail.com> | 2020-05-07 01:35:11 -0400 |
|---|---|---|
| committer | Bob Zeleznik <zzzman@gmail.com> | 2020-05-07 01:35:11 -0400 |
| commit | 51a1f88b4e975946eb5ac8cef75a122e197cd872 (patch) | |
| tree | 9d56101ca7caf1f3625843d380f4493a16cde1bf /src/new_fields/Proxy.ts | |
| parent | 7e2b162446a7f384ef2781fd786a97c21d1a172b (diff) | |
added batch requesting of list items. fixed some performance issues with tree views.
Diffstat (limited to 'src/new_fields/Proxy.ts')
| -rw-r--r-- | src/new_fields/Proxy.ts | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/new_fields/Proxy.ts b/src/new_fields/Proxy.ts index d50c0f14e..555faaad0 100644 --- a/src/new_fields/Proxy.ts +++ b/src/new_fields/Proxy.ts @@ -1,7 +1,7 @@ import { Deserializable } from "../client/util/SerializationHelper"; import { FieldWaiting } from "./Doc"; import { primitive, serializable } from "serializr"; -import { observable, action } from "mobx"; +import { observable, action, runInAction } from "mobx"; import { DocServer } from "../client/DocServer"; import { RefField } from "./RefField"; import { ObjectField } from "./ObjectField"; @@ -61,6 +61,11 @@ export class ProxyField<T extends RefField> extends ObjectField { return undefined; } if (!this.promise) { + const cached = DocServer.GetCachedRefField(this.fieldId); + if (cached !== undefined) { + runInAction(() => this.cache = cached as any); + return cached as any; + } this.promise = DocServer.GetRefField(this.fieldId).then(action((field: any) => { this.promise = undefined; this.cache = field; @@ -70,6 +75,17 @@ export class ProxyField<T extends RefField> extends ObjectField { } return this.promise as any; } + promisedValue(): string { return !this.cache && !this.failed && !this.promise ? this.fieldId : ""; } + setPromise(promise: any) { + this.promise = promise; + } + @action + setValue(field: any) { + this.promise = undefined; + this.cache = field; + if (field === undefined) this.failed = true; + return field; + } } export namespace ProxyField { |
