aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/views/Main.tsx14
-rw-r--r--src/client/views/collections/CollectionView.tsx4
-rw-r--r--src/server/authentication/models/current_user_utils.ts16
3 files changed, 21 insertions, 13 deletions
diff --git a/src/client/views/Main.tsx b/src/client/views/Main.tsx
index fdbad6ce1..cb49bc4e6 100644
--- a/src/client/views/Main.tsx
+++ b/src/client/views/Main.tsx
@@ -73,8 +73,6 @@ export class Main extends React.Component {
return CurrentUserUtils.UserDocument;
}
- public mainDocId: string | undefined;
- private currentUser?: DashUserModel;
public static Instance: Main;
constructor(props: Readonly<{}>) {
@@ -85,7 +83,7 @@ export class Main extends React.Component {
if (window.location.pathname !== RouteStore.home) {
let pathname = window.location.pathname.split("/");
if (pathname.length > 1 && pathname[pathname.length - 2] == 'doc') {
- this.mainDocId = pathname[pathname.length - 1];
+ CurrentUserUtils.MainDocId = pathname[pathname.length - 1];
}
};
@@ -117,8 +115,8 @@ export class Main extends React.Component {
onHistory = () => {
if (window.location.pathname !== RouteStore.home) {
let pathname = window.location.pathname.split("/");
- this.mainDocId = pathname[pathname.length - 1];
- Server.GetField(this.mainDocId, action((field: Opt<Field>) => {
+ CurrentUserUtils.MainDocId = pathname[pathname.length - 1];
+ Server.GetField(CurrentUserUtils.MainDocId, action((field: Opt<Field>) => {
if (field instanceof Document) {
this.openWorkspace(field, true);
}
@@ -148,7 +146,7 @@ export class Main extends React.Component {
initAuthenticationRouters = () => {
// Load the user's active workspace, or create a new one if initial session after signup
- if (!this.mainDocId) {
+ if (!CurrentUserUtils.MainDocId) {
this.userDocument.GetTAsync(KeyStore.ActiveWorkspace, Document).then(doc => {
if (doc) {
this.openWorkspace(doc);
@@ -157,11 +155,11 @@ export class Main extends React.Component {
}
})
} else {
- Server.GetField(this.mainDocId).then(field => {
+ Server.GetField(CurrentUserUtils.MainDocId).then(field => {
if (field instanceof Document) {
this.openWorkspace(field)
} else {
- this.createNewWorkspace(this.mainDocId);
+ this.createNewWorkspace(CurrentUserUtils.MainDocId);
}
})
}
diff --git a/src/client/views/collections/CollectionView.tsx b/src/client/views/collections/CollectionView.tsx
index 7e1d31018..c72633175 100644
--- a/src/client/views/collections/CollectionView.tsx
+++ b/src/client/views/collections/CollectionView.tsx
@@ -13,7 +13,7 @@ import { CollectionSchemaView } from "./CollectionSchemaView";
import { CollectionViewProps } from "./CollectionViewBase";
import { CollectionTreeView } from "./CollectionTreeView";
import { Field, FieldId, FieldWaiting } from "../../../fields/Field";
-import { Main } from "../Main";
+import { CurrentUserUtils } from "../../../server/authentication/models/current_user_utils";
export enum CollectionViewType {
Invalid,
@@ -96,7 +96,7 @@ export class CollectionView extends React.Component<CollectionViewProps> {
}
specificContextMenu = (e: React.MouseEvent): void => {
- if (!e.isPropagationStopped() && this.props.Document.Id != Main.Instance.mainDocId) { // need to test this because GoldenLayout causes a parallel hierarchy in the React DOM for its children and the main document view7
+ if (!e.isPropagationStopped() && this.props.Document.Id != CurrentUserUtils.MainDocId) { // need to test this because GoldenLayout causes a parallel hierarchy in the React DOM for its children and the main document view7
ContextMenu.Instance.addItem({ description: "Freeform", event: () => this.props.Document.SetNumber(KeyStore.ViewType, CollectionViewType.Freeform) })
ContextMenu.Instance.addItem({ description: "Schema", event: () => this.props.Document.SetNumber(KeyStore.ViewType, CollectionViewType.Schema) })
ContextMenu.Instance.addItem({ description: "Treeview", event: () => this.props.Document.SetNumber(KeyStore.ViewType, CollectionViewType.Tree) })
diff --git a/src/server/authentication/models/current_user_utils.ts b/src/server/authentication/models/current_user_utils.ts
index 17a6d493b..3291c671c 100644
--- a/src/server/authentication/models/current_user_utils.ts
+++ b/src/server/authentication/models/current_user_utils.ts
@@ -12,17 +12,27 @@ export class CurrentUserUtils {
private static curr_email: string;
private static curr_id: string;
private static user_document: Document;
+ //TODO tfs: this should be temporary...
+ private static mainDocId: string | undefined;
public static get email(): string {
- return CurrentUserUtils.curr_email;
+ return this.curr_email;
}
public static get id(): string {
- return CurrentUserUtils.curr_id;
+ return this.curr_id;
}
public static get UserDocument(): Document {
- return CurrentUserUtils.user_document;
+ return this.user_document;
+ }
+
+ public static get MainDocId(): string | undefined {
+ return this.mainDocId;
+ }
+
+ public static set MainDocId(id: string | undefined) {
+ this.mainDocId = id;
}
private static createUserDocument(id: string): Document {