aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/Server.ts18
-rw-r--r--src/client/documents/Documents.ts4
-rw-r--r--src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx2
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"}`}