diff --git a/src/modules/room/RoomChat.tsx b/src/modules/room/RoomChat.tsx index 887b2c4..4853380 100644 --- a/src/modules/room/RoomChat.tsx +++ b/src/modules/room/RoomChat.tsx @@ -50,6 +50,7 @@ const RoomChatInner: FC = ({ loginUserName, room }) => { ); }; +// TODO: Back button on small-enough screens (below `md`). const RoomChat: FC = ({ loginUserName, room }) => { const dispatch = useDispatch(); diff --git a/src/modules/room/RoomList.tsx b/src/modules/room/RoomList.tsx index 5ed4762..f280a44 100644 --- a/src/modules/room/RoomList.tsx +++ b/src/modules/room/RoomList.tsx @@ -3,9 +3,13 @@ import { useDispatch } from "react-redux"; import SearchableList from "components/SearchableList"; import RoomListEntry from "modules/room/RoomListEntry"; -import { RoomSliceState, roomGetAll } from "modules/room/slice"; +import { RoomMap, roomGetAll } from "modules/room/slice"; -const RoomList: FC = ({ rooms }) => { +interface Props { + rooms: RoomMap; +} + +const RoomList: FC = ({ rooms }) => { const dispatch = useDispatch(); const onRefresh: ReactEventHandler = (event) => { diff --git a/src/modules/room/RoomsPane.tsx b/src/modules/room/RoomsPane.tsx index dce26af..e29593e 100644 --- a/src/modules/room/RoomsPane.tsx +++ b/src/modules/room/RoomsPane.tsx @@ -5,58 +5,82 @@ import { Switch, Route } from "react-router-dom"; import { decode } from "modules/base64"; import { selectLogin } from "modules/login/slice"; -import { RoomMap, selectAllRooms } from "modules/room/slice"; +import { RoomState, selectAllRooms } from "modules/room/slice"; import RoomBanner from "modules/room/RoomBanner"; import RoomChat from "modules/room/RoomChat"; import RoomList from "modules/room/RoomList"; interface ChatProps { loginUserName: string; - rooms: RoomMap; + roomName?: string; + room?: RoomState; } -interface UrlParams { - roomId: string; -} - -const RoomChatPane: FC = ({ loginUserName, rooms }) => { - const { roomId } = useParams(); - - if (roomId === undefined) { +const RoomChatPane: FC = ({ loginUserName, roomName, room }) => { + if (roomName === undefined) { return ; } - const name = decode(roomId); - const room = rooms[name]; if (room === undefined) { - return ; + return ; } return ; }; -const RoomsPane: FC<{}> = () => { - const { path } = useRouteMatch(); +interface UrlParams { + roomId: string; +} + +const RoomsPaneInner: FC<{}> = () => { const login = useSelector(selectLogin); const rooms = useSelector(selectAllRooms); + const { roomId } = useParams(); + + // When we have not chosen a room, we always show the list. For small screens + // it takes up the whole width, whereas for larger screens it is on the left. + let listClass = "w-full md:w-80 h-full"; + + let name; + let room; + if (roomId !== undefined) { + name = decode(roomId); + room = rooms[name]; + + // When we have chosen a room (even if it does not exist), and the screen is + // not large enough, then we hide the list and show only the chat. + listClass += " hidden md:block"; + } return (
-
+
- - - - - - - - +
); }; +const RoomsPane: FC<{}> = () => { + const { path } = useRouteMatch(); + + return ( + + + + + + + + + ); +}; + export default RoomsPane;