Support switching rooms

pull/21833/head
Travis Ralston 2020-05-11 16:29:32 -06:00
parent 715dd7e1b6
commit 6bdcbd0f3d
1 changed files with 13 additions and 1 deletions

View File

@ -24,6 +24,8 @@ import { RovingTabIndexWrapper } from "../../../accessibility/RovingTabIndex";
import AccessibleButton from "../../views/elements/AccessibleButton"; import AccessibleButton from "../../views/elements/AccessibleButton";
import RoomAvatar from "../../views/avatars/RoomAvatar"; import RoomAvatar from "../../views/avatars/RoomAvatar";
import Tooltip from "../../views/elements/Tooltip"; import Tooltip from "../../views/elements/Tooltip";
import dis from '../../../dispatcher';
import { Key } from "../../../Keyboard";
interface IProps { interface IProps {
room: Room; room: Room;
@ -31,7 +33,6 @@ interface IProps {
// TODO: Allow faslifying counts (for invites and stuff) // TODO: Allow faslifying counts (for invites and stuff)
// TODO: Transparency? // TODO: Transparency?
// TODO: Incoming call? // TODO: Incoming call?
// TODO: onClick
} }
interface IState { interface IState {
@ -70,6 +71,16 @@ export default class RoomTile2 extends React.Component<IProps, IState> {
this.setState({hover: false}); this.setState({hover: false});
}; };
private onTileClick = (ev: React.KeyboardEvent) => {
dis.dispatch({
action: 'view_room',
// TODO: Support show_room_tile in new room list
show_room_tile: true, // make sure the room is visible in the list
room_id: this.props.room.roomId,
clear_search: (ev && (ev.key === Key.ENTER || ev.key === Key.SPACE)),
});
};
public render(): React.ReactElement { public render(): React.ReactElement {
// TODO: Collapsed state // TODO: Collapsed state
// TODO: Invites // TODO: Invites
@ -122,6 +133,7 @@ export default class RoomTile2 extends React.Component<IProps, IState> {
className={classes} className={classes}
onMouseEnter={this.onTileMouseEnter} onMouseEnter={this.onTileMouseEnter}
onMouseLeave={this.onTileMouseLeave} onMouseLeave={this.onTileMouseLeave}
onClick={this.onTileClick}
role="treeitem" role="treeitem"
> >
<div className={avatarClasses}> <div className={avatarClasses}>