diff options
author | bob <bcz@cs.brown.edu> | 2019-03-08 17:53:36 -0500 |
---|---|---|
committer | bob <bcz@cs.brown.edu> | 2019-03-08 17:53:36 -0500 |
commit | b52a583deffe7a3729e182840c0e3f1b1a4e4433 (patch) | |
tree | 498c86c8b184f9307b3043c8d3cfab7796ba97c3 /src | |
parent | d3e66a67406447682c59045a0130d884fe1045a6 (diff) |
fixed network updating of ink
Diffstat (limited to 'src')
-rw-r--r-- | src/client/views/InkingCanvas.tsx | 11 | ||||
-rw-r--r-- | src/fields/InkField.ts | 7 |
2 files changed, 15 insertions, 3 deletions
diff --git a/src/client/views/InkingCanvas.tsx b/src/client/views/InkingCanvas.tsx index 14a779837..0d87c1239 100644 --- a/src/client/views/InkingCanvas.tsx +++ b/src/client/views/InkingCanvas.tsx @@ -1,5 +1,5 @@ import { observer } from "mobx-react"; -import { action } from "mobx"; +import { action, computed } from "mobx"; import { InkingControl } from "./InkingControl"; import React = require("react"); import { Transform } from "../util/Transform"; @@ -11,6 +11,8 @@ import { InkingStroke } from "./InkingStroke"; import "./InkingCanvas.scss" import { CollectionDockingView } from "./collections/CollectionDockingView"; import { Utils } from "../../Utils"; +import { FieldWaiting } from "../../fields/Field"; +import { getMapLikeKeys } from "mobx/lib/internal"; interface InkCanvasProps { @@ -28,8 +30,13 @@ export class InkingCanvas extends React.Component<InkCanvasProps> { super(props); } + @computed get inkData(): StrokeMap { - return new Map(this.props.Document.GetData(KeyStore.Ink, InkField, new Map)); + let map = this.props.Document.GetT(KeyStore.Ink, InkField); + if (!map || map === FieldWaiting) { + return new Map; + } + return new Map(map.Data); } set inkData(value: StrokeMap) { diff --git a/src/fields/InkField.ts b/src/fields/InkField.ts index 1108a04a5..2a4ed18e7 100644 --- a/src/fields/InkField.ts +++ b/src/fields/InkField.ts @@ -1,6 +1,7 @@ import { BasicField } from "./BasicField"; import { Types } from "../server/Message"; import { FieldId } from "./Field"; +import { observable, ObservableMap } from "mobx"; export enum InkTool { None, @@ -38,8 +39,12 @@ export class InkField extends BasicField<StrokeMap> { } } + UpdateFromServer(data: any) { + this.data = new ObservableMap(data); + } + static FromJson(id: string, data: any): InkField { - let map = new Map<string, StrokeData>(); + let map: StrokeMap = new Map<string, StrokeData>(); Object.keys(data).forEach(key => { map.set(key, data[key]); }); |