Skip to content

Commit

Permalink
Merge pull request #6342 from vector-im/luke/fix-stale-sub-list-notif…
Browse files Browse the repository at this point in the history
…-count-after-room-read

Force update RoomSubList after reading a room
  • Loading branch information
dbkr authored Mar 16, 2018
2 parents 0e2a911 + 7dc82e2 commit 8853496
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/components/structures/RoomSubList.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ var RoomSubList = React.createClass({
this.setState({
sortedList: this.applySearchFilter(this.props.list, this.props.searchFilter),
});
this.dispatcherRef = dis.register(this.onAction);
},

componentWillUnmount: function() {
dis.unregister(this.dispatcherRef);
},

componentWillReceiveProps: function(newProps) {
Expand Down Expand Up @@ -116,6 +121,21 @@ var RoomSubList = React.createClass({
}
},

onAction: function(payload) {
// XXX: Previously RoomList would forceUpdate whenever on_room_read is dispatched,
// but this is no longer true, so we must do it here (and can apply the small
// optimisation of checking that we care about the room being read).
//
// Ultimately we need to transition to a state pushing flow where something
// explicitly notifies the components concerned that the notif count for a room
// has change (e.g. a Flux store).
if (payload.action === 'on_room_read' &&
this.props.list.some((r) => r.roomId === payload.roomId)
) {
this.forceUpdate();
}
},

onClick: function(ev) {
if (this.isCollapsableOnClick()) {
// The header isCollapsable, so the click is to be interpreted as collapse and truncation logic
Expand Down

0 comments on commit 8853496

Please sign in to comment.