Skip to content

Commit

Permalink
PLT-2408 Adds here mention for online users (mattermost#3619)
Browse files Browse the repository at this point in the history
* Added @here mention that notifies online users

* Fixed existing race condition that would sometime cause clients to miss mention count changes

* Added missing localization strings

* Prevent @here from mentioning the user who posted it
  • Loading branch information
jwilander committed Jul 21, 2016
1 parent f73bded commit 482d49d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
12 changes: 12 additions & 0 deletions components/suggestion/at_mention_provider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ class AtMentionSuggestion extends Suggestion {
/>
);
icon = <i className='mention__image fa fa-users fa-2x'/>;
} else if (user.username === 'here') {
username = 'here';
description = (
<FormattedMessage
id='suggestion.mention.here'
defaultMessage='Notifies everyone in the channel and online'
/>
);
icon = <i className='mention__image fa fa-users fa-2x'/>;
} else {
username = user.username;

Expand Down Expand Up @@ -126,6 +135,9 @@ export default class AtMentionProvider {
if ('all'.startsWith(prefix)) {
filtered.push({username: 'all'});
}
if ('here'.startsWith(prefix)) {
filtered.push({username: 'here'});
}
}

filtered.sort((a, b) => {
Expand Down
1 change: 1 addition & 0 deletions i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1410,6 +1410,7 @@
"sso_signup.team_error": "Please enter a team name",
"suggestion.mention.all": "Notifies everyone in the channel, use in {townsquare} to notify the whole team",
"suggestion.mention.channel": "Notifies everyone in the channel",
"suggestion.mention.here": "Notifies everyone in the channel and online",
"suggestion.search.private": "Private Groups",
"suggestion.search.public": "Public Channels",
"team_export_tab.download": "download",
Expand Down
2 changes: 1 addition & 1 deletion utils/constants.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export const Constants = {
ONLINE: 'online'
},

SPECIAL_MENTIONS: ['all', 'channel'],
SPECIAL_MENTIONS: ['all', 'channel', 'here'],
CHARACTER_LIMIT: 4000,
IMAGE_TYPES: ['jpg', 'gif', 'bmp', 'png', 'jpeg'],
AUDIO_TYPES: ['mp3', 'wav', 'wma', 'm4a', 'flac', 'aac', 'ogg'],
Expand Down
1 change: 1 addition & 0 deletions utils/text_formatting.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ function highlightCurrentMentions(text, tokens) {
let output = text;

const mentionKeys = UserStore.getCurrentMentionKeys();
mentionKeys.push('@here');

// look for any existing tokens which are self mentions and should be highlighted
var newTokens = new Map();
Expand Down

0 comments on commit 482d49d

Please sign in to comment.