From f3d04b73a53d7680092ce925fceede4f910df5bb Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Sat, 10 Oct 2020 12:10:48 -0400
Subject: 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.

---
 src/client/util/GroupManager.tsx | 5 +++++
 1 file changed, 5 insertions(+)

(limited to 'src/client/util/GroupManager.tsx')

diff --git a/src/client/util/GroupManager.tsx b/src/client/util/GroupManager.tsx
index 63e2a8024..cc1d45a58 100644
--- a/src/client/util/GroupManager.tsx
+++ b/src/client/util/GroupManager.tsx
@@ -13,6 +13,7 @@ import "./GroupManager.scss";
 import { GroupMemberView } from "./GroupMemberView";
 import { SharingManager, User } from "./SharingManager";
 import { listSpec } from "../../fields/Schema";
+import { DateField } from "../../fields/DateField";
 
 /**
  * Interface for options for the react-select component
@@ -144,6 +145,7 @@ export class GroupManager extends React.Component<{}> {
      */
     addGroup(groupDoc: Doc): boolean {
         if (this.GroupManagerDoc) {
+            this.GroupManagerDoc.lastModified = new DateField;
             Doc.AddDocToList(this.GroupManagerDoc, "data", groupDoc);
             return true;
         }
@@ -158,6 +160,7 @@ export class GroupManager extends React.Component<{}> {
     deleteGroup(group: Doc): boolean {
         if (group) {
             if (this.GroupManagerDoc && this.hasEditAccess(group)) {
+                this.GroupManagerDoc.lastModified = new DateField;
                 Doc.RemoveDocFromList(this.GroupManagerDoc, "data", group);
                 SharingManager.Instance.removeGroup(group);
                 const members = JSON.parse(StrCast(group.members));
@@ -184,6 +187,7 @@ export class GroupManager extends React.Component<{}> {
             const memberList = JSON.parse(StrCast(groupDoc.members));
             !memberList.includes(email) && memberList.push(email);
             groupDoc.members = JSON.stringify(memberList);
+            this.GroupManagerDoc && (this.GroupManagerDoc.lastModified = new DateField);
             SharingManager.Instance.shareWithAddedMember(groupDoc, email);
         }
     }
@@ -200,6 +204,7 @@ export class GroupManager extends React.Component<{}> {
             if (index !== -1) {
                 const user = memberList.splice(index, 1)[0];
                 groupDoc.members = JSON.stringify(memberList);
+                this.GroupManagerDoc && (this.GroupManagerDoc.lastModified = new DateField);
                 SharingManager.Instance.removeMember(groupDoc, email);
             }
         }
-- 
cgit v1.2.3-70-g09d2

