aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/views/Main.tsx39
-rw-r--r--src/server/authentication/models/current_user_utils.ts10
2 files changed, 20 insertions, 29 deletions
diff --git a/src/client/views/Main.tsx b/src/client/views/Main.tsx
index 51c076b14..bf10a10af 100644
--- a/src/client/views/Main.tsx
+++ b/src/client/views/Main.tsx
@@ -1,7 +1,7 @@
import { IconName, library } from '@fortawesome/fontawesome-svg-core';
import { faFilePdf, faFilm, faFont, faGlobeAsia, faImage, faMusic, faObjectGroup, faPenNib, faRedoAlt, faTable, faTree, faUndoAlt } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
-import { action, computed, configure, observable, runInAction, trace } from 'mobx';
+import { action, computed, configure, observable, runInAction } from 'mobx';
import { observer } from 'mobx-react';
import "normalize.css";
import * as React from 'react';
@@ -128,13 +128,9 @@ export class Main extends React.Component {
}
});
} else {
- Server.GetField(CurrentUserUtils.MainDocId).then(field => {
- if (field instanceof Document) {
- this.openWorkspace(field);
- } else {
- this.createNewWorkspace(CurrentUserUtils.MainDocId);
- }
- });
+ Server.GetField(CurrentUserUtils.MainDocId).then(field =>
+ field instanceof Document ? this.openWorkspace(field) :
+ this.createNewWorkspace(CurrentUserUtils.MainDocId));
}
}
@@ -161,31 +157,26 @@ export class Main extends React.Component {
openWorkspace = (doc: Document, fromHistory = false): void => {
this.mainContainer = doc;
fromHistory || window.history.pushState(null, doc.Title, "/doc/" + doc.Id);
- CurrentUserUtils.UserDocument.GetTAsync(KeyStore.OptionalRightCollection, Document).then(col => {
+ CurrentUserUtils.UserDocument.GetTAsync(KeyStore.OptionalRightCollection, Document).then(col =>
// if there is a pending doc, and it has new data, show it (syip: we use a timeout to prevent collection docking view from being uninitialized)
- setTimeout(() => {
- if (col) {
- col.GetTAsync<ListField<Document>>(KeyStore.Data, ListField, (f: Opt<ListField<Document>>) => {
- if (f && f.Data.length > 0) {
- CollectionDockingView.Instance.AddRightSplit(col);
- }
- });
- }
- }, 100);
- });
+ setTimeout(() =>
+ col && col.GetTAsync<ListField<Document>>(KeyStore.Data, ListField, (f: Opt<ListField<Document>>) =>
+ f && f.Data.length > 0 && CollectionDockingView.Instance.AddRightSplit(col))
+ , 100)
+ );
}
@computed
get mainContent() {
- trace();
let pwidthFunc = () => this.pwidth;
let pheightFunc = () => this.pheight;
let noScaling = () => 1;
+ let mainCont = this.mainContainer;
return <Measure onResize={action((r: any) => { this.pwidth = r.entry.width; this.pheight = r.entry.height; })}>
{({ measureRef }) =>
<div ref={measureRef} id="mainContent-div">
- {!this.mainContainer ? (null) :
- <DocumentView Document={this.mainContainer}
+ {!mainCont ? (null) :
+ <DocumentView Document={mainCont}
addDocument={undefined}
removeDocument={undefined}
opacity={1}
@@ -257,7 +248,7 @@ export class Main extends React.Component {
get miscButtons() {
let workspacesRef = React.createRef<HTMLDivElement>();
let logoutRef = React.createRef<HTMLDivElement>();
- let toggleWorkspaces = () => runInAction(() => { this._workspacesShown = !this._workspacesShown; });
+ let toggleWorkspaces = () => runInAction(() => this._workspacesShown = !this._workspacesShown);
let clearDatabase = action(() => Utils.Emit(Server.Socket, MessageStore.DeleteAll, {}));
return [
@@ -277,7 +268,7 @@ export class Main extends React.Component {
@computed
get workspaceMenu() {
let areWorkspacesShown = () => this._workspacesShown;
- let toggleWorkspaces = () => runInAction(() => { this._workspacesShown = !this._workspacesShown; });
+ let toggleWorkspaces = () => runInAction(() => this._workspacesShown = !this._workspacesShown);
let workspaces = CurrentUserUtils.UserDocument.GetT<ListField<Document>>(KeyStore.Workspaces, ListField);
return (!workspaces || workspaces === FieldWaiting) ? (null) :
<WorkspacesMenu active={this.mainContainer} open={this.openWorkspace}
diff --git a/src/server/authentication/models/current_user_utils.ts b/src/server/authentication/models/current_user_utils.ts
index 34454eda0..848728183 100644
--- a/src/server/authentication/models/current_user_utils.ts
+++ b/src/server/authentication/models/current_user_utils.ts
@@ -1,4 +1,4 @@
-import { computed, observable, action } from "mobx";
+import { computed, observable, action, runInAction } from "mobx";
import * as rp from 'request-promise';
import { Documents } from "../../../client/documents/Documents";
import { Attribute, AttributeGroup, Catalog, Schema } from "../../../client/northstar/model/idea/idea";
@@ -13,13 +13,13 @@ import { ServerUtils } from "../../ServerUtil";
export class CurrentUserUtils {
private static curr_email: string;
private static curr_id: string;
- private static user_document: Document;
+ @observable private static user_document: Document;
//TODO tfs: these should be temporary...
private static mainDocId: string | undefined;
public static get email() { return this.curr_email; }
public static get id() { return this.curr_id; }
- public static get UserDocument() { return this.user_document; }
+ @computed public static get UserDocument() { return this.user_document; }
public static get MainDocId() { return this.mainDocId; }
public static set MainDocId(id: string | undefined) { this.mainDocId = id; }
@@ -40,14 +40,14 @@ export class CurrentUserUtils {
throw new Error("There should be a user! Why does Dash think there isn't one?");
}
});
- let userDocPromise = rp.get(ServerUtils.prepend(RouteStore.getUserDocumentId)).then(id => {
+ let userDocPromise = rp.get(ServerUtils.prepend(RouteStore.getUserDocumentId)).then(id => runInAction(() => {
if (id) {
return Server.GetField(id).then(field =>
this.user_document = field instanceof Document ? field : this.createUserDocument(id));
} else {
throw new Error("There should be a user id! Why does Dash think there isn't one?");
}
- });
+ }));
return Promise.all([userPromise, userDocPromise]);
}