aboutsummaryrefslogtreecommitdiff
path: root/src/client/util/CurrentUserUtils.ts
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2020-10-10 12:10:48 -0400
committerbobzel <zzzman@gmail.com>2020-10-10 12:10:48 -0400
commitf3d04b73a53d7680092ce925fceede4f910df5bb (patch)
treef5b790ae556d2bdaeaa23c4cd0494c9a2b2e2cf1 /src/client/util/CurrentUserUtils.ts
parentae8dafadcc0c6cea1ac087f17ac84bd302fca39e (diff)
fixes to issues with updating interactively whe groups change. fixes for multiple rapid modifications to list field where values would be overwrriten when sever sendBack stale information. fixes to list.splice() where deleting nothing but adding something didn't result in an addToSet.
Diffstat (limited to 'src/client/util/CurrentUserUtils.ts')
-rw-r--r--src/client/util/CurrentUserUtils.ts14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts
index 580c6040e..694982fea 100644
--- a/src/client/util/CurrentUserUtils.ts
+++ b/src/client/util/CurrentUserUtils.ts
@@ -8,9 +8,9 @@ import { RichTextField } from "../../fields/RichTextField";
import { listSpec } from "../../fields/Schema";
import { SchemaHeaderField } from "../../fields/SchemaHeaderField";
import { ComputedField, ScriptField } from "../../fields/ScriptField";
-import { BoolCast, Cast, NumCast, PromiseValue, StrCast } from "../../fields/Types";
+import { BoolCast, Cast, NumCast, PromiseValue, StrCast, DateCast } from "../../fields/Types";
import { nullAudio } from "../../fields/URLField";
-import { SharingPermissions, UserGroups } from "../../fields/util";
+import { SharingPermissions } from "../../fields/util";
import { Utils } from "../../Utils";
import { DocServer } from "../DocServer";
import { Docs, DocumentOptions, DocUtils } from "../documents/Documents";
@@ -32,6 +32,7 @@ import { Scripting } from "./Scripting";
import { SearchUtil } from "./SearchUtil";
import { SelectionManager } from "./SelectionManager";
import { UndoManager } from "./UndoManager";
+import { SnappingManager } from "./SnappingManager";
export let resolvedPorts: { server: number, socket: number };
@@ -957,8 +958,13 @@ 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;
+ const groups = await DocListCastAsync((doc.globalGroupDatabase as Doc).data);
+ reaction(() => DateCast((doc.globalGroupDatabase as Doc).lastModified),
+ async () => {
+ const groups = await DocListCastAsync((doc.globalGroupDatabase as Doc).data);
+ const mygroups = groups?.filter(group => JSON.parse(StrCast(group.members)).includes(Doc.CurrentUserEmail)) || [];
+ SnappingManager.SetCachedGroups(["Public", ...mygroups?.map(g => StrCast(g.title))]);
+ }, { fireImmediately: true });
doc.system = true;
doc.noviceMode = doc.noviceMode === undefined ? "true" : doc.noviceMode;
doc.title = Doc.CurrentUserEmail;