aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/Main.tsx
diff options
context:
space:
mode:
authorMohammad Amoush <mohammad_amoush@brown.edu>2019-07-16 18:03:12 -0400
committerMohammad Amoush <mohammad_amoush@brown.edu>2019-07-16 18:03:12 -0400
commit1cedadbdf01c392ca9910e3ca18f3875d9a86fed (patch)
tree602608ba06b997cd3144395640e404a01f666291 /src/client/views/Main.tsx
parentf70b95879e87a6bb61aaae5de29747d9474623a7 (diff)
parentf18be9418b9237acd847eaf71adc034226c54695 (diff)
Merge branch 'master' of https://github.com/browngraphicslab/Dash-Web into youtube-api-muhammed
Diffstat (limited to 'src/client/views/Main.tsx')
-rw-r--r--src/client/views/Main.tsx33
1 files changed, 30 insertions, 3 deletions
diff --git a/src/client/views/Main.tsx b/src/client/views/Main.tsx
index 3d9750a85..86578af3e 100644
--- a/src/client/views/Main.tsx
+++ b/src/client/views/Main.tsx
@@ -3,9 +3,36 @@ import { Docs } from "../documents/Documents";
import { CurrentUserUtils } from "../../server/authentication/models/current_user_utils";
import * as ReactDOM from 'react-dom';
import * as React from 'react';
+import { Cast } from "../../new_fields/Types";
+import { Doc, DocListCastAsync } from "../../new_fields/Doc";
+import { List } from "../../new_fields/List";
+import { DocServer } from "../DocServer";
+
+let swapDocs = async () => {
+ let oldDoc = await Cast(CurrentUserUtils.UserDocument.linkManagerDoc, Doc);
+ // Docs.Prototypes.MainLinkDocument().allLinks = new List<Doc>();
+ if (oldDoc) {
+ let links = await DocListCastAsync(oldDoc.allLinks);
+ // if (links && DocListCast(links)) {
+ if (links && links.length) {
+ let data = await DocListCastAsync(Docs.Prototypes.MainLinkDocument().allLinks);
+ if (data) {
+ data.push(...links.filter(i => data!.indexOf(i) === -1));
+ Docs.Prototypes.MainLinkDocument().allLinks = new List<Doc>(data.filter((i, idx) => data!.indexOf(i) === idx));
+ }
+ else {
+ Docs.Prototypes.MainLinkDocument().allLinks = new List<Doc>(links);
+ }
+ }
+ CurrentUserUtils.UserDocument.linkManagerDoc = undefined;
+ }
+};
(async () => {
- await Docs.initProtos();
- await CurrentUserUtils.loadCurrentUser();
+ const info = await CurrentUserUtils.loadCurrentUser();
+ DocServer.init(window.location.protocol, window.location.hostname, 4321, info.email);
+ await Docs.Prototypes.initialize();
+ await CurrentUserUtils.loadUserDocument(info);
+ await swapDocs();
ReactDOM.render(<MainView />, document.getElementById('root'));
-})();
+})(); \ No newline at end of file