aboutsummaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/client')
-rw-r--r--src/client/util/CurrentUserUtils.ts6
-rw-r--r--src/client/util/SharingManager.tsx12
2 files changed, 10 insertions, 8 deletions
diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts
index 759fd6eca..580c6040e 100644
--- a/src/client/util/CurrentUserUtils.ts
+++ b/src/client/util/CurrentUserUtils.ts
@@ -956,6 +956,9 @@ export class CurrentUserUtils {
}
static async updateUserDocument(doc: Doc, sharingDocumentId: string) {
+ if (!doc.globalGroupDatabase) doc.globalGroupDatabase = Docs.Prototypes.MainGroupDocument();
+ await DocListCastAsync((doc.globalGroupDatabase as Doc).data);
+ UserGroups.Current;
doc.system = true;
doc.noviceMode = doc.noviceMode === undefined ? "true" : doc.noviceMode;
doc.title = Doc.CurrentUserEmail;
@@ -989,10 +992,7 @@ export class CurrentUserUtils {
await this.setupSidebarButtons(doc); // the pop-out left sidebar of tools/panels
await this.setupMenuPanel(doc, sharingDocumentId);
if (!doc.globalScriptDatabase) doc.globalScriptDatabase = Docs.Prototypes.MainScriptDocument();
- doc.globalGroupDatabase = Docs.Prototypes.MainGroupDocument();
if (!doc.myLinkDatabase) doc.myLinkDatabase = new List([]);
- const x = await DocListCastAsync((doc.globalGroupDatabase as Doc).data);
- UserGroups.setCurrentUserGroups((doc.globalGroupDatabase as Doc).data as List<Doc>);
setTimeout(() => this.setupDefaultPresentation(doc), 0); // presentation that's initially triggered
diff --git a/src/client/util/SharingManager.tsx b/src/client/util/SharingManager.tsx
index 729742890..ee397ab4f 100644
--- a/src/client/util/SharingManager.tsx
+++ b/src/client/util/SharingManager.tsx
@@ -4,7 +4,7 @@ import { observer } from "mobx-react";
import * as React from "react";
import Select from "react-select";
import * as RequestPromise from "request-promise";
-import { AclAdmin, AclPrivate, DataSym, Doc, DocListCast, Opt, AclSym, AclAddonly, AclEdit, AclReadonly } from "../../fields/Doc";
+import { AclAdmin, AclPrivate, DataSym, Doc, DocListCast, Opt, AclSym, AclAddonly, AclEdit, AclReadonly, DocListCastAsync } from "../../fields/Doc";
import { List } from "../../fields/List";
import { Cast, StrCast } from "../../fields/Types";
import { distributeAcls, GetEffectiveAcl, SharingPermissions, TraceMobx, normalizeEmail } from "../../fields/util";
@@ -189,7 +189,9 @@ export class SharingManager extends React.Component<{}> {
const self = this;
if (group.docsShared) {
if (!user) retry && this.populateUsers().then(() => self.shareWithAddedMember(group, emailId, false));
- else DocListCast(group.docsShared).forEach(doc => Doc.IndexOf(doc, DocListCast(user.sharingDoc[storage])) === -1 && Doc.AddDocToList(user.sharingDoc, storage, doc));
+ else DocListCastAsync(group.docsShared).then(dl => dl?.forEach(doc => {
+ Doc.AddDocToList(user.sharingDoc, storage, doc);
+ }));
}
}
@@ -220,9 +222,9 @@ export class SharingManager extends React.Component<{}> {
const user: ValidatedUser = this.users.find(({ user: { email } }) => email === emailId)!;
if (group.docsShared) {
- DocListCast(group.docsShared).forEach(doc => {
- Doc.IndexOf(doc, DocListCast(user.sharingDoc[storage])) !== -1 && Doc.RemoveDocFromList(user.sharingDoc, storage, doc); // remove the doc only if it is in the list
- });
+ DocListCastAsync(group.docsShared).then(dl => dl?.forEach(doc => {
+ Doc.RemoveDocFromList(user.sharingDoc, storage, doc);
+ }));
}
}