11import React , { useContext , useEffect , useState } from 'react' ;
22import type { Channel as StreamChatChannel } from 'stream-chat' ;
3- import { Channel , MessageInput , MessageFlashList , useChatContext } from 'stream-chat-expo' ;
3+ import {
4+ Channel ,
5+ MessageInput ,
6+ useChatContext ,
7+ MessageFlashList ,
8+ ThreadContextValue ,
9+ } from 'stream-chat-expo' ;
410import { Stack , useLocalSearchParams , useRouter } from 'expo-router' ;
511import { AuthProgressLoader } from '../../../components/AuthProgressLoader' ;
612import { AppContext } from '../../../context/AppContext' ;
@@ -45,7 +51,7 @@ export default function ChannelScreen() {
4551 payload ,
4652 ) => {
4753 const { message, defaultHandler, emitter } = payload ;
48- const { shared_location } = message ;
54+ const { shared_location } = message ?? { } ;
4955 if ( emitter === 'messageContent' && shared_location ) {
5056 // Create url params from shared_location
5157 const params = Object . entries ( shared_location )
@@ -61,26 +67,26 @@ export default function ChannelScreen() {
6167 }
6268
6369 return (
64- < Channel
65- audioRecordingEnabled = { true }
66- channel = { channel }
67- onPressMessage = { onPressMessage }
68- keyboardVerticalOffset = { headerHeight }
69- MessageLocation = { MessageLocation }
70- thread = { thread }
71- >
72- < Stack . Screen options = { { title : 'Channel Screen' } } />
70+ < SafeAreaView edges = { [ 'bottom' ] } style = { styles . container } >
71+ < Channel
72+ audioRecordingEnabled = { true }
73+ channel = { channel }
74+ onPressMessage = { onPressMessage }
75+ keyboardVerticalOffset = { headerHeight }
76+ MessageLocation = { MessageLocation }
77+ thread = { thread }
78+ >
79+ < Stack . Screen options = { { title : 'Channel Screen' } } />
7380
74- < SafeAreaView edges = { [ 'bottom' ] } style = { styles . container } >
7581 < MessageFlashList
76- onThreadSelect = { ( thread ) => {
82+ onThreadSelect = { ( thread : ThreadContextValue [ 'thread' ] ) => {
7783 setThread ( thread ) ;
78- router . push ( `/channel/${ channel . cid } /thread/${ thread . cid } ` ) ;
84+ router . push ( `/channel/${ channel . cid } /thread/${ thread ? .cid ?? '' } ` ) ;
7985 } }
8086 />
8187 < MessageInput InputButtons = { InputButtons } />
82- </ SafeAreaView >
83- </ Channel >
88+ </ Channel >
89+ </ SafeAreaView >
8490 ) ;
8591}
8692
0 commit comments