From 8f8cfc60098fbb87e791a86d76d7c312b28de276 Mon Sep 17 00:00:00 2001
From: bob <bcz@cs.brown.edu>
Date: Thu, 21 Feb 2019 11:49:23 -0500
Subject: working version of docking view for synchronous users

---
 src/client/views/Main.tsx | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

(limited to 'src/client/views/Main.tsx')

diff --git a/src/client/views/Main.tsx b/src/client/views/Main.tsx
index 2f8337d8e..f35362fd4 100644
--- a/src/client/views/Main.tsx
+++ b/src/client/views/Main.tsx
@@ -61,23 +61,22 @@ Documents.initProtos(() => {
         let mainfreeform: Document;
         if (res) {
             mainContainer = ServerUtils.FromJson(res) as Document;
-            var mainfreeformid = mainContainer._proxies.get(KeyStore.ActiveFrame.Id)!;
-            Server.GetField(mainfreeformid, (field) => {
-                if (field) {
-                    mainfreeform = field as Document;
-                }
-            })
             mainfreeform = mainContainer.Get(KeyStore.ActiveFrame) as Document;
+            if (!mainfreeform)
+                Server.GetField(mainContainer._proxies.get(KeyStore.ActiveFrame.Id)!, (field) => mainfreeform = field as Document);
         }
         else {
-            mainfreeform = Documents.CollectionDocument([], { x: 0, y: 400, title: "mini collection" });
-            Utils.Emit(Server.Socket, MessageStore.AddDocument, new DocumentTransfer(mainfreeform.ToJson()));
-
-            var docs = [mainfreeform].map(doc => CollectionDockingView.makeDocumentConfig(doc));
-            var config = { settings: { selectionEnabled: false }, content: [{ type: 'row', content: docs }] };
-            mainContainer = Documents.DockDocument(JSON.stringify(config), { title: "main container" }, mainDocId);
+            mainContainer = Documents.DockDocument(JSON.stringify({ content: [{ type: 'row', content: [] }] }), { title: "main container" }, mainDocId);
             Utils.Emit(Server.Socket, MessageStore.AddDocument, new DocumentTransfer(mainContainer.ToJson()))
-            mainContainer.Set(KeyStore.ActiveFrame, mainfreeform);
+
+            setTimeout(() => {
+                mainfreeform = Documents.CollectionDocument([], { x: 0, y: 400, title: "mini collection" });
+                Utils.Emit(Server.Socket, MessageStore.AddDocument, new DocumentTransfer(mainfreeform.ToJson()));
+
+                var docs = [mainfreeform].map(doc => CollectionDockingView.makeDocumentConfig(doc));
+                mainContainer.SetText(KeyStore.Data, JSON.stringify({ content: [{ type: 'row', content: docs }] }));
+                mainContainer.Set(KeyStore.ActiveFrame, mainfreeform);
+            }, 25);
         }
 
         let addImageNode = action(() => {
-- 
cgit v1.2.3-70-g09d2

