Use single state to set both avatars and typing notif
This commit is contained in:
parent
ad2710ec5d
commit
cc69e982a7
2 changed files with 10 additions and 14 deletions
|
@ -48,8 +48,7 @@ module.exports = {
|
||||||
return whoIsTyping;
|
return whoIsTyping;
|
||||||
},
|
},
|
||||||
|
|
||||||
whoIsTypingString: function(room, limit) {
|
whoIsTypingString: function(whoIsTyping, limit) {
|
||||||
const whoIsTyping = this.usersTypingApartFromMe(room);
|
|
||||||
const othersCount = limit === undefined ?
|
const othersCount = limit === undefined ?
|
||||||
0 : Math.max(whoIsTyping.length - limit, 0);
|
0 : Math.max(whoIsTyping.length - limit, 0);
|
||||||
if (whoIsTyping.length == 0) {
|
if (whoIsTyping.length == 0) {
|
||||||
|
|
|
@ -89,10 +89,7 @@ module.exports = React.createClass({
|
||||||
getInitialState: function() {
|
getInitialState: function() {
|
||||||
return {
|
return {
|
||||||
syncState: MatrixClientPeg.get().getSyncState(),
|
syncState: MatrixClientPeg.get().getSyncState(),
|
||||||
whoisTypingString: WhoIsTyping.whoIsTypingString(
|
usersTyping: WhoIsTyping.usersTypingApartFromMe(this.props.room),
|
||||||
this.props.room,
|
|
||||||
this.props.whoIsTypingLimit
|
|
||||||
),
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -141,10 +138,7 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
onRoomMemberTyping: function(ev, member) {
|
onRoomMemberTyping: function(ev, member) {
|
||||||
this.setState({
|
this.setState({
|
||||||
whoisTypingString: WhoIsTyping.whoIsTypingString(
|
usersTyping: WhoIsTyping.usersTypingApartFromMe(this.props.room),
|
||||||
this.props.room,
|
|
||||||
this.props.whoIsTypingLimit
|
|
||||||
),
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -153,7 +147,7 @@ module.exports = React.createClass({
|
||||||
// indicate other sizes.
|
// indicate other sizes.
|
||||||
_getSize: function(state, props) {
|
_getSize: function(state, props) {
|
||||||
if (state.syncState === "ERROR" ||
|
if (state.syncState === "ERROR" ||
|
||||||
state.whoisTypingString ||
|
(state.usersTyping.length > 0) ||
|
||||||
props.numUnreadMessages ||
|
props.numUnreadMessages ||
|
||||||
!props.atEndOfLiveTimeline ||
|
!props.atEndOfLiveTimeline ||
|
||||||
props.hasActiveCall) {
|
props.hasActiveCall) {
|
||||||
|
@ -220,7 +214,7 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
_renderTypingIndicatorAvatars: function(limit) {
|
_renderTypingIndicatorAvatars: function(limit) {
|
||||||
let users = WhoIsTyping.usersTypingApartFromMe(this.props.room);
|
let users = this.state.usersTyping;
|
||||||
|
|
||||||
let othersCount = Math.max(users.length - limit, 0);
|
let othersCount = Math.max(users.length - limit, 0);
|
||||||
users = users.slice(0, limit);
|
users = users.slice(0, limit);
|
||||||
|
@ -324,7 +318,10 @@ module.exports = React.createClass({
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
var typingString = this.state.whoisTypingString;
|
const typingString = WhoIsTyping.whoIsTypingString(
|
||||||
|
this.state.usersTyping,
|
||||||
|
this.props.whoIsTypingLimit
|
||||||
|
);
|
||||||
if (typingString) {
|
if (typingString) {
|
||||||
return (
|
return (
|
||||||
<div className="mx_RoomStatusBar_typingBar">
|
<div className="mx_RoomStatusBar_typingBar">
|
||||||
|
@ -347,7 +344,7 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
var content = this._getContent();
|
var content = this._getContent();
|
||||||
var indicator = this._getIndicator(this.state.whoisTypingString !== null);
|
var indicator = this._getIndicator(this.state.usersTyping.length > 0);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="mx_RoomStatusBar">
|
<div className="mx_RoomStatusBar">
|
||||||
|
|
Loading…
Reference in a new issue