1- import { useState } from "react" ;
1+ import { useEffect , useState } from "react" ;
22import {
33 ActivityIndicator ,
44 KeyboardAvoidingView ,
@@ -16,6 +16,7 @@ import * as Clipboard from "expo-clipboard";
1616import * as Haptics from "expo-haptics" ;
1717
1818import { useChatAppState } from "@/hooks/use-chat-app-state" ;
19+ import { extractInviteCode , formatInviteShareMessage } from "@/lib/invite-links" ;
1920import type { ChatStackParamList } from "@/navigation/types" ;
2021import { colors } from "@/theme/colors" ;
2122
@@ -27,6 +28,17 @@ export function NewChatScreen(props: Props) {
2728 const [ inviteCode , setInviteCode ] = useState ( "" ) ;
2829 const [ error , setError ] = useState < string | null > ( null ) ;
2930
31+ useEffect ( ( ) => {
32+ const routeInviteCode = props . route . params ?. code ;
33+
34+ if ( ! routeInviteCode ) {
35+ return ;
36+ }
37+
38+ setInviteCode ( extractInviteCode ( routeInviteCode ) ) ;
39+ setError ( null ) ;
40+ } , [ props . route . params ?. code ] ) ;
41+
3042 const canImport = inviteCode . trim ( ) . length > 10 ;
3143 const dismiss = ( ) => props . navigation . goBack ( ) ;
3244
@@ -43,7 +55,7 @@ export function NewChatScreen(props: Props) {
4355 const result = await conversations . createInvite ( label ) ;
4456
4557 await Share . share ( {
46- message : `Join my secure room on Enmarch:\n\n ${ result . inviteCode } ` ,
58+ message : formatInviteShareMessage ( result . inviteCode ) ,
4759 title : "Enmarch Invite" ,
4860 } ) . catch ( ( ) => null ) ;
4961
@@ -84,7 +96,7 @@ export function NewChatScreen(props: Props) {
8496 try {
8597 const text = await Clipboard . getStringAsync ( ) ;
8698 if ( text ) {
87- setInviteCode ( text . trim ( ) ) ;
99+ setInviteCode ( extractInviteCode ( text ) ) ;
88100 Haptics . impactAsync ( Haptics . ImpactFeedbackStyle . Light ) ;
89101 }
90102 } catch {
@@ -310,7 +322,7 @@ export function NewChatScreen(props: Props) {
310322 setInviteCode ( text ) ;
311323 setError ( null ) ;
312324 } }
313- placeholder = "Paste invite code"
325+ placeholder = "Paste invite code or deep link "
314326 placeholderTextColor = { colors . mutedForeground }
315327 multiline
316328 style = { {
0 commit comments