diff --git a/app/containers/MessageBox/index.js b/app/containers/MessageBox/index.js index af1a196d..be054279 100644 --- a/app/containers/MessageBox/index.js +++ b/app/containers/MessageBox/index.js @@ -212,11 +212,21 @@ export default class MessageBox extends React.PureComponent { }); } + _getFixedMentions(keyword) { + if ('all'.indexOf(keyword) !== -1) { + this.users = [{ _id: -1, username: 'all', desc: 'all' }, ...this.users]; + } + if ('here'.indexOf(keyword) !== -1) { + this.users = [{ _id: -2, username: 'here', desc: 'active users' }, ...this.users]; + } + } + async _getUsers(keyword) { this.users = database.objects('users'); if (keyword) { this.users = this.users.filtered('username CONTAINS[c] $0', keyword); } + this._getFixedMentions(keyword); this.setState({ mentions: this.users.slice() }); const usernames = []; @@ -244,8 +254,9 @@ export default class MessageBox extends React.PureComponent { console.log('spotlight canceled'); } finally { delete this.oldPromise; - this.users = database.objects('users').filtered('username CONTAINS[c] $0', keyword); - this.setState({ mentions: this.users.slice() }); + this.users = database.objects('users').filtered('username CONTAINS[c] $0', keyword).slice(); + this._getFixedMentions(keyword); + this.setState({ mentions: this.users }); } } @@ -345,20 +356,34 @@ export default class MessageBox extends React.PureComponent { this.component.setNativeProps({ text: newText }); this.setState({ text: newText }); } - renderMentionItem = item => ( + renderFixedMentionItem = item => ( this._onPressMention(item)} > - - {item.username || item.name } + {item.username} + Notify {item.desc} in this room ) + renderMentionItem = (item) => { + if (item.username === 'all' || item.username === 'here') { + return this.renderFixedMentionItem(item); + } + return ( + this._onPressMention(item)} + > + + {item.username || item.name } + + ); + } renderEmoji() { const emojiContainer = ( diff --git a/app/containers/MessageBox/style.js b/app/containers/MessageBox/style.js index bee61609..6bb79baa 100644 --- a/app/containers/MessageBox/style.js +++ b/app/containers/MessageBox/style.js @@ -85,5 +85,10 @@ export default StyleSheet.create({ borderTopColor: '#ECECEC', borderTopWidth: 1, backgroundColor: '#fff' + }, + fixedMentionAvatar: { + fontWeight: 'bold', + textAlign: 'center', + width: 46 } });