@@ -14,7 +14,15 @@ See the License for the specific language governing permissions and
1414limitations under the License.
1515*/
1616
17- import React , { useState , useCallback } from "react" ;
17+ import React , {
18+ useState ,
19+ useCallback ,
20+ FormEvent ,
21+ FormEventHandler ,
22+ } from "react" ;
23+ import { useHistory } from "react-router-dom" ;
24+ import { MatrixClient } from "matrix-js-sdk" ;
25+
1826import { createRoom , roomAliasLocalpartFromRoomName } from "../matrix-utils" ;
1927import { useGroupCallRooms } from "./useGroupCallRooms" ;
2028import { Header , HeaderLogo , LeftNav , RightNav } from "../Header" ;
@@ -26,28 +34,35 @@ import { CallList } from "./CallList";
2634import { UserMenuContainer } from "../UserMenuContainer" ;
2735import { useModalTriggerState } from "../Modal" ;
2836import { JoinExistingCallModal } from "./JoinExistingCallModal" ;
29- import { useHistory } from "react-router-dom" ;
3037import { Title } from "../typography/Typography" ;
3138import { Form } from "../form/Form" ;
3239import { CallType , CallTypeDropdown } from "./CallTypeDropdown" ;
3340
34- export function RegisteredView ( { client } ) {
41+ interface Props {
42+ client : MatrixClient ;
43+ isPasswordlessUser : boolean ;
44+ }
45+
46+ export function RegisteredView ( { client, isPasswordlessUser } : Props ) {
3547 const [ callType , setCallType ] = useState ( CallType . Video ) ;
3648 const [ loading , setLoading ] = useState ( false ) ;
37- const [ error , setError ] = useState ( ) ;
49+ const [ error , setError ] = useState < Error > ( ) ;
3850 const history = useHistory ( ) ;
39- const onSubmit = useCallback (
40- ( e ) => {
51+ const { modalState, modalProps } = useModalTriggerState ( ) ;
52+
53+ const onSubmit : FormEventHandler < HTMLFormElement > = useCallback (
54+ ( e : FormEvent ) => {
4155 e . preventDefault ( ) ;
42- const data = new FormData ( e . target ) ;
43- const roomName = data . get ( "callName" ) ;
44- const ptt = callType === CallType . Radio ;
56+ const data = new FormData ( e . target as HTMLFormElement ) ;
57+ const roomNameData = data . get ( "callName" ) ;
58+ const roomName = typeof roomNameData === "string" ? roomNameData : "" ;
59+ // const ptt = callType === CallType.Radio;
4560
4661 async function submit ( ) {
4762 setError ( undefined ) ;
4863 setLoading ( true ) ;
4964
50- const [ roomIdOrAlias ] = await createRoom ( client , roomName , ptt ) ;
65+ const [ roomIdOrAlias ] = await createRoom ( client , roomName ) ;
5166
5267 if ( roomIdOrAlias ) {
5368 history . push ( `/room/${ roomIdOrAlias } ` ) ;
@@ -64,17 +79,15 @@ export function RegisteredView({ client }) {
6479 console . error ( error ) ;
6580 setLoading ( false ) ;
6681 setError ( error ) ;
67- reset ( ) ;
6882 }
6983 } ) ;
7084 } ,
71- [ client , callType ]
85+ [ client , history , modalState ]
7286 ) ;
7387
7488 const recentRooms = useGroupCallRooms ( client ) ;
7589
76- const { modalState, modalProps } = useModalTriggerState ( ) ;
77- const [ existingRoomId , setExistingRoomId ] = useState ( ) ;
90+ const [ existingRoomId , setExistingRoomId ] = useState < string > ( ) ;
7891 const onJoinExistingRoom = useCallback ( ( ) => {
7992 history . push ( `/${ existingRoomId } ` ) ;
8093 } , [ history , existingRoomId ] ) ;
0 commit comments