Просмотр исходного кода

Merge pull request #8704 from overleaf/ta-multiple-invites-fix

Fix UX on Duplicate Group Invites

GitOrigin-RevId: e51c406d578b130972024065f9b8bdb2503944a9
Timothée Alby 4 лет назад
Родитель
Сommit
5bfb1b8781

+ 1 - 0
services/web/app/src/Features/Subscription/TeamInvitesHandler.js

@@ -174,6 +174,7 @@ function createInvite(subscription, email, inviter, callback) {
       )
 
       if (invite) {
+        invite = invite.toObject()
         invite.sentAt = new Date()
       } else {
         invite = {

+ 6 - 1
services/web/frontend/js/main/user-membership.js

@@ -56,7 +56,12 @@ App.controller('UserMembershipController', function ($scope, queuedHttp) {
           $scope.inputs.addMembers.inflightCount -= 1
           const { data } = response
           if (data.user != null) {
-            $scope.users.push(data.user)
+            const alreadyListed = $scope.users.find(
+              scopeUser => scopeUser.email === data.user.email
+            )
+            if (!alreadyListed) {
+              $scope.users.push(data.user)
+            }
           }
           return ($scope.inputs.addMembers.content = '')
         })

+ 2 - 0
services/web/test/unit/src/Subscription/TeamInvitesHandlerTests.js

@@ -23,6 +23,8 @@ describe('TeamInvitesHandler', function () {
       email: 'jorah@example.com',
       token: this.token,
     }
+    // ensure teamInvite can be converted from Document to Object
+    this.teamInvite.toObject = () => this.teamInvite
 
     this.subscription = {
       id: '55153a8014829a865bbf700d',