Skip to content

Commit c353a32

Browse files
committed
fix: default values
1 parent deb81dd commit c353a32

File tree

3 files changed

+10
-33
lines changed

3 files changed

+10
-33
lines changed

examples/TypeScriptMessaging/App.tsx

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { I18nManager, LogBox, Platform, SafeAreaView, useColorScheme, View } fro
33
import { DarkTheme, DefaultTheme, NavigationContainer, RouteProp } from '@react-navigation/native';
44
import { createStackNavigator, StackNavigationProp } from '@react-navigation/stack';
55
import { useHeaderHeight } from '@react-navigation/elements';
6-
import { SafeAreaProvider, useSafeAreaInsets } from 'react-native-safe-area-context';
6+
import { SafeAreaProvider } from 'react-native-safe-area-context';
77
import { Channel as ChannelType, ChannelSort } from 'stream-chat';
88
import {
99
Channel,
@@ -16,7 +16,6 @@ import {
1616
Streami18n,
1717
Thread,
1818
ThreadContextValue,
19-
useAttachmentPickerContext,
2019
useCreateChatClient,
2120
useOverlayContext,
2221
} from 'stream-chat-react-native';
@@ -53,11 +52,7 @@ const filters = {
5352
type: 'messaging',
5453
};
5554

56-
const sort: ChannelSort = [
57-
{ pinned_at: -1 },
58-
{ last_message_at: -1 },
59-
{ updated_at: -1 },
60-
];
55+
const sort: ChannelSort = [{ pinned_at: -1 }, { last_message_at: -1 }, { updated_at: -1 }];
6156

6257
/**
6358
* Start playing with streami18n instance here:
@@ -100,7 +95,6 @@ const EmptyHeader = () => <></>;
10095
const ChannelScreen: React.FC<ChannelScreenProps> = ({ navigation }) => {
10196
const { channel, setThread, thread } = useContext(AppContext);
10297
const headerHeight = useHeaderHeight();
103-
const { setTopInset } = useAttachmentPickerContext();
10498
const { overlay } = useOverlayContext();
10599

106100
useEffect(() => {
@@ -109,10 +103,6 @@ const ChannelScreen: React.FC<ChannelScreenProps> = ({ navigation }) => {
109103
});
110104
}, [overlay, navigation]);
111105

112-
useEffect(() => {
113-
setTopInset(headerHeight);
114-
}, [headerHeight, setTopInset]);
115-
116106
if (channel === undefined) {
117107
return null;
118108
}
@@ -193,16 +183,13 @@ const Stack = createStackNavigator<NavigationParamsList>();
193183
type AppContextType = {
194184
channel: ChannelType | undefined;
195185
setChannel: React.Dispatch<React.SetStateAction<ChannelType | undefined>>;
196-
setThread: React.Dispatch<
197-
React.SetStateAction<ThreadContextValue['thread'] | undefined>
198-
>;
186+
setThread: React.Dispatch<React.SetStateAction<ThreadContextValue['thread'] | undefined>>;
199187
thread: ThreadContextValue['thread'] | undefined;
200188
};
201189

202190
const AppContext = React.createContext({} as AppContextType);
203191

204192
const App = () => {
205-
const { bottom } = useSafeAreaInsets();
206193
const theme = useStreamChatTheme();
207194
const { channel } = useContext(AppContext);
208195

@@ -217,11 +204,7 @@ const App = () => {
217204
}
218205

219206
return (
220-
<OverlayProvider
221-
bottomInset={bottom}
222-
i18nInstance={streami18n}
223-
value={{ style: theme }}
224-
>
207+
<OverlayProvider i18nInstance={streami18n} value={{ style: theme }}>
225208
<Chat client={chatClient} i18nInstance={streami18n} enableOfflineSupport>
226209
<Stack.Navigator
227210
initialRouteName='ChannelList'

package/src/components/Channel/Channel.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
510510
AutoCompleteSuggestionList = AutoCompleteSuggestionListDefault,
511511

512512
autoCompleteSuggestionsLimit,
513-
bottomInset,
513+
bottomInset = 0,
514514
CameraSelectorIcon = DefaultCameraSelectorIcon,
515515
FileSelectorIcon = DefaultFileSelectorIcon,
516516
CreatePollIcon = DefaultCreatePollIcon,
@@ -677,7 +677,7 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
677677
thread: threadFromProps,
678678
threadList,
679679
threadMessages,
680-
topInset,
680+
topInset = 0,
681681
TypingIndicator = TypingIndicatorDefault,
682682
TypingIndicatorContainer = TypingIndicatorContainerDefault,
683683
UnreadMessagesNotification = UnreadMessagesNotificationDefault,

package/src/components/MessageInput/MessageInput.tsx

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,7 @@ type MessageInputPropsWithContext = Partial<
121121
| 'numberOfAttachmentPickerImageColumns'
122122
>
123123
> &
124-
Partial<
125-
Pick<
126-
AttachmentPickerContextValue,
127-
'bottomInset' | 'topInset' | 'bottomSheetRef' | 'selectedPicker'
128-
>
129-
> &
124+
Pick<AttachmentPickerContextValue, 'bottomInset' | 'bottomSheetRef' | 'selectedPicker'> &
130125
Pick<ChatContextValue, 'isOnline'> &
131126
Pick<ChannelContextValue, 'channel' | 'members' | 'threadList' | 'watchers'> &
132127
Pick<
@@ -214,7 +209,7 @@ const MessageInputWithContext = (props: MessageInputPropsWithContext) => {
214209
attachmentSelectionBarHeight,
215210
numberOfAttachmentImagesToLoadPerCall = 60,
216211
numberOfAttachmentPickerImageColumns = 3,
217-
bottomInset = 0,
212+
bottomInset,
218213
bottomSheetRef,
219214
selectedPicker,
220215

@@ -677,7 +672,7 @@ const MessageInputWithContext = (props: MessageInputPropsWithContext) => {
677672
</View>
678673
{isImageMediaLibraryAvailable() ? (
679674
<>
680-
{selectedPicker && AttachmentPickerSelectionBar ? (
675+
{selectedPicker ? (
681676
<View
682677
style={[
683678
{
@@ -917,7 +912,7 @@ export const MessageInput = (props: MessageInputProps) => {
917912
uploadNewFile,
918913
VideoRecorderSelectorIcon,
919914
} = useMessageInputContext();
920-
const { bottomInset, bottomSheetRef, selectedPicker, topInset } = useAttachmentPickerContext();
915+
const { bottomInset, bottomSheetRef, selectedPicker } = useAttachmentPickerContext();
921916

922917
const { Reply } = useMessagesContext();
923918

@@ -995,7 +990,6 @@ export const MessageInput = (props: MessageInputProps) => {
995990
t,
996991
thread,
997992
threadList,
998-
topInset,
999993
uploadNewFile,
1000994
VideoRecorderSelectorIcon,
1001995
watchers,

0 commit comments

Comments
 (0)