diff options
author | usodhi <61431818+usodhi@users.noreply.github.com> | 2020-10-08 22:40:39 +0530 |
---|---|---|
committer | usodhi <61431818+usodhi@users.noreply.github.com> | 2020-10-08 22:40:39 +0530 |
commit | 7ae3e17011725b380b9010e7579c7084139b61e5 (patch) | |
tree | 5da5d396deea2d9c0e6b1d20036133a3897a336a /src/client/util/SharingManager.tsx | |
parent | 4508b7feacd4ac1ea8145d3284527b523829606a (diff) | |
parent | f6623a790fbb5df02effebbe9edea69383e0569f (diff) |
Merge branch 'master' of https://github.com/browngraphicslab/Dash-Web into acls_uv
Diffstat (limited to 'src/client/util/SharingManager.tsx')
-rw-r--r-- | src/client/util/SharingManager.tsx | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/client/util/SharingManager.tsx b/src/client/util/SharingManager.tsx index 4aa8d74e4..e789a7867 100644 --- a/src/client/util/SharingManager.tsx +++ b/src/client/util/SharingManager.tsx @@ -132,19 +132,28 @@ export class SharingManager extends React.Component<{}> { populateUsers = async () => { if (!this.populating) { this.populating = true; - runInAction(() => this.users = []); const userList = await RequestPromise.get(Utils.prepend("/getUsers")); const raw = JSON.parse(userList) as User[]; + const sharingDocs: ValidatedUser[] = []; const evaluating = raw.map(async user => { const isCandidate = user.email !== Doc.CurrentUserEmail; if (isCandidate) { - const userSharingDoc = await DocServer.GetRefField(user.sharingDocumentId); - if (userSharingDoc instanceof Doc) { - runInAction(() => this.users.push({ user, sharingDoc: userSharingDoc, userColor: StrCast(userSharingDoc.userColor) })); + const sharingDoc = await DocServer.GetRefField(user.sharingDocumentId); + if (sharingDoc instanceof Doc) { + sharingDocs.push({ user, sharingDoc, userColor: StrCast(sharingDoc.color) }); } } }); - return Promise.all(evaluating).then(() => this.populating = false); + return Promise.all(evaluating).then(() => { + runInAction(() => { + for (let i = 0; i < sharingDocs.length; i++) { + if (!this.users.find(user => user.user.email === sharingDocs[i].user.email)) { + this.users.push(sharingDocs[i]); + } + } + }); + this.populating = false; + }); } } |