aboutsummaryrefslogtreecommitdiff
path: root/src/server/authentication/models/current_user_utils.ts
diff options
context:
space:
mode:
authorBob Zeleznik <zzzman@gmail.com>2019-10-16 23:50:27 -0400
committerBob Zeleznik <zzzman@gmail.com>2019-10-16 23:50:27 -0400
commitcaebaeca6993ff48609ab16dcc390d4d0458b03a (patch)
tree1f35d8f38e1f56c046b4b5585bd22b6f70bcd500 /src/server/authentication/models/current_user_utils.ts
parent7763a08eb5ed931dbf854e2b72d07b7613791e2b (diff)
fixed applying templates to collections. fixed templates containing collections
Diffstat (limited to 'src/server/authentication/models/current_user_utils.ts')
-rw-r--r--src/server/authentication/models/current_user_utils.ts14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/server/authentication/models/current_user_utils.ts b/src/server/authentication/models/current_user_utils.ts
index 5ce707011..e6f202685 100644
--- a/src/server/authentication/models/current_user_utils.ts
+++ b/src/server/authentication/models/current_user_utils.ts
@@ -23,16 +23,11 @@ export class CurrentUserUtils {
public static get MainDocId() { return this.mainDocId; }
public static set MainDocId(id: string | undefined) { this.mainDocId = id; }
@computed public static get UserDocument() { return Doc.UserDoc(); }
+ @computed public static get ActivePen() { return Doc.UserDoc().activePen instanceof Doc && (Doc.UserDoc().activePen as Doc).pen as Doc; }
@observable public static GuestTarget: Doc | undefined;
@observable public static GuestWorkspace: Doc | undefined;
- private static createUserDocument(id: string): Doc {
- let doc = new Doc(id, true);
- doc.title = Doc.CurrentUserEmail;
- return this.updateUserDocument(doc);// this should be the last
- }
-
// a default set of note types .. not being used yet...
static setupNoteTypes(doc: Doc) {
return [
@@ -174,6 +169,7 @@ export class CurrentUserUtils {
}
static updateUserDocument(doc: Doc) {
+ doc.title = Doc.CurrentUserEmail;
new InkingControl();
(doc.optionalRightCollection === undefined) && CurrentUserUtils.setupMobileUploads(doc);
(doc.overlays === undefined) && CurrentUserUtils.setupOverlays(doc);
@@ -216,10 +212,8 @@ export class CurrentUserUtils {
Doc.CurrentUserEmail = email;
await rp.get(Utils.prepend(RouteStore.getUserDocumentId)).then(id => {
if (id && id !== "guest") {
- return DocServer.GetRefField(id).then(async field => {
- let userDoc = field instanceof Doc ? await this.updateUserDocument(field) : this.createUserDocument(id);
- runInAction(() => Doc.SetUserDoc(userDoc));
- });
+ return DocServer.GetRefField(id).then(async field =>
+ Doc.SetUserDoc(await this.updateUserDocument(field instanceof Doc ? field : new Doc(id, true))));
} else {
throw new Error("There should be a user id! Why does Dash think there isn't one?");
}