From 3556aae6d063d8b654509330e70bc67606f16613 Mon Sep 17 00:00:00 2001
From: Tyler Schicke <tyler_schicke@brown.edu>
Date: Sun, 21 Apr 2019 00:39:09 -0400
Subject: More changes

---
 .../views/collections/CollectionDockingView.tsx    | 38 ++++++++++------------
 1 file changed, 18 insertions(+), 20 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 b6c87231f..7b204cbdc 100644
--- a/src/client/views/collections/CollectionDockingView.tsx
+++ b/src/client/views/collections/CollectionDockingView.tsx
@@ -250,28 +250,26 @@ export class CollectionDockingView extends React.Component<SubCollectionViewProp
 
     tabCreated = (tab: any) => {
         if (tab.hasOwnProperty("contentItem") && tab.contentItem.config.type !== "stack") {
-            Server.GetField(tab.contentItem.config.props.documentId, action((f: Opt<Field>) => {
-                if (f !== undefined && f instanceof Document) {
-                    f.GetTAsync(KeyStore.Title, TextField, (tfield) => {
-                        if (tfield !== undefined) {
-                            tab.titleElement[0].textContent = f.Title;
-                        }
-                    });
-                    f.GetTAsync(KeyStore.LinkedFromDocs, ListField).then(lf =>
-                        f.GetTAsync(KeyStore.LinkedToDocs, ListField).then(lt => {
-                            let count = (lf ? lf.Data.length : 0) + (lt ? lt.Data.length : 0);
-                            let counter: any = this.htmlToElement(`<div class="messageCounter">${count}</div>`);
-                            tab.element.append(counter);
-                            counter.DashDocId = tab.contentItem.config.props.documentId;
-                            tab.reactionDisposer = reaction((): [List<Field> | null | undefined, List<Field> | null | undefined] => [Cast(f.linkedFromDocs, List), Cast(f.linkedToDocs, List)],
-                                ([linkedFrom, linkedTo]) => {
-                                    let count = (linkedFrom ? linkedFrom.length : 0) + (linkedTo ? linkedTo.length : 0);
-                                    counter.innerHTML = count;
-                                });
-                        }));
+            DocServer.GetRefField(tab.contentItem.config.props.documentId).then(async f => {
+                if (f instanceof Doc) {
+                    const tfield = await Cast(f.title, "string");
+                    if (tfield !== undefined) {
+                        tab.titleElement[0].textContent = f.Title;
+                    }
+                    const lf = await Cast(f.linkedFromDocs, List);
+                    const lt = await Cast(f.linkedToDocs, List);
+                    let count = (lf ? lf.length : 0) + (lt ? lt.length : 0);
+                    let counter: any = this.htmlToElement(`<div class="messageCounter">${count}</div>`);
+                    tab.element.append(counter);
+                    counter.DashDocId = tab.contentItem.config.props.documentId;
+                    tab.reactionDisposer = reaction((): [List<Field> | null | undefined, List<Field> | null | undefined] => [lf, lt],
+                        ([linkedFrom, linkedTo]) => {
+                            let count = (linkedFrom ? linkedFrom.length : 0) + (linkedTo ? linkedTo.length : 0);
+                            counter.innerHTML = count;
+                        });
                     tab.titleElement[0].DashDocId = tab.contentItem.config.props.documentId;
                 }
-            }));
+            });
         }
         tab.closeElement.off('click') //unbind the current click handler
             .click(function () {
-- 
cgit v1.2.3-70-g09d2

