From 20becbb5ca40350ed85e01f73f29621ba7783bb9 Mon Sep 17 00:00:00 2001
From: bob <bcz@cs.brown.edu>
Date: Wed, 24 Apr 2019 12:20:38 -0400
Subject: playing with linking

---
 src/client/views/nodes/DocumentView.tsx | 38 +++------------------------------
 1 file changed, 3 insertions(+), 35 deletions(-)

(limited to 'src/client/views/nodes/DocumentView.tsx')

diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index 252f4d039..c19b0c342 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -152,7 +152,6 @@ export class DocumentView extends React.Component<DocumentViewProps> {
                 Math.abs(e.clientY - this._downY) < Utils.DRAG_THRESHOLD)) {
             SelectionManager.SelectDoc(this, e.ctrlKey);
         }
-        e.stopPropagation();
     }
     onPointerDown = (e: React.PointerEvent): void => {
         this._downX = e.clientX;
@@ -217,43 +216,12 @@ export class DocumentView extends React.Component<DocumentViewProps> {
     @action
     drop = (e: Event, de: DragManager.DropEvent) => {
         if (de.data instanceof DragManager.LinkDragData) {
-            let sourceDoc: Document = de.data.linkSourceDocument;
-            let destDoc: Document = this.props.Document;
-            let linkDoc: Document = new Document();
+            let sourceDoc = de.data.linkSourceDocument;
+            let destDoc = this.props.Document;
 
             destDoc.GetTAsync(KeyStore.Prototype, Document).then(protoDest =>
                 sourceDoc.GetTAsync(KeyStore.Prototype, Document).then(protoSrc =>
-                    runInAction(() => {
-                        let batch = UndoManager.StartBatch("document view drop");
-                        linkDoc.SetText(KeyStore.Title, "New Link");
-                        linkDoc.SetText(KeyStore.LinkDescription, "");
-                        linkDoc.SetText(KeyStore.LinkTags, "Default");
-
-                        let dstTarg = protoDest ? protoDest : destDoc;
-                        let srcTarg = protoSrc ? protoSrc : sourceDoc;
-                        if ((de.data as DragManager.LinkDragData).blacklist.indexOf(dstTarg) === -1) {
-                            linkDoc.Set(KeyStore.LinkedToDocs, dstTarg);
-                            linkDoc.Set(KeyStore.LinkedFromDocs, srcTarg);
-                            const prom1 = new Promise(resolve => dstTarg.GetOrCreateAsync(
-                                KeyStore.LinkedFromDocs,
-                                ListField,
-                                field => {
-                                    (field as ListField<Document>).Data.push(linkDoc);
-                                    resolve();
-                                }
-                            ));
-                            const prom2 = new Promise(resolve => srcTarg.GetOrCreateAsync(
-                                KeyStore.LinkedToDocs,
-                                ListField,
-                                field => {
-                                    (field as ListField<Document>).Data.push(linkDoc);
-                                    resolve();
-                                }
-                            ));
-                            Promise.all([prom1, prom2]).finally(() => batch.end());
-                        }
-                    })
-                )
+                    (protoSrc ? protoSrc : sourceDoc).CreateLink(protoDest ? protoDest : destDoc))
             );
             e.stopPropagation();
         }
-- 
cgit v1.2.3-70-g09d2

