From 4ffcff69a2fc767c6a03d46d7296b6a8c7ffd281 Mon Sep 17 00:00:00 2001
From: madelinegr <mgriswold99@gmail.com>
Date: Tue, 18 Jun 2019 19:13:45 -0400
Subject: Presentations Listed, Option to Change Added, and

---
 .../views/presentationview/PresentationElement.tsx | 28 +++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)

(limited to 'src/client/views/presentationview/PresentationElement.tsx')

diff --git a/src/client/views/presentationview/PresentationElement.tsx b/src/client/views/presentationview/PresentationElement.tsx
index 00dc07921..8ec6348f2 100644
--- a/src/client/views/presentationview/PresentationElement.tsx
+++ b/src/client/views/presentationview/PresentationElement.tsx
@@ -56,7 +56,13 @@ export enum buttonIndex {
 @observer
 export default class PresentationElement extends React.Component<PresentationElementProps> {
 
-    @observable selectedButtons: boolean[] = new Array(6);
+    @observable selectedButtons: boolean[];
+
+
+    constructor(props: PresentationElementProps) {
+        super(props);
+        this.selectedButtons = new Array(6);
+    }
 
     /**
      * Getter to get the status of the buttons.
@@ -67,6 +73,16 @@ export default class PresentationElement extends React.Component<PresentationEle
     }
 
     async componentDidMount() {
+        this.receiveButtonBackUp();
+
+    }
+
+    async componentDidUpdate() {
+        this.receiveButtonBackUp();
+    }
+
+    receiveButtonBackUp = async () => {
+
         //get the list that stores docs that keep track of buttons
         let castedList = Cast(this.props.presButtonBackUp.selectedButtonDocs, listSpec(Doc));
         if (!castedList) {
@@ -74,17 +90,21 @@ export default class PresentationElement extends React.Component<PresentationEle
         }
         //if this is the first time this doc mounts, push a doc for it to store
         if (castedList.length <= this.props.index) {
-            castedList.push(new Doc());
+            let newDoc = new Doc();
+            let defaultBooleanArray: boolean[] = new Array(6);
+            newDoc.selectedButtons = new List(defaultBooleanArray);
+            castedList.push(newDoc);
             //otherwise update the selected buttons depending on storage.
         } else {
             let curDoc: Doc = await castedList[this.props.index];
             let selectedButtonOfDoc = Cast(curDoc.selectedButtons, listSpec("boolean"), null);
+            console.log("Debug Selected Buttons: ", this.selectedButtons, " and the selectedButtonOfDoc: ", selectedButtonOfDoc);
             if (selectedButtonOfDoc !== undefined) {
                 runInAction(() => this.selectedButtons = selectedButtonOfDoc);
+                console.log("New Selected Buttons: ", this.selectedButtons);
             }
         }
 
-
     }
 
     /**
@@ -337,6 +357,8 @@ export default class PresentationElement extends React.Component<PresentationEle
         let p = this.props;
         let title = p.document.title;
 
+        console.log("Re-rendered");
+
         //to get currently selected presentation doc
         let selected = NumCast(p.mainDocument.selectedDoc, 0);
 
-- 
cgit v1.2.3-70-g09d2

