aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2021-03-19 23:31:59 -0400
committerbobzel <zzzman@gmail.com>2021-03-19 23:31:59 -0400
commit86a1656949a1faa346b073fe0a68e3e856fbb09e (patch)
treea4141452f934338cd8e405fd84716c987b2a1d0c
parent40245cd179ac0544e3a21e1b56ead73475e90cc8 (diff)
fixing up future/history for webBox to sync annotation display.
-rw-r--r--src/client/views/DocComponent.tsx4
-rw-r--r--src/client/views/nodes/WebBox.tsx14
2 files changed, 9 insertions, 9 deletions
diff --git a/src/client/views/DocComponent.tsx b/src/client/views/DocComponent.tsx
index 86396dc4d..be1eab86b 100644
--- a/src/client/views/DocComponent.tsx
+++ b/src/client/views/DocComponent.tsx
@@ -84,7 +84,7 @@ export interface ViewBoxAnnotatableProps {
}
export function ViewBoxAnnotatableComponent<P extends ViewBoxAnnotatableProps, T>(schemaCtor: (doc: Doc) => T) {
class Component extends Touchable<P> {
- _annotationKey: string = "annotations";
+ @observable _annotationKey: string = "annotations";
@observable _isChildActive = false;
//TODO This might be pretty inefficient if doc isn't observed, because computed doesn't cache then
@@ -125,7 +125,7 @@ export function ViewBoxAnnotatableComponent<P extends ViewBoxAnnotatableProps, T
protected _multiTouchDisposer?: InteractionUtils.MultiTouchEventDisposer;
- public get annotationKey() { return this.fieldKey + "-" + this._annotationKey; }
+ @computed public get annotationKey() { return this.fieldKey + "-" + this._annotationKey; }
@action.bound
removeDocument(doc: Doc | Doc[], annotationKey?: string, leavePushpin?: boolean): boolean {
diff --git a/src/client/views/nodes/WebBox.tsx b/src/client/views/nodes/WebBox.tsx
index bfe8782ac..a294125a5 100644
--- a/src/client/views/nodes/WebBox.tsx
+++ b/src/client/views/nodes/WebBox.tsx
@@ -8,7 +8,7 @@ import { Id } from "../../../fields/FieldSymbols";
import { HtmlField } from "../../../fields/HtmlField";
import { InkTool } from "../../../fields/InkField";
import { List } from "../../../fields/List";
-import { makeInterface } from "../../../fields/Schema";
+import { makeInterface, listSpec } from "../../../fields/Schema";
import { Cast, NumCast, StrCast } from "../../../fields/Types";
import { WebField } from "../../../fields/URLField";
import { TraceMobx } from "../../../fields/util";
@@ -282,8 +282,8 @@ export class WebBox extends ViewBoxAnnotatableComponent<FieldViewProps, WebDocum
@action
forward = () => {
- const future = StrListCast(this.dataDoc[this.fieldKey + "-future"]);
- const history = StrListCast(this.dataDoc[this.fieldKey + "-history"]);
+ const future = Cast(this.dataDoc[this.fieldKey + "-future"], listSpec("string"), []);
+ const history = Cast(this.dataDoc[this.fieldKey + "-history"], listSpec("string"), []);
if (future.length) {
history.push(this._url);
this.dataDoc[this.fieldKey] = new WebField(new URL(this._url = future.pop()!));
@@ -295,8 +295,8 @@ export class WebBox extends ViewBoxAnnotatableComponent<FieldViewProps, WebDocum
@action
back = () => {
- const future = StrListCast(this.dataDoc[this.fieldKey + "-future"]);
- const history = StrListCast(this.dataDoc[this.fieldKey + "-history"]);
+ const future = Cast(this.dataDoc[this.fieldKey + "-future"], listSpec("string"));
+ const history = Cast(this.dataDoc[this.fieldKey + "-history"], listSpec("string"), []);
if (history.length) {
if (future === undefined) this.dataDoc[this.fieldKey + "-future"] = new List<string>([this._url]);
else future.push(this._url);
@@ -316,8 +316,8 @@ export class WebBox extends ViewBoxAnnotatableComponent<FieldViewProps, WebDocum
if (!newUrl) return;
if (!newUrl.startsWith("http")) newUrl = "http://" + newUrl;
try {
- const future = StrListCast(this.dataDoc[this.fieldKey + "-future"]);
- const history = StrListCast(this.dataDoc[this.fieldKey + "-history"]);
+ const future = Cast(this.dataDoc[this.fieldKey + "-future"], listSpec("string"));
+ const history = Cast(this.dataDoc[this.fieldKey + "-history"], listSpec("string"));
const url = this.webField?.toString();
if (url) {
if (history === undefined) {