Skip to content

Commit 54ce9c6

Browse files
committed
fix: add app changes
1 parent 3038e7b commit 54ce9c6

File tree

3 files changed

+18
-25
lines changed

3 files changed

+18
-25
lines changed

examples/SampleApp/App.tsx

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { createStackNavigator } from '@react-navigation/stack';
66
import { SafeAreaProvider, useSafeAreaInsets } from 'react-native-safe-area-context';
77
import {
88
Chat,
9-
MessageType,
109
OverlayProvider,
1110
SqliteClient,
1211
ThemeProvider,
@@ -36,7 +35,7 @@ import { SharedGroupsScreen } from './src/screens/SharedGroupsScreen';
3635
import { ThreadScreen } from './src/screens/ThreadScreen';
3736
import { UserSelectorScreen } from './src/screens/UserSelectorScreen';
3837

39-
import type { StreamChat } from 'stream-chat';
38+
import type { LocalMessage, StreamChat } from 'stream-chat';
4039

4140
if (__DEV__) {
4241
DevSettings.addMenuItem('Reset local DB (offline storage)', () => {
@@ -45,10 +44,7 @@ if (__DEV__) {
4544
});
4645
}
4746

48-
import type {
49-
StackNavigatorParamList,
50-
UserSelectorParamList,
51-
} from './src/types';
47+
import type { StackNavigatorParamList, UserSelectorParamList } from './src/types';
5248
import { GestureHandlerRootView } from 'react-native-gesture-handler';
5349
import { navigateToChannel, RootNavigationRef } from './src/utils/RootNavigation';
5450
import FastImage from 'react-native-fast-image';
@@ -106,18 +102,16 @@ const App = () => {
106102
}
107103
}
108104
});
109-
messaging
110-
.getInitialNotification()
111-
.then((remoteMessage) => {
112-
if (remoteMessage) {
113-
// Notification caused app to open from quit state on iOS
114-
const channelId = remoteMessage.data?.channel_id as string;
115-
if (channelId) {
116-
// this will make the app to start with the channel screen with this channel id
117-
initialChannelIdGlobalRef.current = channelId;
118-
}
105+
messaging.getInitialNotification().then((remoteMessage) => {
106+
if (remoteMessage) {
107+
// Notification caused app to open from quit state on iOS
108+
const channelId = remoteMessage.data?.channel_id as string;
109+
if (channelId) {
110+
// this will make the app to start with the channel screen with this channel id
111+
initialChannelIdGlobalRef.current = channelId;
119112
}
120-
});
113+
}
114+
});
121115
return () => {
122116
unsubscribeOnNotificationOpen();
123117
unsubscribeForegroundEvent();
@@ -170,7 +164,7 @@ const DrawerNavigator: React.FC = () => (
170164
</Drawer.Navigator>
171165
);
172166

173-
const isMessageAIGenerated = (message: MessageType) => !!message.ai_generated;
167+
const isMessageAIGenerated = (message: LocalMessage) => !!message.ai_generated;
174168

175169
const DrawerNavigatorWrapper: React.FC<{
176170
chatClient: StreamChat;

examples/SampleApp/src/screens/ThreadScreen.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { StyleSheet, View } from 'react-native';
33
import { SafeAreaView } from 'react-native-safe-area-context';
44
import {
55
Channel,
6-
MessageType,
76
Thread,
87
ThreadType,
98
useAttachmentPickerContext,
@@ -17,7 +16,7 @@ import { ScreenHeader } from '../components/ScreenHeader';
1716
import type { RouteProp } from '@react-navigation/native';
1817

1918
import type { StackNavigatorParamList } from '../types';
20-
import { ThreadState, UserResponse } from 'stream-chat';
19+
import { LocalMessage, ThreadState, UserResponse } from 'stream-chat';
2120

2221
const selector = (nextValue: ThreadState) => ({ parentMessage: nextValue.parentMessage }) as const;
2322

@@ -34,12 +33,12 @@ type ThreadScreenProps = {
3433
};
3534

3635
export type ThreadHeaderProps = {
37-
thread: MessageType | ThreadType;
36+
thread: LocalMessage | ThreadType;
3837
};
3938

4039
const ThreadHeader: React.FC<ThreadHeaderProps> = ({ thread }) => {
4140
const typing = useTypingString();
42-
let subtitleText = ((thread as MessageType)?.user as UserResponse)?.name;
41+
let subtitleText = ((thread as LocalMessage)?.user as UserResponse)?.name;
4342
const { parentMessage } =
4443
useStateStore((thread as ThreadType)?.threadInstance?.state, selector) || {};
4544

examples/SampleApp/src/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { Channel, UserResponse } from 'stream-chat';
2-
import type { MessageType, ThreadType } from 'stream-chat-react-native';
1+
import type { Channel, LocalMessage, UserResponse } from 'stream-chat';
2+
import type { ThreadType } from 'stream-chat-react-native';
33
import type { Theme } from '@react-navigation/native';
44

55
export type DrawerNavigatorParamList = {
@@ -38,7 +38,7 @@ export type StackNavigatorParamList = {
3838
};
3939
ThreadScreen: {
4040
channel: Channel;
41-
thread: MessageType | ThreadType;
41+
thread: LocalMessage | ThreadType;
4242
};
4343
};
4444

0 commit comments

Comments
 (0)