mirror of https://github.com/vector-im/riot-web
Sync typing indication with avatar typing indication
Follow the same rules for displaying "is typing" as with the typing avatars.pull/21833/head
parent
91a052f817
commit
7c66d1c867
|
@ -32,17 +32,22 @@ module.exports = {
|
||||||
return whoIsTyping;
|
return whoIsTyping;
|
||||||
},
|
},
|
||||||
|
|
||||||
whoIsTypingString: function(room) {
|
whoIsTypingString: function(room, limit) {
|
||||||
var whoIsTyping = this.usersTypingApartFromMe(room);
|
const whoIsTyping = this.usersTypingApartFromMe(room);
|
||||||
|
const othersCount = limit === undefined ? 0 : Math.max(whoIsTyping.length - limit, 0);
|
||||||
if (whoIsTyping.length == 0) {
|
if (whoIsTyping.length == 0) {
|
||||||
return null;
|
return '';
|
||||||
} else if (whoIsTyping.length == 1) {
|
} else if (whoIsTyping.length == 1) {
|
||||||
return whoIsTyping[0].name + ' is typing';
|
return whoIsTyping[0].name + ' is typing';
|
||||||
|
}
|
||||||
|
const names = whoIsTyping.map(function(m) {
|
||||||
|
return m.name;
|
||||||
|
});
|
||||||
|
if (othersCount) {
|
||||||
|
const other = ' other' + (othersCount > 1 ? 's' : '');
|
||||||
|
return names.slice(0, limit).join(', ') + ' and ' + othersCount + other + ' are typing';
|
||||||
} else {
|
} else {
|
||||||
var names = whoIsTyping.map(function(m) {
|
const lastPerson = names.pop();
|
||||||
return m.name;
|
|
||||||
});
|
|
||||||
var lastPerson = names.shift();
|
|
||||||
return names.join(', ') + ' and ' + lastPerson + ' are typing';
|
return names.join(', ') + ' and ' + lastPerson + ' are typing';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,10 @@ module.exports = React.createClass({
|
||||||
// more interesting)
|
// more interesting)
|
||||||
hasActiveCall: React.PropTypes.bool,
|
hasActiveCall: React.PropTypes.bool,
|
||||||
|
|
||||||
|
// Number of names to display in typing indication. E.g. set to 3, will
|
||||||
|
// result in "X, Y, Z and 100 others are typing."
|
||||||
|
whoIsTypingLimit: React.PropTypes.number,
|
||||||
|
|
||||||
// callback for when the user clicks on the 'resend all' button in the
|
// callback for when the user clicks on the 'resend all' button in the
|
||||||
// 'unsent messages' bar
|
// 'unsent messages' bar
|
||||||
onResendAllClick: React.PropTypes.func,
|
onResendAllClick: React.PropTypes.func,
|
||||||
|
@ -80,7 +84,7 @@ module.exports = React.createClass({
|
||||||
getInitialState: function() {
|
getInitialState: function() {
|
||||||
return {
|
return {
|
||||||
syncState: MatrixClientPeg.get().getSyncState(),
|
syncState: MatrixClientPeg.get().getSyncState(),
|
||||||
whoisTypingString: WhoIsTyping.whoIsTypingString(this.props.room),
|
whoisTypingString: WhoIsTyping.whoIsTypingString(this.props.room, this.props.whoIsTypingLimit),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -127,7 +131,7 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
onRoomMemberTyping: function(ev, member) {
|
onRoomMemberTyping: function(ev, member) {
|
||||||
this.setState({
|
this.setState({
|
||||||
whoisTypingString: WhoIsTyping.whoIsTypingString(this.props.room),
|
whoisTypingString: WhoIsTyping.whoIsTypingString(this.props.room, this.props.whoIsTypingLimit),
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -1531,6 +1531,7 @@ module.exports = React.createClass({
|
||||||
onResize={this.onChildResize}
|
onResize={this.onChildResize}
|
||||||
onVisible={this.onStatusBarVisible}
|
onVisible={this.onStatusBarVisible}
|
||||||
onHidden={this.onStatusBarHidden}
|
onHidden={this.onStatusBarHidden}
|
||||||
|
whoIsTypingLimit={2}
|
||||||
/>;
|
/>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue