Improve zeroing of RoomList notification badges

Use an action and force an update when zeroing the number of notifications in a room. This is better than waiting for a `render` to happen at some point. This will hopefully fix https://github.com/vector-im/riot-web/issues/3257
pull/21833/head
Luke Barnard 2017-03-28 10:38:57 +01:00
parent aa486b605d
commit f4dc7ae8b1
2 changed files with 10 additions and 3 deletions

View File

@ -476,9 +476,10 @@ var TimelinePanel = React.createClass({
// if we are scrolled to the bottom, do a quick-reset of our unreadNotificationCount // if we are scrolled to the bottom, do a quick-reset of our unreadNotificationCount
// to avoid having to wait from the remote echo from the homeserver. // to avoid having to wait from the remote echo from the homeserver.
if (this.isAtEndOfLiveTimeline()) { if (this.isAtEndOfLiveTimeline()) {
this.props.timelineSet.room.setUnreadNotificationCount('total', 0); dis.dispatch({
this.props.timelineSet.room.setUnreadNotificationCount('highlight', 0); action: 'on_room_read',
// XXX: i'm a bit surprised we don't have to emit an event or dispatch to get this picked up room: this.props.timelineSet.room,
});
} }
var currentReadUpToEventId = this._getCurrentReadReceipt(true); var currentReadUpToEventId = this._getCurrentReadReceipt(true);

View File

@ -96,6 +96,12 @@ module.exports = React.createClass({
}); });
} }
break; break;
case 'on_room_read':
payload.room.setUnreadNotificationCount('total', 0);
payload.room.setUnreadNotificationCount('highlight', 0);
// Force an update because this state is too deep to cause an update
this.forceUpdate();
break;
} }
}, },