mirror of
https://github.com/screego/server.git
synced 2026-08-30 17:33:30 +08:00
Prefill room ID from url
This commit is contained in:
committed by
Jannis Mattheis
parent
d71c303df7
commit
ab187c14f3
@@ -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';
|
||||
@@ -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 = () =>
|
||||
|
||||
+1
-1
@@ -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('&')
|
||||
|
||||
Reference in New Issue
Block a user