From 5d3c00c2b02758a644df687656097dad055d0fe1 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Wed, 11 Aug 2021 16:04:00 -0400
Subject: fixed issues with screenshotbox flickering when brought up from top
 menu, and generating errors when recording.

---
 src/client/views/nodes/ScreenshotBox.tsx | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

(limited to 'src/client/views/nodes/ScreenshotBox.tsx')

diff --git a/src/client/views/nodes/ScreenshotBox.tsx b/src/client/views/nodes/ScreenshotBox.tsx
index 0e235a62d..68ab3193b 100644
--- a/src/client/views/nodes/ScreenshotBox.tsx
+++ b/src/client/views/nodes/ScreenshotBox.tsx
@@ -1,11 +1,11 @@
 import React = require("react");
 import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
 // import { Canvas } from '@react-three/fiber';
-import { action, computed, observable, reaction } from "mobx";
+import { action, computed, observable, reaction, trace, runInAction } from "mobx";
 import { observer } from "mobx-react";
 // import { BufferAttribute, Camera, Vector2, Vector3 } from 'three';
 import { DateField } from "../../../fields/DateField";
-import { Doc, WidthSym } from "../../../fields/Doc";
+import { Doc, WidthSym, HeightSym } from "../../../fields/Doc";
 import { documentSchema } from "../../../fields/documentSchemas";
 import { Id } from "../../../fields/FieldSymbols";
 import { InkTool } from "../../../fields/InkField";
@@ -218,9 +218,8 @@ export class ScreenshotBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatabl
         // }
         return (null);
     }
-    toggleRecording = action(async () => {
-        this._screenCapture = !this._screenCapture;
-        if (this._screenCapture) {
+    toggleRecording = async () => {
+        if (!this._screenCapture) {
             this._audioRec = new MediaRecorder(await navigator.mediaDevices.getUserMedia({ audio: true }));
             const aud_chunks: any = [];
             this._audioRec.ondataavailable = (e: any) => aud_chunks.push(e.data);
@@ -249,18 +248,24 @@ export class ScreenshotBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatabl
             };
             this._audioRec.start();
             this._videoRec.start();
-            this.dataDoc.mediaState = "recording";
+            runInAction(() => {
+                this._screenCapture = true;
+                this.dataDoc.mediaState = "recording";
+            });
             DocUtils.ActiveRecordings.push(this);
         } else {
             this._audioRec?.stop();
             this._videoRec?.stop();
-            this.dataDoc.mediaState = "paused";
+            runInAction(() => {
+                this._screenCapture = false;
+                this.dataDoc.mediaState = "paused";
+            });
             const ind = DocUtils.ActiveRecordings.indexOf(this);
             ind !== -1 && (DocUtils.ActiveRecordings.splice(ind, 1));
 
             CaptureManager.Instance.open(this.rootDoc);
         }
-    });
+    };
 
     setupDictation = () => {
         if (this.dataDoc[this.fieldKey + "-dictation"]) return;
@@ -275,7 +280,7 @@ export class ScreenshotBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatabl
         this.dataDoc[this.fieldKey + "-dictation"] = dictationText;
     }
     contentFunc = () => [this.threed, this.content];
-    videoPanelHeight = () => NumCast(this.dataDoc[this.fieldKey + "-nativeHeight"], 1) / NumCast(this.dataDoc[this.fieldKey + "-nativeWidth"], 1) * this.props.PanelWidth();
+    videoPanelHeight = () => NumCast(this.dataDoc[this.fieldKey + "-nativeHeight"], this.layoutDoc[HeightSym]()) / NumCast(this.dataDoc[this.fieldKey + "-nativeWidth"], this.layoutDoc[WidthSym]()) * this.props.PanelWidth();
     formattedPanelHeight = () => Math.max(0, this.props.PanelHeight() - this.videoPanelHeight());
     render() {
         TraceMobx();
-- 
cgit v1.2.3-70-g09d2


From 3051d9a16dff8efbf4d32465812093cae7508c74 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Thu, 19 Aug 2021 18:42:46 -0400
Subject: fixed errors and warnings

---
 src/client/util/CurrentUserUtils.ts                               | 8 ++++----
 src/client/util/LinkManager.ts                                    | 4 ++--
 src/client/util/SharingManager.tsx                                | 2 +-
 src/client/views/nodes/FilterBox.tsx                              | 4 ++--
 src/client/views/nodes/ScreenshotBox.tsx                          | 2 +-
 .../views/nodes/formattedText/ProsemirrorExampleTransfer.ts       | 2 +-
 src/fields/Doc.ts                                                 | 2 +-
 7 files changed, 12 insertions(+), 12 deletions(-)

(limited to 'src/client/views/nodes/ScreenshotBox.tsx')

diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts
index e446e3752..1f37163d7 100644
--- a/src/client/util/CurrentUserUtils.ts
+++ b/src/client/util/CurrentUserUtils.ts
@@ -567,7 +567,7 @@ export class CurrentUserUtils {
             );
 
             menuBtns.forEach(menuBtn => {
-                if (menuBtn.title == "Search") {
+                if (menuBtn.title === "Search") {
                     this.searchBtn = menuBtn;
                 }
             });
@@ -575,10 +575,10 @@ export class CurrentUserUtils {
             menuBtns[menuBtns.length - 1].hidden = ComputedField.MakeFunction("IsNoviceMode()");
 
             menuBtns.forEach(menuBtn => {
-                if (menuBtn.title == "Search") {
-                    doc.searchBtn = menuBtn
+                if (menuBtn.title === "Search") {
+                    doc.searchBtn = menuBtn;
                 }
-            })
+            });
 
             doc.menuStack = new PrefetchProxy(Docs.Create.StackingDocument(menuBtns, {
                 title: "menuItemPanel",
diff --git a/src/client/util/LinkManager.ts b/src/client/util/LinkManager.ts
index c33dff8d1..3579083e4 100644
--- a/src/client/util/LinkManager.ts
+++ b/src/client/util/LinkManager.ts
@@ -47,7 +47,7 @@ export class LinkManager {
                         Doc.GetProto(link)[DirectLinksSym].add(link);
                     }
                 }));
-            }
+            };
             const remLinkFromDoc = (link: Doc) => {
                 const a1 = link?.anchor1;
                 const a2 = link?.anchor2;
@@ -58,7 +58,7 @@ export class LinkManager {
                         Doc.GetProto(link)[DirectLinksSym].delete(link);
                     }
                 }));
-            }
+            };
             const watchUserLinkDB = (userLinkDBDoc: Doc) => {
                 LinkManager.links.push(...DocListCast(userLinkDBDoc.data));
                 const toRealField = (field: Field) => field instanceof ProxyField ? field.value() : field;  // see List.ts.  data structure is not a simple list of Docs, but a list of ProxyField/Fields
diff --git a/src/client/util/SharingManager.tsx b/src/client/util/SharingManager.tsx
index 6c4556250..6d7f7e8df 100644
--- a/src/client/util/SharingManager.tsx
+++ b/src/client/util/SharingManager.tsx
@@ -513,7 +513,7 @@ export class SharingManager extends React.Component<{}> {
 
         if (this.myDocAcls) {
             const newDocs: Doc[] = [];
-            SearchBox.foreachRecursiveDoc(docs, doc => newDocs.push(doc));
+            SearchBox.foreachRecursiveDoc(docs, (depth, doc) => newDocs.push(doc));
             docs = newDocs.filter(doc => GetEffectiveAcl(doc) === AclAdmin);
         }
 
diff --git a/src/client/views/nodes/FilterBox.tsx b/src/client/views/nodes/FilterBox.tsx
index c892a9f6c..beefc4a82 100644
--- a/src/client/views/nodes/FilterBox.tsx
+++ b/src/client/views/nodes/FilterBox.tsx
@@ -101,7 +101,7 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
         if (this._loaded && targetDoc) {
             const allDocs = new Set<Doc>();
             const activeTabs = DocListCast(targetDoc.data);
-            SearchBox.foreachRecursiveDoc(activeTabs, (doc: Doc) => allDocs.add(doc));
+            SearchBox.foreachRecursiveDoc(activeTabs, (depth, doc) => allDocs.add(doc));
             setTimeout(action(() => this._allDocs = Array.from(allDocs)));
         }
         return this._allDocs;
@@ -482,7 +482,7 @@ Scripting.addGlobal(function determineCheckedState(layoutDoc: Doc, facetHeader:
 Scripting.addGlobal(function readFacetData(layoutDoc: Doc, facetHeader: string) {
     const allCollectionDocs = new Set<Doc>();
     const activeTabs = DocListCast(layoutDoc.data);
-    SearchBox.foreachRecursiveDoc(activeTabs, (doc: Doc) => allCollectionDocs.add(doc));
+    SearchBox.foreachRecursiveDoc(activeTabs, (depth: number, doc: Doc) => allCollectionDocs.add(doc));
     const set = new Set<string>();
     if (facetHeader === "tags") allCollectionDocs.forEach(child => Field.toString(child[facetHeader] as Field).split(":").forEach(key => set.add(key)));
     else allCollectionDocs.forEach(child => set.add(Field.toString(child[facetHeader] as Field)));
diff --git a/src/client/views/nodes/ScreenshotBox.tsx b/src/client/views/nodes/ScreenshotBox.tsx
index 68ab3193b..f0db0b594 100644
--- a/src/client/views/nodes/ScreenshotBox.tsx
+++ b/src/client/views/nodes/ScreenshotBox.tsx
@@ -265,7 +265,7 @@ export class ScreenshotBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatabl
 
             CaptureManager.Instance.open(this.rootDoc);
         }
-    };
+    }
 
     setupDictation = () => {
         if (this.dataDoc[this.fieldKey + "-dictation"]) return;
diff --git a/src/client/views/nodes/formattedText/ProsemirrorExampleTransfer.ts b/src/client/views/nodes/formattedText/ProsemirrorExampleTransfer.ts
index eff400a98..76a5675de 100644
--- a/src/client/views/nodes/formattedText/ProsemirrorExampleTransfer.ts
+++ b/src/client/views/nodes/formattedText/ProsemirrorExampleTransfer.ts
@@ -84,7 +84,7 @@ export function buildKeymap<S extends Schema<any>>(schema: S, props: any, mapKey
                 break;
         }
         return true;
-    }
+    };
 
     const toggleEditableMark = (mark: any) => (state: EditorState<S>, dispatch: (tx: Transaction<S>) => void) => canEdit(state) && toggleMark(mark)(state, dispatch);
 
diff --git a/src/fields/Doc.ts b/src/fields/Doc.ts
index 1eeadeedc..e4087cf43 100644
--- a/src/fields/Doc.ts
+++ b/src/fields/Doc.ts
@@ -257,7 +257,7 @@ export class Doc extends RefField {
                         DocServer.GetRefField(this[Id], true);
                     }
                 };
-                const writeMode = DocServer.getFieldWriteMode(fKey as string);
+                const writeMode = DocServer.getFieldWriteMode(fKey);
                 if (fKey.startsWith("acl") || writeMode !== DocServer.WriteMode.Playground) {
                     delete this[CachedUpdates][fKey];
                     await fn();
-- 
cgit v1.2.3-70-g09d2

