From 8fb87d09649c269f27b2d475a78b935fc80c637e Mon Sep 17 00:00:00 2001 From: Sam Wilkins Date: Sun, 29 Sep 2019 18:38:04 -0400 Subject: fixed login logic --- src/client/views/MainView.tsx | 76 ++++++++++++++----------------------------- 1 file changed, 25 insertions(+), 51 deletions(-) (limited to 'src') diff --git a/src/client/views/MainView.tsx b/src/client/views/MainView.tsx index 29e046e8b..332e07f1c 100644 --- a/src/client/views/MainView.tsx +++ b/src/client/views/MainView.tsx @@ -256,60 +256,34 @@ export class MainView extends React.Component { initAuthenticationRouters = async () => { // Load the user's active workspace, or create a new one if initial session after signup let received = CurrentUserUtils.MainDocId; - let doc: Opt; - if (received) { - if (!this.userDoc) { - // if no one's logged in... - console.log("NO One's LOGGED IN!"); + if (received && !this.userDoc) { + reaction( + () => CurrentUserUtils.GuestTarget, + target => target && this.createNewWorkspace(), + { fireImmediately: true } + ); + } else { + if (received && this.urlState.sharing) { reaction( - () => CurrentUserUtils.GuestTarget, - target => target && this.createNewWorkspace(), - { fireImmediately: true } + () => { + let docking = CollectionDockingView.Instance; + return docking && docking.initialized; + }, + initialized => { + if (initialized && received) { + DocServer.GetRefField(received).then(field => { + if (field instanceof Doc && field.viewType !== CollectionViewType.Docking) { + CollectionDockingView.AddRightSplit(field, undefined); + } + }); + } + }, ); - } else if (this.urlState.sharing) { - // if a logged in user is opening a shared link - console.log("SHARING, opening right split after docking view initialized"); - if (received && this.urlState.sharing) { - reaction( - () => { - let docking = CollectionDockingView.Instance; - return docking && docking.initialized; - }, - initialized => { - if (initialized && received) { - DocServer.GetRefField(received).then(field => { - if (field instanceof Doc && field.viewType !== CollectionViewType.Docking) { - CollectionDockingView.AddRightSplit(field, undefined); - DocumentManager.Instance.jumpToDocument(field, true, undefined, undefined, undefined, undefined); - const { nro, readonly } = this.urlState; - HistoryUtil.pushState({ - type: "doc", - docId: CurrentUserUtils.MainDocId!, - readonly, - nro, - sharing: false, - }); - } - }); - } - }, - ); - } - } else { - // a logged in user is just opening a document, likely their own workspace - console.log("DEFAULT"); - DocServer.GetRefField(received).then(field => { - console.log(field instanceof Doc ? "Opening" : "Creating"); - field instanceof Doc ? this.openWorkspace(field) : - this.createNewWorkspace(received); - }); } - } else { + let doc: Opt; if (this.userDoc && (doc = await Cast(this.userDoc.activeWorkspace, Doc))) { - console.log("Opening existing workspace for existing user!"); this.openWorkspace(doc); } else { - console.log("Creating a new workspace for existing user!"); this.createNewWorkspace(); } } @@ -322,7 +296,7 @@ export class MainView extends React.Component { y: 400, width: this.pwidth * .7, height: this.pheight, - title: CurrentUserUtils.GuestTarget ? `Guest View of ${StrCast(CurrentUserUtils.GuestTarget.title)}` : "My Blank Collection" + title: "My Blank Collection" }; let workspaces: FieldResult; let freeformDoc = CurrentUserUtils.GuestTarget || Docs.Create.FreeformDocument([], freeformOptions); @@ -636,11 +610,11 @@ export class MainView extends React.Component { @computed get miscButtons() { let logoutRef = React.createRef(); - + const prompt = CurrentUserUtils.GuestWorkspace ? "Exit" : "Log Out"; return [ this.isSearchVisible ?
: null,
-
+ ]; } -- cgit v1.2.3-70-g09d2