diff options
author | Sam Wilkins <abdullah_ahmed@brown.edu> | 2019-03-08 23:42:40 -0500 |
---|---|---|
committer | Sam Wilkins <abdullah_ahmed@brown.edu> | 2019-03-08 23:42:40 -0500 |
commit | 8ea26fc316685f0a3d1b81b7c2e8bd612acbb99c (patch) | |
tree | 1e7bc0ec6960330b72b503f534684edfd8b13b1c /src/client/views/Main.tsx | |
parent | f4a01b9b394a5bdc48e57923567249bb05cb71ff (diff) |
workspace persistencegit add -Agit add -A
Diffstat (limited to 'src/client/views/Main.tsx')
-rw-r--r-- | src/client/views/Main.tsx | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/client/views/Main.tsx b/src/client/views/Main.tsx index da7e17f1f..cb13e172e 100644 --- a/src/client/views/Main.tsx +++ b/src/client/views/Main.tsx @@ -35,6 +35,11 @@ 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(); }); } @@ -54,6 +59,7 @@ 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); @@ -62,6 +68,7 @@ export class Main extends React.Component { } }); } else { + console.log("FROM THE TOP, WE THINK THERE'S NO CURRENT USER"); this.createNewWorkspace(); } }); @@ -69,7 +76,7 @@ export class Main extends React.Component { @action createNewWorkspace = (): void => { - let mainDoc = Documents.DockDocument(JSON.stringify({ content: [{ type: 'row', content: [] }] }), { title: "main container" }); + 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 }, @@ -86,6 +93,7 @@ export class Main extends React.Component { this.openDocument(mainDoc); }, 0); this.userWorkspaces.push(mainDoc); + console.log(this.userWorkspaces.length); } @action @@ -94,6 +102,7 @@ export class Main extends React.Component { body: { target: doc.Id }, json: true }); + console.log(`OPENING ${doc.Id}`); this.mainContainer = doc; this.mainContainer.GetAsync(KeyStore.ActiveFrame, field => this.mainfreeform = field as Document); } |