@all & @here mention (#200)
This commit is contained in:
parent
c81182c9cf
commit
c86e06afa0
|
@ -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,7 +356,20 @@ export default class MessageBox extends React.PureComponent {
|
|||
this.component.setNativeProps({ text: newText });
|
||||
this.setState({ text: newText });
|
||||
}
|
||||
renderMentionItem = item => (
|
||||
renderFixedMentionItem = item => (
|
||||
<TouchableOpacity
|
||||
style={styles.mentionItem}
|
||||
onPress={() => this._onPressMention(item)}
|
||||
>
|
||||
<Text style={styles.fixedMentionAvatar}>{item.username}</Text>
|
||||
<Text>Notify {item.desc} in this room</Text>
|
||||
</TouchableOpacity>
|
||||
)
|
||||
renderMentionItem = (item) => {
|
||||
if (item.username === 'all' || item.username === 'here') {
|
||||
return this.renderFixedMentionItem(item);
|
||||
}
|
||||
return (
|
||||
<TouchableOpacity
|
||||
style={styles.mentionItem}
|
||||
onPress={() => this._onPressMention(item)}
|
||||
|
@ -358,7 +382,8 @@ export default class MessageBox extends React.PureComponent {
|
|||
/>
|
||||
<Text>{item.username || item.name }</Text>
|
||||
</TouchableOpacity>
|
||||
)
|
||||
);
|
||||
}
|
||||
renderEmoji() {
|
||||
const emojiContainer = (
|
||||
<View style={styles.emojiContainer}>
|
||||
|
|
|
@ -85,5 +85,10 @@ export default StyleSheet.create({
|
|||
borderTopColor: '#ECECEC',
|
||||
borderTopWidth: 1,
|
||||
backgroundColor: '#fff'
|
||||
},
|
||||
fixedMentionAvatar: {
|
||||
fontWeight: 'bold',
|
||||
textAlign: 'center',
|
||||
width: 46
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue