aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/Server.ts16
-rw-r--r--src/client/SocketStub.ts1
-rw-r--r--src/fields/Document.ts8
-rw-r--r--src/fields/ListField.ts4
4 files changed, 20 insertions, 9 deletions
diff --git a/src/client/Server.ts b/src/client/Server.ts
index e9edb7b9c..3047f64b3 100644
--- a/src/client/Server.ts
+++ b/src/client/Server.ts
@@ -26,14 +26,19 @@ export class Server {
// Retrieves the cached value of the field and sends a request to the server for the real value (if it's not cached).
// Call this is from within a reaction and test whether the return value is FieldWaiting.
// 'hackTimeout' is here temporarily for simplicity when debugging things.
- public static GetField(fieldid: FIELD_ID, callback: (field: Opt<Field>) => void = (f) => { }, hackTimeout: number = -1) {
+ public static GetField(fieldid: FIELD_ID, callback: (field: Opt<Field>) => void = (f) => { }, doc: Document, key: Key, hackTimeout: number = -1) {
if (!this.ClientFieldsCached.get(fieldid)) {
- // this.ClientFieldsCached.set(fieldid, FieldWaiting);
+ var ft = this.times++;
+ var title = (doc._proxies.has(KeyStore.Title.Id) ? "???" : doc.Title) + "(" + doc.Id + ")";
+ var mesg = "-----> field(" + ft + ") " + title + " " + key.Name;
+ console.log(mesg);
+ this.ClientFieldsCached.set(fieldid, FieldWaiting);
//simulating a server call with a registered callback action
SocketStub.SEND_FIELD_REQUEST(fieldid, (field) => {
if (field) {
this.Cache[field.Id] = field;
}
+ console.log(" <=== field(" + ft + ") " + title + " " + key.Name);
callback(field)
});
} else if (this.ClientFieldsCached.get(fieldid) != FieldWaiting) {
@@ -67,19 +72,19 @@ export class Server {
// console.log("how did you get a key that isnt a key wtf")
// }
// })
-
return this.GetField(doc._proxies.get(key.Id),
action((fieldfromserver: Opt<Field>) => {
if (fieldfromserver) {
doc.fields.set(key.Id, { key, field: fieldfromserver });
}
- }));
+ }), doc, key);
}
public static AddDocument(document: Document) {
SocketStub.SEND_ADD_DOCUMENT(document);
}
public static AddDocumentField(doc: Document, key: Key, value: Field) {
+ console.log("Add doc field " + doc.Title + " " + key.Name + " fid " + value.Id + " " + value);
SocketStub.SEND_ADD_DOCUMENT_FIELD(doc, key, value);
}
public static DeleteDocumentField(doc: Document, key: Key) {
@@ -93,7 +98,8 @@ export class Server {
// setTimeout(this.UpdateField, 1000, field)
}
this.lock = true
- // console.log("updating field " + field.Id)
+ var title = field instanceof Document ? (((field as Document)._proxies.has(KeyStore.Title.Id) ? "doc:" : (field as Document).Title) + "(" + (field as Document).Id + ")") : field.GetValue();
+ console.log("updating field " + title)
SocketStub.SEND_SET_FIELD(field, (args: any) => {
if (this.lock) {
this.lock = false
diff --git a/src/client/SocketStub.ts b/src/client/SocketStub.ts
index 7545a166c..36818b1eb 100644
--- a/src/client/SocketStub.ts
+++ b/src/client/SocketStub.ts
@@ -30,6 +30,7 @@ export class SocketStub {
// this.FieldStore.set(document.Id, new Document(document.Id));
// document.fields.forEach((f, key) => (this.FieldStore.get(document.Id) as Document)._proxies.set(key.Id, (f as Field).Id));
+ console.log("sending " + document.Title);
Utils.Emit(Server.Socket, MessageStore.AddDocument, new DocumentTransfer(document.ToJson()))
}
diff --git a/src/fields/Document.ts b/src/fields/Document.ts
index 4bab1299d..4b159b4eb 100644
--- a/src/fields/Document.ts
+++ b/src/fields/Document.ts
@@ -4,10 +4,8 @@ import { NumberField } from "./NumberField";
import { ObservableMap, computed, action, observable } from "mobx";
import { TextField } from "./TextField";
import { ListField } from "./ListField";
-import { findDOMNode } from "react-dom";
import { Server } from "../client/Server";
import { Types } from "../server/Message";
-import { ObjectID } from "bson";
export class Document extends Field {
public fields: ObservableMap<string, { key: Key, field: Opt<Field> }> = new ObservableMap();
@@ -17,6 +15,8 @@ export class Document extends Field {
super(id)
if (save) {
+ var title = (this._proxies.has(KeyStore.Title.Id) ? "???" : this.Title) + "(" + this.Id + ")";
+ console.log("Save " + title);
Server.UpdateField(this)
}
}
@@ -169,7 +169,9 @@ export class Document extends Field {
throw new Error("Method not implemented.");
}
GetValue() {
- throw new Error("Method not implemented.");
+ var title = (this._proxies.has(KeyStore.Title.Id) ? "???" : this.Title) + "(" + this.Id + ")";
+ return title;
+ //throw new Error("Method not implemented.");
}
Copy(): Field {
throw new Error("Method not implemented.");
diff --git a/src/fields/ListField.ts b/src/fields/ListField.ts
index 1585746df..d3d8fc71b 100644
--- a/src/fields/ListField.ts
+++ b/src/fields/ListField.ts
@@ -43,15 +43,17 @@ export class ListField<T extends Field> extends BasicField<T[]> {
}
init(callback: (field: Field) => any) {
+ console.log("requesting list fields " + this._proxies.length)
Server.GetFields(this._proxies, action((fields: { [index: string]: Field }) => {
if (!this.arraysEqual(this._proxies, this.Data.map(field => field.Id))) {
-
+ console.log("Got new fields " + this.Data.length)
this.Data = this._proxies.map(id => fields[id] as T)
observe(this.Data, () => {
this.updateProxies()
Server.UpdateField(this);
})
}
+ console.log("received fields " + this.Data)
callback(this);
}))
}