From be2569d8640f1693eb27f124ad3dd8062ada4837 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Mon, 11 Dec 2023 00:41:05 -0500
Subject: more updates to mobx 6.  updated typescript to v5. updated pdf-dist

---
 src/client/views/PropertiesDocContextSelector.tsx | 27 ++++++++++++++++-------
 1 file changed, 19 insertions(+), 8 deletions(-)

(limited to 'src/client/views/PropertiesDocContextSelector.tsx')

diff --git a/src/client/views/PropertiesDocContextSelector.tsx b/src/client/views/PropertiesDocContextSelector.tsx
index 196250167..5bde9d3c4 100644
--- a/src/client/views/PropertiesDocContextSelector.tsx
+++ b/src/client/views/PropertiesDocContextSelector.tsx
@@ -1,4 +1,4 @@
-import { computed } from 'mobx';
+import { computed, makeObservable, observable } from 'mobx';
 import { observer } from 'mobx-react';
 import * as React from 'react';
 import { Doc, DocListCast } from '../../fields/Doc';
@@ -8,6 +8,7 @@ import { DocFocusOrOpen } from '../util/DocumentManager';
 import { CollectionDockingView } from './collections/CollectionDockingView';
 import { DocumentView, OpenWhere } from './nodes/DocumentView';
 import './PropertiesDocContextSelector.scss';
+import { copyProps } from '../../Utils';
 
 type PropertiesDocContextSelectorProps = {
     DocView?: DocumentView;
@@ -18,10 +19,20 @@ type PropertiesDocContextSelectorProps = {
 
 @observer
 export class PropertiesDocContextSelector extends React.Component<PropertiesDocContextSelectorProps> {
+    _prevProps: PropertiesDocContextSelectorProps;
+    @observable _props: PropertiesDocContextSelectorProps;
+    constructor(props: PropertiesDocContextSelectorProps) {
+        super(props);
+        this._props = this._prevProps = props;
+        makeObservable(this);
+    }
+    componentDidUpdate() {
+        copyProps(this);
+    }
     @computed get _docs() {
-        if (!this.props.DocView) return [];
-        const target = this.props.DocView.props.Document;
-        const targetContext = this.props.DocView.props.docViewPath().lastElement()?.Document;
+        if (!this._props.DocView) return [];
+        const target = this._props.DocView._props.Document;
+        const targetContext = this._props.DocView._props.docViewPath().lastElement()?.Document;
         const embeddings = DocListCast(target.proto_embeddings);
         const containerProtos = embeddings.filter(embedding => embedding.embedContainer && embedding.embedContainer instanceof Doc).reduce((set, embedding) => set.add(Cast(embedding.embedContainer, Doc, null)), new Set<Doc>());
         const containerSets = Array.from(containerProtos.keys()).map(container => DocListCast(container.proto_embeddings));
@@ -40,23 +51,23 @@ export class PropertiesDocContextSelector extends React.Component<PropertiesDocC
         );
 
         return doclayouts
-            .filter(doc => !Doc.AreProtosEqual(doc, CollectionDockingView.Instance?.props.Document))
+            .filter(doc => !Doc.AreProtosEqual(doc, CollectionDockingView.Instance?.Document))
             .filter(doc => !Doc.IsSystem(doc))
             .filter(doc => doc !== targetContext)
             .map(doc => ({ col: doc, target }));
     }
 
     getOnClick = (col: Doc, target: Doc) => {
-        if (!this.props.DocView) return;
+        if (!this._props.DocView) return;
         col = Doc.IsDataProto(col) ? Doc.MakeDelegate(col) : col;
-        DocFocusOrOpen(Doc.GetProto(this.props.DocView.props.Document), undefined, col);
+        DocFocusOrOpen(Doc.GetProto(this._props.DocView.Document), undefined, col);
     };
 
     render() {
         if (this._docs.length < 1) return undefined;
         return (
             <div>
-                {this.props.hideTitle ? null : <p key="contexts">Contexts:</p>}
+                {this._props.hideTitle ? null : <p key="contexts">Contexts:</p>}
                 {this._docs.map(doc => (
                     <p key={doc.col[Id] + doc.target[Id]}>
                         <a onClick={() => this.getOnClick(doc.col, doc.target)}>{StrCast(doc.col.title)}</a>
-- 
cgit v1.2.3-70-g09d2

