From aab4148a23a6505f103564fff305ac4c97b64479 Mon Sep 17 00:00:00 2001
From: monoguitari <113245090+monoguitari@users.noreply.github.com>
Date: Wed, 23 Aug 2023 13:15:31 -0400
Subject: Basic implementation of micahels branching trail on master

---
 src/client/util/BranchingTrailManager.tsx | 29 +++++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

(limited to 'src/client/util/BranchingTrailManager.tsx')

diff --git a/src/client/util/BranchingTrailManager.tsx b/src/client/util/BranchingTrailManager.tsx
index 44cec6922..a224b84f4 100644
--- a/src/client/util/BranchingTrailManager.tsx
+++ b/src/client/util/BranchingTrailManager.tsx
@@ -6,6 +6,8 @@ import { Id } from '../../fields/FieldSymbols';
 import { PresBox } from '../views/nodes/trails';
 import { OverlayView } from '../views/OverlayView';
 import { DocumentManager } from './DocumentManager';
+import { Docs } from '../documents/Documents';
+import { nullAudio } from '../../fields/URLField';
 
 @observer
 export class BranchingTrailManager extends React.Component {
@@ -19,8 +21,20 @@ export class BranchingTrailManager extends React.Component {
     }
 
     setupUi = () => {
-        OverlayView.Instance.addWindow(<BranchingTrailManager></BranchingTrailManager>, { x: 100, y: 150, width: 1000, title: 'Branching Trail' });
+        OverlayView.Instance.addWindow(<BranchingTrailManager></BranchingTrailManager>, { x: 100, y: 150, width: 1000, title: 'Branching Trail'});
+        // OverlayView.Instance.forceUpdate();
+        console.log(OverlayView.Instance);
+        // let hi = Docs.Create.TextDocument("beee", {
+        //     x: 100,
+        //     y: 100,
+        // })
+        // hi.overlayX = 100;
+        // hi.overlayY = 100;
+        
+        // Doc.AddToMyOverlay(hi);
+        console.log(DocumentManager._overlayViews);
     };
+    
 
     // stack of the history
     @observable private slideHistoryStack: String[] = [];
@@ -53,7 +67,9 @@ export class BranchingTrailManager extends React.Component {
         }
 
         if (this.prevPresId === null || this.prevPresId !== presId) {
+            Doc.UserDoc().isBranchingMode = true;
             this.setPrevPres(presId);
+            
             // REVERT THE SET
             const stringified = [presId, targetDocId].toString();
             if (this.containsSet.has([presId, targetDocId].toString())) {
@@ -68,6 +84,10 @@ export class BranchingTrailManager extends React.Component {
                 this.containsSet.add(stringified);
             }
         }
+        console.log(this.slideHistoryStack.length);
+        if (this.slideHistoryStack.length === 0) {
+            Doc.UserDoc().isBranchingMode = false;
+        }
     };
 
     clickHandler = (e: React.PointerEvent<HTMLButtonElement>, targetDocId: string, removeIndex: number) => {
@@ -75,18 +95,23 @@ export class BranchingTrailManager extends React.Component {
         if (!targetDoc) {
             return;
         }
+
         const newStack = this.slideHistoryStack.slice(0, removeIndex);
         const removed = this.slideHistoryStack.slice(removeIndex);
+        
         this.setSlideHistoryStack(newStack);
 
         removed.forEach(info => this.containsSet.delete(info.toString()));
         DocumentManager.Instance.showDocument(targetDoc, { willZoomCentered: true });
+        if (this.slideHistoryStack.length === 0) {
+            Doc.UserDoc().isBranchingMode = false;
+        }
         //PresBox.NavigateToTarget(targetDoc, targetDoc);
     };
 
     @computed get trailBreadcrumbs() {
         return (
-            <div style={{ border: '.5rem solid green', padding: '5px', backgroundColor: 'white', minHeight: '50px' }}>
+            <div style={{ border: '.5rem solid green', padding: '5px', backgroundColor: 'white', minHeight: '50px', minWidth: '1000px' }}>
                 {this.slideHistoryStack.map((info, index) => {
                     const [presId, targetDocId] = info.split(',');
                     const doc = this.docIdToDocMap.get(targetDocId);
-- 
cgit v1.2.3-70-g09d2

