aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSam Wilkins <samwilkins333@gmail.com>2019-09-29 18:38:04 -0400
committerSam Wilkins <samwilkins333@gmail.com>2019-09-29 18:38:04 -0400
commit8fb87d09649c269f27b2d475a78b935fc80c637e (patch)
treec637e1728fea384fac134387a344136da83af651 /src
parent0cf79318e179588ff5855156b2ad0d729958c9e8 (diff)
fixed login logic
Diffstat (limited to 'src')
-rw-r--r--src/client/views/MainView.tsx76
1 files changed, 25 insertions, 51 deletions
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<Doc>;
- 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<Doc>;
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<Doc>;
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<HTMLDivElement>();
-
+ const prompt = CurrentUserUtils.GuestWorkspace ? "Exit" : "Log Out";
return [
this.isSearchVisible ? <div className="main-searchDiv" key="search" style={{ top: '34px', right: '1px', position: 'absolute' }} > <FilterBox /> </div> : null,
<div className="main-buttonDiv" key="logout" style={{ bottom: '0px', right: '1px', position: 'absolute' }} ref={logoutRef}>
- <button onClick={() => window.location.assign(Utils.prepend(RouteStore.logout))}>Log Out</button></div>
+ <button onClick={() => window.location.assign(Utils.prepend(RouteStore.logout))}>{prompt}</button></div>
];
}