From 78efe1087488265da4ea37373a2a9a22a7f8cf10 Mon Sep 17 00:00:00 2001
From: geireann <60007097+geireann@users.noreply.github.com>
Date: Mon, 24 Aug 2020 18:39:57 +0800
Subject: pin with view added to marquee menu and pres trails options added

---
 .../views/collections/CollectionDockingView.tsx    | 53 +++++++---------------
 1 file changed, 17 insertions(+), 36 deletions(-)

(limited to 'src/client/views/collections/CollectionDockingView.tsx')

diff --git a/src/client/views/collections/CollectionDockingView.tsx b/src/client/views/collections/CollectionDockingView.tsx
index 744648e24..761d88989 100644
--- a/src/client/views/collections/CollectionDockingView.tsx
+++ b/src/client/views/collections/CollectionDockingView.tsx
@@ -719,43 +719,24 @@ export class DockedFrameRenderer extends React.Component<DockedFrameProps> {
     @undoBatch
     @action
     public static PinDoc(doc: Doc, unpin = false) {
-        if (SelectionManager.SelectedDocuments().length > 1) {
-            SelectionManager.SelectedDocuments().forEach((docView: DocumentView, i: number) => {
-                if (unpin) DockedFrameRenderer.UnpinDoc(docView.props.Document);
-                else {
-                    console.log('adding multiple docs to trails');
-                    const curPres = Cast(Doc.UserDoc().activePresentation, Doc) as Doc;
-                    if (curPres) {
-                        const pinDoc = Doc.MakeAlias(docView.props.Document);
-                        pinDoc.presentationTargetDoc = docView.props.Document;
-                        pinDoc.presZoomButton = true;
-                        pinDoc.context = curPres;
-                        Doc.AddDocToList(curPres, "data", pinDoc);
-                        if (curPres.expandBoolean) pinDoc.presExpandInlineButton = true;
-                        if (!DocumentManager.Instance.getDocumentView(curPres)) {
-                            CollectionDockingView.AddRightSplit(curPres);
-                        }
-                        DocumentManager.Instance.jumpToDocument(doc, false, undefined, Cast(doc.context, Doc, null));
-                    }
-                }
-            });
-        } else {
-            if (unpin) DockedFrameRenderer.UnpinDoc(doc);
-            else {
-                //add this new doc to props.Document
-                const curPres = Cast(Doc.UserDoc().activePresentation, Doc) as Doc;
-                if (curPres) {
-                    const pinDoc = Doc.MakeAlias(doc);
-                    pinDoc.presentationTargetDoc = doc;
-                    pinDoc.presZoomButton = true;
-                    pinDoc.context = curPres;
-                    Doc.AddDocToList(curPres, "data", pinDoc);
-                    if (curPres.expandBoolean) pinDoc.presExpandInlineButton = true;
-                    if (!DocumentManager.Instance.getDocumentView(curPres)) {
-                        CollectionDockingView.AddRightSplit(curPres);
-                    }
-                    DocumentManager.Instance.jumpToDocument(doc, false, undefined, Cast(doc.context, Doc, null));
+        if (unpin) DockedFrameRenderer.UnpinDoc(doc);
+        else {
+            //add this new doc to props.Document
+            const curPres = Cast(Doc.UserDoc().activePresentation, Doc) as Doc;
+            if (curPres) {
+                const pinDoc = Doc.MakeAlias(doc);
+                pinDoc.presentationTargetDoc = doc;
+                pinDoc.presZoomButton = true;
+                pinDoc.context = curPres;
+                Doc.AddDocToList(curPres, "data", pinDoc);
+                if (curPres.expandBoolean) pinDoc.presExpandInlineButton = true;
+                if (!DocumentManager.Instance.getDocumentView(curPres)) {
+                    CollectionDockingView.AddRightSplit(curPres);
                 }
+                DocumentManager.Instance.jumpToDocument(doc, false, undefined, Cast(doc.context, Doc, null));
+                const myPresentations = Doc.UserDoc().myPresentations as Doc;
+                const presData = DocListCast(myPresentations.data);
+                if (!presData.includes(curPres)) Doc.AddDocToList(myPresentations, "data", curPres);
             }
         }
     }
-- 
cgit v1.2.3-70-g09d2

