aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/Main.tsx
diff options
context:
space:
mode:
authorSam Wilkins <samwilkins333@gmail.com>2019-02-27 15:24:51 -0500
committerSam Wilkins <samwilkins333@gmail.com>2019-02-27 15:24:51 -0500
commitf60be11aef0e76cbc636933611962b3e1a4ec71e (patch)
treeddbbfcde2875d5c223312c7dea6b107a6b66cdfa /src/client/views/Main.tsx
parentac0dfd18950cb2b1e70e0df1c5fc7778e393007f (diff)
mostly finished workspace manipulation: golden-layout bug when creating a new workspace
Diffstat (limited to 'src/client/views/Main.tsx')
-rw-r--r--src/client/views/Main.tsx48
1 files changed, 21 insertions, 27 deletions
diff --git a/src/client/views/Main.tsx b/src/client/views/Main.tsx
index 2c2149a1e..febf7489b 100644
--- a/src/client/views/Main.tsx
+++ b/src/client/views/Main.tsx
@@ -37,33 +37,27 @@ document.addEventListener("pointerdown", action(function (e: PointerEvent) {
}
}), true)
-let mainDocId: string;
+// Load the user's active workspace, or create a new one if initial session after signup
request.get(window.location.origin + "/getActiveWorkspaceId", (error, response, body) => {
- const here = window.location.origin;
- let workspaceId: string;
- if (body) {
- workspaceId = body;
- } else {
- workspaceId = Utils.GenerateGuid();
- request.post(here + "/addWorkspaceId", {
- body: {
- target: mainDocId
- },
- json: true
- })
- request.post(here + "/setActiveWorkspaceId", {
- body: {
- target: mainDocId
- },
- json: true
- })
- }
- load(workspaceId);
-})
+ init(body ? body : getNewWorkspace());
+});
-function load(workspaceId: string) {
- mainDocId = workspaceId;
- init();
+function getNewWorkspace(): string {
+ let newId = Utils.GenerateGuid();
+ const here = window.location.origin;
+ request.post(here + "/addWorkspaceId", {
+ body: {
+ target: newId
+ },
+ json: true
+ })
+ request.post(here + "/setActiveWorkspaceId", {
+ body: {
+ target: newId
+ },
+ json: true
+ })
+ return newId;
}
//runInAction(() =>
@@ -82,7 +76,7 @@ function load(workspaceId: string) {
// schemaDocs[4].SetData(KS.Author, "Bob", TextField);
// schemaDocs.push(doc2);
// const doc7 = Documents.SchemaDocument(schemaDocs)
-function init() {
+function init(mainDocId: string) {
Documents.initProtos(() => {
Utils.EmitCallback(Server.Socket, MessageStore.GetField, mainDocId, (res: any) => {
console.log("HELLO WORLD")
@@ -197,7 +191,7 @@ function init() {
left: '4px',
width: '150px'
}} onClick={() => WorkspacesMenu.Instance.toggle()}>Workspaces</button>
- <WorkspacesMenu load={load} />
+ <WorkspacesMenu load={init} new={getNewWorkspace} />
</div>),
document.getElementById('root'));
})