File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
src/components/structures Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -88,6 +88,11 @@ var RoomSubList = React.createClass({
8888 this . setState ( {
8989 sortedList : this . applySearchFilter ( this . props . list , this . props . searchFilter ) ,
9090 } ) ;
91+ this . dispatcherRef = dis . register ( this . onAction ) ;
92+ } ,
93+
94+ componentWillUnmount : function ( ) {
95+ dis . unregister ( this . dispatcherRef ) ;
9196 } ,
9297
9398 componentWillReceiveProps : function ( newProps ) {
@@ -116,6 +121,21 @@ var RoomSubList = React.createClass({
116121 }
117122 } ,
118123
124+ onAction : function ( payload ) {
125+ // XXX: Previously RoomList would forceUpdate whenever on_room_read is dispatched,
126+ // but this is no longer true, so we must do it here (and can apply the small
127+ // optimisation of checking that we care about the room being read).
128+ //
129+ // Ultimately we need to transition to a state pushing flow where something
130+ // explicitly notifies the components concerned that the notif count for a room
131+ // has change (e.g. a Flux store).
132+ if ( payload . action === 'on_room_read' &&
133+ this . props . list . some ( ( r ) => r . roomId === payload . roomId )
134+ ) {
135+ this . forceUpdate ( ) ;
136+ }
137+ } ,
138+
119139 onClick : function ( ev ) {
120140 if ( this . isCollapsableOnClick ( ) ) {
121141 // The header isCollapsable, so the click is to be interpreted as collapse and truncation logic
You can’t perform that action at this time.
0 commit comments