From f88bb6cb27d84041637ac31d8b4b82a710367dfb Mon Sep 17 00:00:00 2001
From: madelinegr <mgriswold99@gmail.com>
Date: Fri, 7 Jun 2019 18:08:18 -0400
Subject: Navigation done

---
 .../views/presentationview/PresentationView.tsx    | 29 +++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

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

diff --git a/src/client/views/presentationview/PresentationView.tsx b/src/client/views/presentationview/PresentationView.tsx
index efc333ee3..cbfad56d1 100644
--- a/src/client/views/presentationview/PresentationView.tsx
+++ b/src/client/views/presentationview/PresentationView.tsx
@@ -222,6 +222,32 @@ export class PresentationView extends React.Component<PresViewProps>  {
         });
     }
 
+    navigateToElement = (curDoc: Doc) => {
+        let docToJump: Doc = curDoc;
+        let curDocPresId = StrCast(curDoc.presentId, null);
+
+        if (curDocPresId !== undefined) {
+            if (this.groupMappings.has(curDocPresId)) {
+                let currentDocGroup = this.groupMappings.get(curDocPresId)!;
+                currentDocGroup.forEach((doc: Doc, index: number) => {
+                    let selectedButtons: boolean[] = this.presElementsMappings.get(doc)!.selected;
+                    if (selectedButtons[buttonIndex.Navigate]) {
+                        docToJump = doc;
+                    }
+                });
+            }
+
+        }
+        if (docToJump === curDoc) {
+            if (this.presElementsMappings.get(curDoc)!.selected[buttonIndex.Navigate]) {
+                DocumentManager.Instance.jumpToDocument(curDoc);
+            } else {
+                return;
+            }
+        }
+        DocumentManager.Instance.jumpToDocument(docToJump);
+    }
+
     getDocAtIndex = async (index: number) => {
         const list = FieldValue(Cast(this.props.Document.data, listSpec(Doc)));
         if (!list) {
@@ -255,7 +281,8 @@ export class PresentationView extends React.Component<PresViewProps>  {
 
         this.props.Document.selectedDoc = index;
         const doc = await list[index];
-        DocumentManager.Instance.jumpToDocument(doc);
+        // DocumentManager.Instance.jumpToDocument(doc);
+        this.navigateToElement(doc);
         this.hideIfNotPresented(index);
         this.showAfterPresented(index);
 
-- 
cgit v1.2.3-70-g09d2

