Tidy up code
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
d7ca374991
commit
f5d490ee78
2 changed files with 16 additions and 12 deletions
|
@ -130,11 +130,6 @@ export default class RoomSubList extends React.PureComponent {
|
||||||
this.props.list.some((r) => r.roomId === payload.room_id)
|
this.props.list.some((r) => r.roomId === payload.room_id)
|
||||||
) {
|
) {
|
||||||
this.onClick();
|
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,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -226,19 +226,23 @@ export default createReactClass({
|
||||||
this.forceUpdate();
|
this.forceUpdate();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'scroll_room_tile':
|
|
||||||
case 'view_room':
|
case 'view_room':
|
||||||
// when the room is selected make sure its tile is visible, for breadcrumbs/keyboard shortcuts
|
// when the room is selected make sure its tile is visible, for breadcrumbs/keyboard shortcut access
|
||||||
if (payload.room_id === this.props.room.roomId && this._roomTile.current) {
|
if (payload.room_id === this.props.room.roomId) {
|
||||||
this._roomTile.current.scrollIntoView({
|
this._scrollIntoView();
|
||||||
block: "nearest",
|
|
||||||
behavior: "auto",
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_scrollIntoView: function() {
|
||||||
|
if (!this._roomTile.current) return;
|
||||||
|
this._roomTile.current.scrollIntoView({
|
||||||
|
block: "nearest",
|
||||||
|
behavior: "auto",
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
_onActiveRoomChange: function() {
|
_onActiveRoomChange: function() {
|
||||||
this.setState({
|
this.setState({
|
||||||
selected: this.props.room.roomId === RoomViewStore.getRoomId(),
|
selected: this.props.room.roomId === RoomViewStore.getRoomId(),
|
||||||
|
@ -272,6 +276,11 @@ export default createReactClass({
|
||||||
statusUser.on("User._unstable_statusMessage", this._onStatusMessageCommitted);
|
statusUser.on("User._unstable_statusMessage", this._onStatusMessageCommitted);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// when we're first rendered (or our sublist is expanded) make sure we are visible if we're active
|
||||||
|
if (this.state.selected) {
|
||||||
|
this._scrollIntoView();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillUnmount: function() {
|
componentWillUnmount: function() {
|
||||||
|
|
Loading…
Reference in a new issue