Skip to content

Commit b3a6039

Browse files
committed
fix: add forgotten change
1 parent 1461ccc commit b3a6039

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

examples/SampleApp/App.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect } from 'react';
1+
import React, { useEffect, useState } from 'react';
22
import { DevSettings, LogBox, Platform, useColorScheme } from 'react-native';
33
import { createDrawerNavigator } from '@react-navigation/drawer';
44
import { DarkTheme, DefaultTheme, NavigationContainer } from '@react-navigation/native';
@@ -58,6 +58,7 @@ Geolocation.setRNConfiguration({
5858
import type { LocalMessage, StreamChat, TextComposerMiddleware } from 'stream-chat';
5959
import { Toast } from './src/components/ToastComponent/Toast';
6060
import { useClientNotificationsToastHandler } from './src/hooks/useClientNotificationsToastHandler';
61+
import AsyncStore from './src/utils/AsyncStore.ts';
6162

6263
init({ data });
6364

@@ -90,6 +91,7 @@ const Stack = createStackNavigator<StackNavigatorParamList>();
9091
const UserSelectorStack = createStackNavigator<UserSelectorParamList>();
9192
const App = () => {
9293
const { chatClient, isConnecting, loginUser, logout, switchUser } = useChatClient();
94+
const [messageListImplementation, setMessageListImplementation] = useState<'flashlist' | 'flatlist' | null>(null);
9395
const colorScheme = useColorScheme();
9496
const streamChatTheme = useStreamChatTheme();
9597

@@ -131,6 +133,14 @@ const App = () => {
131133
}
132134
}
133135
});
136+
const getMessageListImplementation = async () => {
137+
const storedValue = await AsyncStore.getItem(
138+
'@stream-rn-sampleapp-messagelist-implementation',
139+
{ id: 'flashlist' }
140+
);
141+
setMessageListImplementation(storedValue?.id as ('flashlist' | 'flatlist'));
142+
}
143+
getMessageListImplementation();
134144
return () => {
135145
unsubscribeOnNotificationOpen();
136146
unsubscribeForegroundEvent();
@@ -162,6 +172,10 @@ const App = () => {
162172
});
163173
}, [chatClient]);
164174

175+
if (!messageListImplementation) {
176+
return;
177+
}
178+
165179
return (
166180
<SafeAreaProvider
167181
style={{
@@ -180,7 +194,7 @@ const App = () => {
180194
dark: colorScheme === 'dark',
181195
}}
182196
>
183-
<AppContext.Provider value={{ chatClient, loginUser, logout, switchUser }}>
197+
<AppContext.Provider value={{ chatClient, loginUser, logout, switchUser, messageListImplementation }}>
184198
{isConnecting && !chatClient ? (
185199
<LoadingScreen />
186200
) : chatClient ? (

0 commit comments

Comments
 (0)