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

Fix UX on Duplicate Group Invites

GitOrigin-RevId: e51c406d578b130972024065f9b8bdb2503944a9
This commit is contained in:
Timothée Alby 2022-07-07 10:01:47 +02:00 committed by Copybot
parent e48c23546e
commit 5bfb1b8781
3 changed files with 9 additions and 1 deletions

View file

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

View file

@ -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 = '')
})

View file

@ -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',