Display message when user wants to choose existing username (Fixes: #16)

This commit is contained in:
Mario Orlicky 2016-11-18 23:18:16 +01:00
parent 4dc0ec07b8
commit 69fbd31abc
3 changed files with 14 additions and 4 deletions

View file

@ -26,11 +26,18 @@ Template.editProfilePopup.events({
'profile.fullname': fullname,
'profile.initials': initials,
}});
// XXX We should report the error to the user.
if (username !== Meteor.user().username) {
Meteor.call('setUsername', username);
}
Popup.back();
Meteor.call('setUsername', username, function(error) {
const messageElement = tpl.$('.username-taken');
if (error) {
messageElement.show();
} else {
messageElement.hide();
Popup.back();
}
});
} else Popup.back();
},
});