aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryipstanley <stanley_yip@brown.edu>2019-02-11 20:38:09 -0500
committeryipstanley <stanley_yip@brown.edu>2019-02-11 20:38:09 -0500
commit2eb147ab8f25e6dd90f47cf21499c7340642f0c9 (patch)
tree527f184d12ee4ab1e50efc715c992b7fced0d406
parent7d30ae6c423290e502f72be566c4aba4fe62f9ff (diff)
asdkjfl
-rw-r--r--src/client/Server.ts4
-rw-r--r--src/client/SocketStub.ts6
-rw-r--r--src/fields/Document.ts10
-rw-r--r--src/fields/Field.ts5
4 files changed, 13 insertions, 12 deletions
diff --git a/src/client/Server.ts b/src/client/Server.ts
index db6bf992c..30fc57c93 100644
--- a/src/client/Server.ts
+++ b/src/client/Server.ts
@@ -31,9 +31,9 @@ export class Server {
public static GetDocumentField(doc: Document, key: Key) {
var hackTimeout: number = key == KeyStore.Data ? (this.times++ == 0 ? 5000 : 1000) : key == KeyStore.X ? 2500 : 500;
- return this.GetField(doc._proxies.get(key),
+ return this.GetField(doc._proxies.get(key.Id),
action((fieldfromserver: Field) => {
- doc._proxies.delete(key);
+ doc._proxies.delete(key.Id);
doc.fields.set(key, fieldfromserver);
})
, hackTimeout);
diff --git a/src/client/SocketStub.ts b/src/client/SocketStub.ts
index 3b1401632..bdf326cd8 100644
--- a/src/client/SocketStub.ts
+++ b/src/client/SocketStub.ts
@@ -19,7 +19,7 @@ export class SocketStub {
// server stores stripped down document (w/ only field id proxies) in the field store
this.FieldStore.set(document.Id, new Document(document.Id));
- document.fields.forEach((f, key) => (this.FieldStore.get(document.Id) as Document)._proxies.set(key, (f as Field).Id));
+ document.fields.forEach((f, key) => (this.FieldStore.get(document.Id) as Document)._proxies.set(key.Id, (f as Field).Id));
// Server.Socket.emit(MessageStore.AddDocument.Message, document)
}
@@ -41,7 +41,7 @@ export class SocketStub {
// server updates its document to hold a proxy mapping from key => fieldId
var document = this.FieldStore.get(doc.Id) as Document;
if (document)
- document._proxies.set(key, value.Id);
+ document._proxies.set(key.Id, value.Id);
// server adds the field to its repository of fields
this.FieldStore.set(value.Id, value);
@@ -55,7 +55,7 @@ export class SocketStub {
// Server removes the field id from the document's list of field proxies
var document = this.FieldStore.get(doc.Id) as Document;
if (document)
- document._proxies.delete(key);
+ document._proxies.delete(key.Id);
}
public static SEND_SET_FIELD(field: Field, value: any) {
diff --git a/src/fields/Document.ts b/src/fields/Document.ts
index 004bfa4c0..99cd03813 100644
--- a/src/fields/Document.ts
+++ b/src/fields/Document.ts
@@ -10,7 +10,7 @@ import { Types } from "../server/Message";
export class Document extends Field {
public fields: ObservableMap<Key, Opt<Field>> = new ObservableMap();
- public _proxies: ObservableMap<Key, FIELD_ID> = new ObservableMap();
+ public _proxies: ObservableMap<string, FIELD_ID> = new ObservableMap();
@computed
public get Title() {
@@ -22,18 +22,18 @@ export class Document extends Field {
if (ignoreProto) {
if (this.fields.has(key)) {
field = this.fields.get(key);
- } else if (this._proxies.has(key)) {
+ } else if (this._proxies.has(key.Id)) {
field = Server.GetDocumentField(this, key);
}
} else {
let doc: FieldValue<Document> = this;
while (doc && doc != FieldWaiting && field != FieldWaiting) {
if (!doc.fields.has(key)) {
- if (doc._proxies.has(key)) {
+ if (doc._proxies.has(key.Id)) {
field = Server.GetDocumentField(doc, key);
break;
}
- if ((doc.fields.has(KeyStore.Prototype) || doc._proxies.has(KeyStore.Prototype))) {
+ if ((doc.fields.has(KeyStore.Prototype) || doc._proxies.has(KeyStore.Prototype.Id))) {
doc = doc.GetPrototype();
} else
break;
@@ -160,7 +160,7 @@ export class Document extends Field {
let fields: [string, string][] = []
this._proxies.forEach((field, key) => {
if (field) {
- fields.push([key.Id as string, field as string])
+ fields.push([key, field as string])
}
});
diff --git a/src/fields/Field.ts b/src/fields/Field.ts
index 03c2da7be..1a5cfb29c 100644
--- a/src/fields/Field.ts
+++ b/src/fields/Field.ts
@@ -28,8 +28,8 @@ export type FieldValue<T> = Opt<T> | FIELD_WAITING;
export abstract class Field {
//FieldUpdated: TypedEvent<Opt<FieldUpdatedArgs>> = new TypedEvent<Opt<FieldUpdatedArgs>>();
- private id: FIELD_ID;
- get Id(): FIELD_ID {
+ private id: string;
+ get Id(): string {
return this.id;
}
@@ -87,6 +87,7 @@ export abstract class Field {
let doc: Document = new Document(id)
let fields: [string, string][] = data as [string, string][]
fields.forEach(element => {
+ doc._proxies.set(element[0], element[1]);
let keyId: string = element[0]
let valueId: string = element[1]
Server.GetField(keyId, (key: Field) => {