Skip to content

Commit

Permalink
Prefill room ID from url
Browse files Browse the repository at this point in the history
  • Loading branch information
maximbaz authored and jmattheis committed Jan 11, 2021
1 parent d71c303 commit ab187c1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion ui/src/RoomManage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
import {FCreateRoom, UseRoom} from './useRoom';
import {RoomMode, UIConfig} from './message';
import {randomRoomName} from './name';
import {getRoomFromURL} from './useRoomID';
import HelpIcon from '@material-ui/icons/Help';
import logo from './logo.svg';
import {UseConfig} from './useConfig';
Expand All @@ -38,7 +39,9 @@ const defaultMode = (authMode: UIConfig['authMode'], loggedIn: boolean): RoomMod
};

const CreateRoom = ({room, config}: Pick<UseRoom, 'room'> & {config: UIConfig}) => {
const [id, setId] = React.useState(randomRoomName);
const [id, setId] = React.useState(
() => getRoomFromURL(window.location.search) ?? randomRoomName()
);
const [mode, setMode] = React.useState<RoomMode>(defaultMode(config.authMode, config.loggedIn));
const [ownerLeave, setOwnerLeave] = React.useState(true);
const submit = () =>
Expand Down
2 changes: 1 addition & 1 deletion ui/src/useRoomID.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

const getRoomFromURL = (search: string): string | undefined =>
export const getRoomFromURL = (search: string): string | undefined =>
search
.slice(1)
.split('&')
Expand Down

0 comments on commit ab187c1

Please sign in to comment.