open room sublist when using alt-arrows to navigate into it, refire scroll event

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
pull/21833/head
Michael Telatynski 2020-03-19 22:07:22 +00:00
parent 7d28137cfd
commit d7ca374991
2 changed files with 26 additions and 11 deletions

View File

@ -111,17 +111,31 @@ export default class RoomSubList extends React.PureComponent {
}
onAction = (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();
switch (payload.action) {
case 'on_room_read':
// 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 (this.props.list.some((r) => r.roomId === payload.roomId)) {
this.forceUpdate();
}
break;
case 'view_room':
if (this.state.hidden && !this.props.forceExpand &&
this.props.list.some((r) => r.roomId === payload.room_id)
) {
this.onClick();
// re-fire to scroll the room tile, normally it catches `view_room` but here it wasn't rendered yet.
dis.dispatch({
action: 'scroll_room_tile',
room_id: payload.room_id,
});
}
}
};

View File

@ -226,6 +226,7 @@ export default createReactClass({
this.forceUpdate();
break;
case 'scroll_room_tile':
case 'view_room':
// when the room is selected make sure its tile is visible, for breadcrumbs/keyboard shortcuts
if (payload.room_id === this.props.room.roomId && this._roomTile.current) {