aboutsummaryrefslogtreecommitdiff
path: root/src/fields/Proxy.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/fields/Proxy.ts')
-rw-r--r--src/fields/Proxy.ts19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/fields/Proxy.ts b/src/fields/Proxy.ts
index 820d9b6ff..83b5672b3 100644
--- a/src/fields/Proxy.ts
+++ b/src/fields/Proxy.ts
@@ -21,7 +21,7 @@ export class ProxyField<T extends RefField> extends ObjectField {
constructor(value?: T | string) {
super();
if (typeof value === 'string') {
- //this.cache = DocServer.GetCachedRefField(value) as any;
+ // this.cache = DocServer.GetCachedRefField(value) as any;
this.fieldId = value;
} else if (value) {
this.cache = { field: value, p: undefined };
@@ -29,7 +29,7 @@ export class ProxyField<T extends RefField> extends ObjectField {
}
}
- [ToValue](doc: any) {
+ [ToValue](/* doc: any */) {
return ProxyField.toValue(this);
}
@@ -39,13 +39,13 @@ export class ProxyField<T extends RefField> extends ObjectField {
}
[ToJavascriptString]() {
- return Field.toScriptString(this[ToValue](undefined)?.value);
+ return Field.toScriptString(this[ToValue]()?.value);
}
[ToScriptString]() {
- return Field.toScriptString(this[ToValue](undefined)?.value); // not sure this is quite right since it doesn't recreate a proxy field, but better than 'invalid' ?
+ return Field.toScriptString(this[ToValue]()?.value); // not sure this is quite right since it doesn't recreate a proxy field, but better than 'invalid' ?
}
[ToString]() {
- return 'ProxyField';
+ return Field.toString(this[ToValue]()?.value);
}
@serializable(primitive())
@@ -59,7 +59,9 @@ export class ProxyField<T extends RefField> extends ObjectField {
return this._cache;
}
private set cache(val: { field: T | undefined; p: FieldWaiting<T> | undefined }) {
- runInAction(() => (this._cache = { ...val }));
+ runInAction(() => {
+ this._cache = { ...val };
+ });
}
private failed = false;
@@ -78,7 +80,7 @@ export class ProxyField<T extends RefField> extends ObjectField {
return this.cache.field ?? this.cache.p;
}
@computed get needsRequesting(): boolean {
- return !this.cache.field && !this.failed && !this._cache.p && !DocServer.GetCachedRefField(this.fieldId) ? true : false;
+ return !!(!this.cache.field && !this.failed && !this._cache.p && !DocServer.GetCachedRefField(this.fieldId));
}
setExternalValuePromise(externalValuePromise: Promise<any>) {
@@ -92,6 +94,7 @@ export class ProxyField<T extends RefField> extends ObjectField {
}
}
+// eslint-disable-next-line no-redeclare
export namespace ProxyField {
let useProxy = true;
export function DisableProxyFields() {
@@ -115,9 +118,11 @@ export namespace ProxyField {
if (useProxy) {
return { value: value.value };
}
+ return undefined;
}
}
+// eslint-disable-next-line no-use-before-define
function prefetchValue(proxy: PrefetchProxy<RefField>) {
return proxy.value as any;
}