Skip to content

Commit 48385b8

Browse files
authored
perf: MessageList livestreaming improvements (#3244)
* fix: add RAF coalescing * fix: correct import * fix: livestreaming mode MVCP * perf: throttle certain channel preview updates to avoid stressing the state update queue * fix: goToMessage behaviour * feat: add message pruning capabilities * perf: only register animated values when STR is enabled * chore: extract message bubble * chore: add menu option * chore: add menu option for pruning a well * fix: variable dynamic size message items * fix: flashlist mvcp disjoint set bug * fix: memoize message bubble components to be in line with previous behaviour * fix: save a render cycle through restructuring * fix: remove redundant check * Revert "fix: remove redundant check" This reverts commit 8dd98f7. * Revert "fix: save a render cycle through restructuring" This reverts commit 38ca199. * fix: experiment with scrollToIndex * fix: styles since upgrade * fix: scroll to bottom not always working * fix: api rename * chore: flashlist bump * fix: stutter when scrolling to message * fix: infinite scroll bug * chore: bump stream-chat-js * chore: add package.json as well * fix: remove console.log
1 parent 3499068 commit 48385b8

File tree

20 files changed

+825
-451
lines changed

20 files changed

+825
-451
lines changed

examples/SampleApp/App.tsx

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ import type { LocalMessage, StreamChat, TextComposerMiddleware } from 'stream-ch
5959
import { Toast } from './src/components/ToastComponent/Toast';
6060
import { useClientNotificationsToastHandler } from './src/hooks/useClientNotificationsToastHandler';
6161
import AsyncStore from './src/utils/AsyncStore.ts';
62+
import {
63+
MessageListImplementationConfigItem,
64+
MessageListModeConfigItem,
65+
MessageListPruningConfigItem,
66+
} from './src/components/SecretMenu.tsx';
6267

6368
init({ data });
6469

@@ -91,7 +96,15 @@ const Stack = createStackNavigator<StackNavigatorParamList>();
9196
const UserSelectorStack = createStackNavigator<UserSelectorParamList>();
9297
const App = () => {
9398
const { chatClient, isConnecting, loginUser, logout, switchUser } = useChatClient();
94-
const [messageListImplementation, setMessageListImplementation] = useState<'flashlist' | 'flatlist' | null>(null);
99+
const [messageListImplementation, setMessageListImplementation] = useState<
100+
MessageListImplementationConfigItem['id'] | undefined
101+
>(undefined);
102+
const [messageListMode, setMessageListMode] = useState<
103+
MessageListModeConfigItem['mode'] | undefined
104+
>(undefined);
105+
const [messageListPruning, setMessageListPruning] = useState<
106+
MessageListPruningConfigItem['value'] | undefined
107+
>(undefined);
95108
const colorScheme = useColorScheme();
96109
const streamChatTheme = useStreamChatTheme();
97110

@@ -133,14 +146,26 @@ const App = () => {
133146
}
134147
}
135148
});
136-
const getMessageListImplementation = async () => {
137-
const storedValue = await AsyncStore.getItem(
149+
const getMessageListConfig = async () => {
150+
const messageListImplementationStoredValue = await AsyncStore.getItem(
138151
'@stream-rn-sampleapp-messagelist-implementation',
139-
{ id: 'flashlist' }
152+
{ id: 'flatlist' },
140153
);
141-
setMessageListImplementation(storedValue?.id as ('flashlist' | 'flatlist'));
142-
}
143-
getMessageListImplementation();
154+
const messageListModeStoredValue = await AsyncStore.getItem(
155+
'@stream-rn-sampleapp-messagelist-mode',
156+
{ mode: 'default' },
157+
);
158+
const messageListPruningStoredValue = await AsyncStore.getItem(
159+
'@stream-rn-sampleapp-messagelist-pruning',
160+
{ value: undefined },
161+
);
162+
setMessageListImplementation(
163+
messageListImplementationStoredValue?.id as MessageListImplementationConfigItem['id'],
164+
);
165+
setMessageListMode(messageListModeStoredValue?.mode as MessageListModeConfigItem['mode']);
166+
setMessageListPruning(messageListPruningStoredValue?.value as MessageListPruningConfigItem['value']);
167+
};
168+
getMessageListConfig();
144169
return () => {
145170
unsubscribeOnNotificationOpen();
146171
unsubscribeForegroundEvent();
@@ -172,7 +197,7 @@ const App = () => {
172197
});
173198
}, [chatClient]);
174199

175-
if (!messageListImplementation) {
200+
if (!messageListImplementation || !messageListMode) {
176201
return;
177202
}
178203

@@ -194,7 +219,17 @@ const App = () => {
194219
dark: colorScheme === 'dark',
195220
}}
196221
>
197-
<AppContext.Provider value={{ chatClient, loginUser, logout, switchUser, messageListImplementation }}>
222+
<AppContext.Provider
223+
value={{
224+
chatClient,
225+
loginUser,
226+
logout,
227+
switchUser,
228+
messageListImplementation,
229+
messageListMode,
230+
messageListPruning,
231+
}}
232+
>
198233
{isConnecting && !chatClient ? (
199234
<LoadingScreen />
200235
) : chatClient ? (

examples/SampleApp/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"@react-navigation/drawer": "7.4.1",
3838
"@react-navigation/native": "^7.1.10",
3939
"@react-navigation/stack": "^7.3.3",
40-
"@shopify/flash-list": "^2.0.3",
40+
"@shopify/flash-list": "^2.1.0",
4141
"emoji-mart": "^5.6.0",
4242
"lodash.mergewith": "^4.6.2",
4343
"react": "19.1.0",

0 commit comments

Comments
 (0)