mirror of
https://github.com/element-hq/element-web.git
synced 2024-11-29 21:59:40 +03:00
Added updating of count when room tile notification state changed
This commit is contained in:
parent
ee73bc3aa4
commit
2cf2df20f6
1 changed files with 40 additions and 26 deletions
|
@ -82,11 +82,15 @@ var RoomSubList = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
getInitialState: function() {
|
getInitialState: function() {
|
||||||
|
var subListNotifications = this.roomNotificationCount();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
hidden: this.props.startAsHidden || false,
|
hidden: this.props.startAsHidden || false,
|
||||||
capTruncate: this.props.list.length > TRUNCATE_AT,
|
capTruncate: this.props.list.length > TRUNCATE_AT,
|
||||||
truncateAt: this.props.list.length > TRUNCATE_AT ? TRUNCATE_AT : -1,
|
truncateAt: this.props.list.length > TRUNCATE_AT ? TRUNCATE_AT : -1,
|
||||||
sortedList: [],
|
sortedList: [],
|
||||||
|
subListNotifCount: subListNotifications[0],
|
||||||
|
subListNotifHighlight: subListNotifications[1],
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -121,30 +125,35 @@ var RoomSubList = React.createClass({
|
||||||
|
|
||||||
if (this.state.hidden && (this.state.capTruncate && isTruncatable)) {
|
if (this.state.hidden && (this.state.capTruncate && isTruncatable)) {
|
||||||
isHidden = false;
|
isHidden = false;
|
||||||
this.setState({ hidden : isHidden });
|
this.setState({
|
||||||
this.setState({ capTruncate : true });
|
hidden : isHidden,
|
||||||
// Show truncated list
|
capTruncate : true,
|
||||||
this.setState({ truncateAt : TRUNCATE_AT });
|
truncateAt : TRUNCATE_AT
|
||||||
} else if ((!this.state.hidden && this.state.capTruncate) ||
|
});
|
||||||
(this.state.hidden && (this.state.capTruncate && !isTruncatable))) {
|
} else if ((!this.state.hidden && this.state.capTruncate)
|
||||||
|
|| (this.state.hidden && (this.state.capTruncate && !isTruncatable)))
|
||||||
|
{
|
||||||
isHidden = false;
|
isHidden = false;
|
||||||
this.setState({ hidden : isHidden });
|
this.setState({
|
||||||
this.setState({ capTruncate : false });
|
hidden : isHidden,
|
||||||
// Show full list
|
capTruncate : false,
|
||||||
this.setState({ truncateAt : -1 });
|
truncateAt : -1
|
||||||
|
});
|
||||||
} else if (!this.state.hidden && !this.state.capTruncate) {
|
} else if (!this.state.hidden && !this.state.capTruncate) {
|
||||||
isHidden = true;
|
isHidden = true;
|
||||||
this.setState({ hidden : isHidden });
|
this.setState({
|
||||||
this.setState({ capTruncate : true });
|
hidden : isHidden,
|
||||||
// Truncated list
|
capTruncate : true,
|
||||||
this.setState({ truncateAt : TRUNCATE_AT });
|
truncateAt : TRUNCATE_AT
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
// Catch any weird states the system gets into
|
// Catch any weird states the system gets into
|
||||||
isHidden = false;
|
isHidden = false;
|
||||||
this.setState({ hidden : isHidden });
|
this.setState({
|
||||||
this.setState({ capTruncate : true });
|
hidden : isHidden,
|
||||||
// Show truncated list
|
capTruncate : true,
|
||||||
this.setState({ truncateAt : TRUNCATE_AT });
|
truncateAt : TRUNCATE_AT
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.props.onShowMoreRooms();
|
this.props.onShowMoreRooms();
|
||||||
|
@ -230,7 +239,7 @@ var RoomSubList = React.createClass({
|
||||||
var subListHighlight = false;
|
var subListHighlight = false;
|
||||||
var cli = MatrixClientPeg.get();
|
var cli = MatrixClientPeg.get();
|
||||||
|
|
||||||
this.state.sortedList.map(function(room) {
|
this.props.list.map(function(room) {
|
||||||
var roomNotifState = RoomNotifs.getRoomNotifsState(room.roomId);
|
var roomNotifState = RoomNotifs.getRoomNotifsState(room.roomId);
|
||||||
var highlight = room.getUnreadNotificationCount('highlight') > 0 || self.props.label === 'Invites';
|
var highlight = room.getUnreadNotificationCount('highlight') > 0 || self.props.label === 'Invites';
|
||||||
var notificationCount = room.getUnreadNotificationCount();
|
var notificationCount = room.getUnreadNotificationCount();
|
||||||
|
@ -250,6 +259,14 @@ var RoomSubList = React.createClass({
|
||||||
return [subListCount, subListHighlight];
|
return [subListCount, subListHighlight];
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_updateSubListCount: function() {
|
||||||
|
var subListNotifications = this.roomNotificationCount();
|
||||||
|
this.setState({
|
||||||
|
subListNotifCount: subListNotifications[0],
|
||||||
|
subListNotifHighlight: subListNotifications[1]
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
moveRoomTile: function(room, atIndex) {
|
moveRoomTile: function(room, atIndex) {
|
||||||
if (debug) console.log("moveRoomTile: id " + room.roomId + ", atIndex " + atIndex);
|
if (debug) console.log("moveRoomTile: id " + room.roomId + ", atIndex " + atIndex);
|
||||||
//console.log("moveRoomTile before: " + JSON.stringify(this.state.rooms));
|
//console.log("moveRoomTile before: " + JSON.stringify(this.state.rooms));
|
||||||
|
@ -357,6 +374,7 @@ var RoomSubList = React.createClass({
|
||||||
unread={ Unread.doesRoomHaveUnreadMessages(room) }
|
unread={ Unread.doesRoomHaveUnreadMessages(room) }
|
||||||
highlight={ room.getUnreadNotificationCount('highlight') > 0 || self.props.label === 'Invites' }
|
highlight={ room.getUnreadNotificationCount('highlight') > 0 || self.props.label === 'Invites' }
|
||||||
isInvite={ self.props.label === 'Invites' }
|
isInvite={ self.props.label === 'Invites' }
|
||||||
|
refreshSubList={ self._updateSubListCount }
|
||||||
incomingCall={ self.props.incomingCall && (self.props.incomingCall.roomId === room.roomId) ? self.props.incomingCall : null } />
|
incomingCall={ self.props.incomingCall && (self.props.incomingCall.roomId === room.roomId) ? self.props.incomingCall : null } />
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -365,10 +383,6 @@ var RoomSubList = React.createClass({
|
||||||
_getHeaderJsx: function() {
|
_getHeaderJsx: function() {
|
||||||
var TintableSvg = sdk.getComponent("elements.TintableSvg");
|
var TintableSvg = sdk.getComponent("elements.TintableSvg");
|
||||||
|
|
||||||
var subListNotifications = this.roomNotificationCount();
|
|
||||||
var subListNotificationsCount = subListNotifications[0];
|
|
||||||
var subListNotificationsHighlight = subListNotifications[1];
|
|
||||||
|
|
||||||
var roomCount = this.props.list.length > 0 ? this.props.list.length : '';
|
var roomCount = this.props.list.length > 0 ? this.props.list.length : '';
|
||||||
var isTruncatable = this.props.list.length > TRUNCATE_AT;
|
var isTruncatable = this.props.list.length > TRUNCATE_AT;
|
||||||
if (!this.state.hidden && this.state.capTruncate && isTruncatable) {
|
if (!this.state.hidden && this.state.capTruncate && isTruncatable) {
|
||||||
|
@ -384,12 +398,12 @@ var RoomSubList = React.createClass({
|
||||||
|
|
||||||
var badgeClasses = classNames({
|
var badgeClasses = classNames({
|
||||||
'mx_RoomSubList_badge': true,
|
'mx_RoomSubList_badge': true,
|
||||||
'mx_RoomSubList_badgeHighlight': subListNotificationsHighlight,
|
'mx_RoomSubList_badgeHighlight': this.state.subListNotifHighlight,
|
||||||
});
|
});
|
||||||
|
|
||||||
var badge;
|
var badge;
|
||||||
if (subListNotificationsCount > 0) {
|
if (this.state.subListNotifCount > 0) {
|
||||||
badge = <div className={badgeClasses}>{subListNotificationsCount}</div>;
|
badge = <div className={badgeClasses}>{this.state.subListNotifCount}</div>;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
Loading…
Reference in a new issue