diff options
author | Nathan-SR <144961007+Nathan-SR@users.noreply.github.com> | 2024-05-05 18:28:35 -0400 |
---|---|---|
committer | Nathan-SR <144961007+Nathan-SR@users.noreply.github.com> | 2024-05-05 18:28:35 -0400 |
commit | 86f55d8aa12268fe847eaa344e8efbab5d293f34 (patch) | |
tree | 6bbc5c6fb6825ef969ed0342e4851667b81577cc /src/fields/Proxy.ts | |
parent | 2a9db784a6e3492a8f7d8ce9a745b4f1a0494241 (diff) | |
parent | 139600ab7e8a82a31744cd3798247236cd5616fc (diff) |
Merge branch 'nathan-starter' of https://github.com/brown-dash/Dash-Web into nathan-starter
Diffstat (limited to 'src/fields/Proxy.ts')
-rw-r--r-- | src/fields/Proxy.ts | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/fields/Proxy.ts b/src/fields/Proxy.ts index 820d9b6ff..4f8058ce4 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,10 +39,10 @@ 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'; @@ -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; } |