diff options
| author | monikahedman <monika_hedman@brown.edu> | 2019-07-14 17:08:03 -0400 |
|---|---|---|
| committer | monikahedman <monika_hedman@brown.edu> | 2019-07-14 17:08:03 -0400 |
| commit | 7f011d633021fece4d071b741f8571440236ea71 (patch) | |
| tree | ce2e7dc7c29a2a2ebab57efbc8001b2d753819d8 /src/client/views/Main.tsx | |
| parent | 2575564d70828820521074455383e940d521cca8 (diff) | |
| parent | 7d9e29690956327d1ed9981cd2882d08b72b5c86 (diff) | |
pulled from master
Diffstat (limited to 'src/client/views/Main.tsx')
| -rw-r--r-- | src/client/views/Main.tsx | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/client/views/Main.tsx b/src/client/views/Main.tsx index 3d9750a85..589542806 100644 --- a/src/client/views/Main.tsx +++ b/src/client/views/Main.tsx @@ -3,9 +3,33 @@ 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"; + +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 Docs.Prototypes.initialize(); await CurrentUserUtils.loadCurrentUser(); + await swapDocs(); ReactDOM.render(<MainView />, document.getElementById('root')); -})(); +})();
\ No newline at end of file |
