From f60be11aef0e76cbc636933611962b3e1a4ec71e Mon Sep 17 00:00:00 2001 From: Sam Wilkins Date: Wed, 27 Feb 2019 15:24:51 -0500 Subject: mostly finished workspace manipulation: golden-layout bug when creating a new workspace --- src/client/views/Main.tsx | 48 +++++++++++++++++++++-------------------------- 1 file changed, 21 insertions(+), 27 deletions(-) (limited to 'src/client') 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 - + ), document.getElementById('root')); }) -- cgit v1.2.3-70-g09d2