diff options
-rw-r--r-- | client/components/users/userHeader.jade | 2 | ||||
-rw-r--r-- | client/components/users/userHeader.js | 15 | ||||
-rwxr-xr-x | i18n/en.i18n.json | 1 | ||||
-rw-r--r-- | models/cardComments.js | 6 |
4 files changed, 20 insertions, 4 deletions
diff --git a/client/components/users/userHeader.jade b/client/components/users/userHeader.jade index 21c3c382..f7f6222a 100644 --- a/client/components/users/userHeader.jade +++ b/client/components/users/userHeader.jade @@ -28,6 +28,8 @@ template(name="editProfilePopup") input.js-profile-fullname(type="text" value=profile.fullname autofocus) label | {{_ 'username'}} + span.error.hide.username-taken + | {{_ 'error-username-taken'}} input.js-profile-username(type="text" value=username) label | {{_ 'initials'}} diff --git a/client/components/users/userHeader.js b/client/components/users/userHeader.js index 1f2f1d9b..1c390395 100644 --- a/client/components/users/userHeader.js +++ b/client/components/users/userHeader.js @@ -27,11 +27,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(); }, }); diff --git a/i18n/en.i18n.json b/i18n/en.i18n.json index 4697b536..6e2098c4 100755 --- a/i18n/en.i18n.json +++ b/i18n/en.i18n.json @@ -171,6 +171,7 @@ "error-user-doesNotExist": "This user does not exist", "error-user-notAllowSelf": "This action on self is not allowed", "error-user-notCreated": "This user is not created", + "error-username-taken": "This username is already taken", "export-board": "Export board", "filter": "Filter", "filter-cards": "Filter Cards", diff --git a/models/cardComments.js b/models/cardComments.js index ce6edf3c..070c148e 100644 --- a/models/cardComments.js +++ b/models/cardComments.js @@ -57,6 +57,12 @@ CardComments.helpers({ CardComments.hookOptions.after.update = { fetchPrevious: false }; if (Meteor.isServer) { + // Comments are often fetched within a card, so we create an index to make these + // queries more efficient. + Meteor.startup(() => { + CardComments._collection._ensureIndex({ cardId: 1, createdAt: -1 }); + }); + CardComments.after.insert((userId, doc) => { Activities.insert({ userId, |