aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/documents/Documents.ts18
-rw-r--r--src/client/util/LinkManager.ts5
-rw-r--r--src/client/views/Main.tsx23
3 files changed, 44 insertions, 2 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index 2a3827782..638ba287f 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -54,7 +54,8 @@ export enum DocumentType {
PDF = "pdf",
ICON = "icon",
IMPORT = "import",
- LINK = "link"
+ LINK = "link",
+ LINKDOC = "linkdoc"
}
export interface DocumentOptions {
@@ -85,6 +86,12 @@ export interface DocumentOptions {
// [key: string]: Opt<Field>;
}
+class EmptyBox {
+ public static LayoutString() {
+ return "";
+ }
+}
+
export namespace Docs {
export namespace Prototypes {
@@ -148,6 +155,11 @@ export namespace Docs {
[DocumentType.IMPORT, {
layout: { view: DirectoryImportBox },
options: { height: 150 }
+ }],
+ [DocumentType.LINKDOC, {
+ data: new List<Doc>(),
+ layout: { view: EmptyBox },
+ options: {}
}]
]);
@@ -195,6 +207,10 @@ export namespace Docs {
return PrototypeMap.get(type)!;
}
+ export function MainLinkDocument() {
+ return Prototypes.get(DocumentType.LINKDOC);
+ }
+
/**
* This is a convenience method that is used to initialize
* prototype documents for the first time.
diff --git a/src/client/util/LinkManager.ts b/src/client/util/LinkManager.ts
index 1ed040aa4..a647f22c1 100644
--- a/src/client/util/LinkManager.ts
+++ b/src/client/util/LinkManager.ts
@@ -5,6 +5,7 @@ import { listSpec } from "../../new_fields/Schema";
import { List } from "../../new_fields/List";
import { Id } from "../../new_fields/FieldSymbols";
import { CurrentUserUtils } from "../../server/authentication/models/current_user_utils";
+import { Docs } from "../documents/Documents";
/*
@@ -35,7 +36,9 @@ export class LinkManager {
// the linkmanagerdoc stores a list of docs representing all linkdocs in 'allLinks' and a list of strings representing all group types in 'allGroupTypes'
// lists of strings representing the metadata keys for each group type is stored under a key that is the same as the group type
public get LinkManagerDoc(): Doc | undefined {
- return FieldValue(Cast(CurrentUserUtils.UserDocument.linkManagerDoc, Doc));
+ // return FieldValue(Cast(CurrentUserUtils.UserDocument.linkManagerDoc, Doc));
+
+ return Docs.Prototypes.MainLinkDocument();
}
public getAllLinks(): Doc[] {
diff --git a/src/client/views/Main.tsx b/src/client/views/Main.tsx
index 932a6375f..1b9a45f0b 100644
--- a/src/client/views/Main.tsx
+++ b/src/client/views/Main.tsx
@@ -3,9 +3,32 @@ 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);
+ }
+ else {
+ Docs.Prototypes.MainLinkDocument().allLinks = new List<Doc>(links);
+ }
+ }
+ CurrentUserUtils.UserDocument.LinkManagerDoc = undefined;
+ }
+}
(async () => {
await Docs.Prototypes.initialize();
await CurrentUserUtils.loadCurrentUser();
+ await swapDocs();
ReactDOM.render(<MainView />, document.getElementById('root'));
})(); \ No newline at end of file