aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/views/Main.tsx22
-rw-r--r--src/server/authentication/controllers/WorkspacesMenu.tsx4
2 files changed, 13 insertions, 13 deletions
diff --git a/src/client/views/Main.tsx b/src/client/views/Main.tsx
index cb13e172e..b160a7671 100644
--- a/src/client/views/Main.tsx
+++ b/src/client/views/Main.tsx
@@ -35,11 +35,6 @@ export class Main extends React.Component {
this.initEventListeners();
Documents.initProtos(() => {
- // retrieve all workspace documents from the server
- request.get(this.contextualize("getAllWorkspaceIds"), (error, res, body) => {
- let ids = JSON.parse(body) as string[];
- Server.GetFields(ids, action((fields: { [id: string]: Field }) => this.userWorkspaces = ids.map(id => fields[id] as Document)));
- })
this.initAuthenticationRouters();
});
}
@@ -59,34 +54,39 @@ export class Main extends React.Component {
// Load the user's active workspace, or create a new one if initial session after signup
request.get(this.contextualize("getActiveWorkspaceId"), (error, response, body) => {
if (body) {
- console.log("FROM THE TOP, SOMEONE'S ALREADY BEEN HERE");
Server.GetField(body, field => {
if (field instanceof Document) {
this.openDocument(field);
} else {
- this.createNewWorkspace();
+ this.createNewWorkspace(true);
}
});
} else {
- console.log("FROM THE TOP, WE THINK THERE'S NO CURRENT USER");
- this.createNewWorkspace();
+ this.createNewWorkspace(true);
}
});
}
@action
- createNewWorkspace = (): void => {
+ createNewWorkspace = (init: boolean): void => {
let mainDoc = Documents.DockDocument(JSON.stringify({ content: [{ type: 'row', content: [] }] }), { title: `Main Container ${this.userWorkspaces.length}` });
let newId = mainDoc.Id;
request.post(this.contextualize("addWorkspaceId"), {
body: { target: newId },
json: true
+ }, () => {
+ if (init) {
+ // retrieve all workspace documents from the server
+ request.get(this.contextualize("getAllWorkspaceIds"), (error, res, body) => {
+ let ids = JSON.parse(body) as string[];
+ Server.GetFields(ids, action((fields: { [id: string]: Field }) => this.userWorkspaces = ids.map(id => fields[id] as Document)));
+ });
+ }
});
// bcz: strangely, we need a timeout to prevent exceptions/issues initializing GoldenLayout (the rendering engine for Main Container)
setTimeout(() => {
let freeformDoc = Documents.FreeformDocument([], { x: 0, y: 400, title: "mini collection" });
-
var dockingLayout = { content: [{ type: 'row', content: [CollectionDockingView.makeDocumentConfig(freeformDoc)] }] };
mainDoc.SetText(KeyStore.Data, JSON.stringify(dockingLayout));
mainDoc.Set(KeyStore.ActiveFrame, freeformDoc);
diff --git a/src/server/authentication/controllers/WorkspacesMenu.tsx b/src/server/authentication/controllers/WorkspacesMenu.tsx
index 00de34d7a..70c37774c 100644
--- a/src/server/authentication/controllers/WorkspacesMenu.tsx
+++ b/src/server/authentication/controllers/WorkspacesMenu.tsx
@@ -11,7 +11,7 @@ import { Field } from '../../../fields/Field';
export interface WorkspaceMenuProps {
active: Document;
open: (workspace: Document) => void;
- new: () => void;
+ new: (init: boolean) => void;
allWorkspaces: Document[];
}
@@ -28,7 +28,7 @@ export class WorkspacesMenu extends React.Component<WorkspaceMenuProps> {
@action
addNewWorkspace() {
- this.props.new();
+ this.props.new(false);
this.toggle();
}