diff options
author | bob <bcz@cs.brown.edu> | 2019-04-10 15:18:12 -0400 |
---|---|---|
committer | bob <bcz@cs.brown.edu> | 2019-04-10 15:18:12 -0400 |
commit | 1c660a6e768cea8d5e162be8082659743792cc3d (patch) | |
tree | ea94bdf40585c3d1b14e998b03aed7322e8b07e4 /src | |
parent | d4326a225f3e801c98e4acdc6558af1c3fe6ae07 (diff) | |
parent | b03261853e191d4f70dd9d3fc70706f399533066 (diff) |
Merge branch 'master' of https://github.com/browngraphicslab/Dash-Web
Diffstat (limited to 'src')
-rw-r--r-- | src/client/Server.ts | 18 | ||||
-rw-r--r-- | src/client/documents/Documents.ts | 4 | ||||
-rw-r--r-- | src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx | 2 |
3 files changed, 12 insertions, 12 deletions
diff --git a/src/client/Server.ts b/src/client/Server.ts index 228d94a7b..3bbbebe72 100644 --- a/src/client/Server.ts +++ b/src/client/Server.ts @@ -59,14 +59,14 @@ export class Server { public static GetFields(fieldIds: FieldId[]): Promise<{ [id: string]: Field }>; public static GetFields(fieldIds: FieldId[], callback: (fields: FieldMap) => any): void; public static GetFields(fieldIds: FieldId[], callback?: (fields: FieldMap) => any): Promise<FieldMap> | void { - let fn = (cb: (fields: FieldMap) => void) => runInAction(() => { + let fn = action((cb: (fields: FieldMap) => void) => { let neededFieldIds: FieldId[] = []; let waitingFieldIds: FieldId[] = []; - let existingFields: { [id: string]: Field } = {}; + let existingFields: FieldMap = {}; for (let id of fieldIds) { let field = this.ClientFieldsCached.get(id); - if (!field) { + if (field === undefined) { neededFieldIds.push(id); this.ClientFieldsCached.set(id, FieldWaiting); } else if (field === FieldWaiting) { @@ -79,7 +79,7 @@ export class Server { for (let id of neededFieldIds) { let field = fields[id]; if (field) { - if (!(this.ClientFieldsCached.get(field.Id) instanceof Field)) { + if (this.ClientFieldsCached.get(field.Id) === FieldWaiting) { this.ClientFieldsCached.set(field.Id, field); } else { throw new Error("we shouldn't be trying to replace things that are already in the cache"); @@ -94,12 +94,12 @@ export class Server { } reaction(() => waitingFieldIds.map(id => this.ClientFieldsCached.get(id)), (cachedFields, reaction) => { - if (!cachedFields.some(field => !field)) { + if (!cachedFields.some(field => field === FieldWaiting)) { + const realFields = cachedFields as Opt<Field>[]; reaction.dispose(); - for (let field of cachedFields) { - let realField = field as Field; - existingFields[realField.Id] = realField; - } + waitingFieldIds.forEach((id, index) => { + existingFields[id] = realFields[index]; + }); cb({ ...fields, ...existingFields }); } }, { fireImmediately: true }); diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts index f8438e093..3c36fe500 100644 --- a/src/client/documents/Documents.ts +++ b/src/client/documents/Documents.ts @@ -208,7 +208,7 @@ export namespace Documents { } export async function DBDocument(url: string, options: DocumentOptions = {}) { let schemaName = options.title ? options.title : "-no schema-"; - let ctlog = await Gateway.Instance.GetSchema(url, schemaName) + let ctlog = await Gateway.Instance.GetSchema(url, schemaName); if (ctlog && ctlog.schemas) { let schema = ctlog.schemas[0]; let schemaDoc = Documents.TreeDocument([], { ...options, nativeWidth: undefined, nativeHeight: undefined, width: 150, height: 100, title: schema.displayName! }); @@ -228,7 +228,7 @@ export namespace Documents { })); }); return schemaDoc; - }; + } return Documents.TreeDocument([], { width: 50, height: 100, title: schemaName }); } export function WebDocument(url: string, options: DocumentOptions = {}) { diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx index 102455d27..db8c370df 100644 --- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx +++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx @@ -313,7 +313,7 @@ export class CollectionFreeFormView extends CollectionSubView { const pany: number = -this.props.Document.GetNumber(KeyStore.PanY, 0); return ( - <Measure onResize={(r: any) => runInAction(() => { this._pwidth = r.entry.width; this._pheight = r.entry.height })}> + <Measure onResize={(r: any) => runInAction(() => { this._pwidth = r.entry.width; this._pheight = r.entry.height; })}> {({ measureRef }) => ( <div className={`collectionfreeformview-measure`} ref={measureRef}> <div className={`collectionfreeformview${this.isAnnotationOverlay ? "-overlay" : "-container"}`} |