Implement "someone is typing" avatars (#631)
When users are typing, their avatars can be seen instead of "..." in the RoomView StatusBar
This commit is contained in:
parent
f1bb07729f
commit
0c5762b91d
1 changed files with 35 additions and 4 deletions
|
@ -19,6 +19,9 @@ var sdk = require('../../index');
|
||||||
var dis = require("../../dispatcher");
|
var dis = require("../../dispatcher");
|
||||||
var WhoIsTyping = require("../../WhoIsTyping");
|
var WhoIsTyping = require("../../WhoIsTyping");
|
||||||
var MatrixClientPeg = require("../../MatrixClientPeg");
|
var MatrixClientPeg = require("../../MatrixClientPeg");
|
||||||
|
const MemberAvatar = require("../views/avatars/MemberAvatar");
|
||||||
|
|
||||||
|
const TYPING_AVATARS_LIMIT = 2;
|
||||||
|
|
||||||
module.exports = React.createClass({
|
module.exports = React.createClass({
|
||||||
displayName: 'RoomStatusBar',
|
displayName: 'RoomStatusBar',
|
||||||
|
@ -173,10 +176,8 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
if (wantPlaceholder) {
|
if (wantPlaceholder) {
|
||||||
return (
|
return (
|
||||||
<div className="mx_RoomStatusBar_placeholderIndicator">
|
<div className="mx_RoomStatusBar_typingIndicatorAvatars">
|
||||||
<span>.</span>
|
{this._renderTypingIndicatorAvatars(TYPING_AVATARS_LIMIT)}
|
||||||
<span>.</span>
|
|
||||||
<span>.</span>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -184,6 +185,36 @@ module.exports = React.createClass({
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_renderTypingIndicatorAvatars: function(limit) {
|
||||||
|
let users = WhoIsTyping.usersTyping(this.props.room);
|
||||||
|
|
||||||
|
let othersCount = Math.max(users.length - limit, 0);
|
||||||
|
users = users.slice(0, limit);
|
||||||
|
|
||||||
|
let avatars = users.map((u, index) => {
|
||||||
|
let showInitial = othersCount === 0 && index === users.length - 1;
|
||||||
|
return (
|
||||||
|
<MemberAvatar
|
||||||
|
key={u.userId}
|
||||||
|
member={u}
|
||||||
|
width={24}
|
||||||
|
height={24}
|
||||||
|
resizeMethod="crop"
|
||||||
|
defaultToInitialLetter={showInitial}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (othersCount > 0) {
|
||||||
|
avatars.push(
|
||||||
|
<span className="mx_RoomStatusBar_typingIndicatorRemaining">
|
||||||
|
+{othersCount}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return avatars;
|
||||||
|
},
|
||||||
|
|
||||||
// return suitable content for the main (text) part of the status bar.
|
// return suitable content for the main (text) part of the status bar.
|
||||||
_getContent: function() {
|
_getContent: function() {
|
||||||
|
|
Loading…
Reference in a new issue