aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/WebBox.tsx
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2021-03-20 00:50:26 -0400
committerbobzel <zzzman@gmail.com>2021-03-20 00:50:26 -0400
commit05e562534763d1c15218ef82b6cb8e8d9bba35b1 (patch)
treed60921b34179dd6bd56414bcc4036d6c675d28a5 /src/client/views/nodes/WebBox.tsx
parent54c8424a1e8999a2f3a82e3463671ddf2a3c84f6 (diff)
cleaned up warnings. fixed webBox annotations to write to correct key so that they appear on startup.
Diffstat (limited to 'src/client/views/nodes/WebBox.tsx')
-rw-r--r--src/client/views/nodes/WebBox.tsx9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/client/views/nodes/WebBox.tsx b/src/client/views/nodes/WebBox.tsx
index b6dd66194..81810fbd1 100644
--- a/src/client/views/nodes/WebBox.tsx
+++ b/src/client/views/nodes/WebBox.tsx
@@ -72,13 +72,15 @@ export class WebBox extends ViewBoxAnnotatableComponent<FieldViewProps, WebDocum
if (this.layoutDoc[this.fieldKey + "-contentWidth"] === undefined) {
this.layoutDoc[this.fieldKey + "-contentWidth"] = Doc.NativeWidth(this.layoutDoc);
}
- this._annotationKey = "annotations-" + this.urlHash(this._url);
}
async componentDidMount() {
this.props.setContentView?.(this); // this tells the DocumentView that this AudioBox is the "content" of the document. this allows the DocumentView to indirectly call getAnchor() on the AudioBox when making a link.
- runInAction(() => this._url = this.webField?.toString() || "");
+ runInAction(() => {
+ this._url = this.webField?.toString() || "";
+ this._annotationKey = "annotations-" + this.urlHash(this._url);
+ });
this._disposers.selection = reaction(() => this.props.isSelected(),
selected => !selected && setTimeout(() => {
@@ -307,7 +309,8 @@ export class WebBox extends ViewBoxAnnotatableComponent<FieldViewProps, WebDocum
return false;
}
- urlHash(s: string) {
+ urlHash = (s: string) => {
+ console.log("Hash: " + s + "=" + this._url + " => " + s.split('').reduce((a: any, b: any) => { a = ((a << 5) - a) + b.charCodeAt(0); return a & a; }, 0))
return s.split('').reduce((a: any, b: any) => { a = ((a << 5) - a) + b.charCodeAt(0); return a & a; }, 0);
}