Skip to content

Commit 87a1749

Browse files
committed
fix: expo sample app message flash list improvement
1 parent 14c76a8 commit 87a1749

File tree

4 files changed

+52
-27
lines changed

4 files changed

+52
-27
lines changed

examples/ExpoMessaging/app/channel/[cid]/index.tsx

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import React, { useContext, useEffect, useState } from 'react';
22
import 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';
410
import { Stack, useLocalSearchParams, useRouter } from 'expo-router';
511
import { AuthProgressLoader } from '../../../components/AuthProgressLoader';
612
import { 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

examples/ExpoMessaging/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"@react-native-firebase/messaging": "^23.4.0",
1919
"@react-navigation/elements": "^2.6.4",
2020
"@react-navigation/native": "^7.1.8",
21-
"@shopify/flash-list": "2.0.2",
21+
"@shopify/flash-list": "^2.1.0",
2222
"expo": "54.0.13",
2323
"expo-audio": "~1.0.13",
2424
"expo-build-properties": "~1.0.9",

examples/ExpoMessaging/yarn.lock

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2248,12 +2248,10 @@
22482248
read-yaml-file "^2.1.0"
22492249
strip-json-comments "^3.1.1"
22502250

2251-
"@shopify/[email protected]":
2252-
version "2.0.2"
2253-
resolved "https://registry.yarnpkg.com/@shopify/flash-list/-/flash-list-2.0.2.tgz#644748f883fccf8cf2e0ca251e0ef88673b89120"
2254-
integrity sha512-zhlrhA9eiuEzja4wxVvotgXHtqd3qsYbXkQ3rsBfOgbFA9BVeErpDE/yEwtlIviRGEqpuFj/oU5owD6ByaNX+w==
2255-
dependencies:
2256-
tslib "2.8.1"
2251+
"@shopify/flash-list@^2.1.0":
2252+
version "2.1.0"
2253+
resolved "https://registry.yarnpkg.com/@shopify/flash-list/-/flash-list-2.1.0.tgz#b1eefcf9fbd01ca04a5f24a6003cda3b46a59f64"
2254+
integrity sha512-/EIQlptG456yM5o9qNmNsmaZEFEOGvG3WGyb6GUAxSLlcKUGlPUkPI2NLW5wQSDEY4xSRa5zocUI+9xwmsM4Kg==
22572255

22582256
"@sinclair/typebox@^0.27.8":
22592257
version "0.27.8"
@@ -6079,7 +6077,22 @@ [email protected]:
60796077
version "0.0.0"
60806078
uid ""
60816079

6082-
stream-chat@^9.17.0, stream-chat@^9.9.0:
6080+
stream-chat@^9.23.0:
6081+
version "9.23.0"
6082+
resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-9.23.0.tgz#e7e5cf729861597e7198907c1cab22a57d68a2fc"
6083+
integrity sha512-UW112HYsLnYb4RMIXBtAouNQCCe0weVzNivjezsw+JKK1b/TX0JLBi+wK25mBUEO+coOGKfXiye6IB3gao8ipw==
6084+
dependencies:
6085+
"@types/jsonwebtoken" "^9.0.8"
6086+
"@types/ws" "^8.5.14"
6087+
axios "^1.12.2"
6088+
base64-js "^1.5.1"
6089+
form-data "^4.0.4"
6090+
isomorphic-ws "^5.0.0"
6091+
jsonwebtoken "^9.0.2"
6092+
linkifyjs "^4.3.2"
6093+
ws "^8.18.1"
6094+
6095+
stream-chat@^9.9.0:
60836096
version "9.20.3"
60846097
resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-9.20.3.tgz#5f47d6f46d146202c743282f5fb7350f4a640922"
60856098
integrity sha512-206Lea0ZAVWbfYZkIwLG5m+++ELD3f8EAEL/YzbMDL++E2vU2WhQ2d1HNb1ROXURZUF0Sy845htTw1rwnahomw==
@@ -6310,7 +6323,7 @@ ts-interface-checker@^0.1.9:
63106323
resolved "https://registry.yarnpkg.com/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz#784fd3d679722bc103b1b4b8030bcddb5db2a699"
63116324
integrity sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==
63126325

6313-
tslib@2.8.1, tslib@^2.0.0, tslib@^2.1.0:
6326+
tslib@^2.0.0, tslib@^2.1.0:
63146327
version "2.8.1"
63156328
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.8.1.tgz#612efe4ed235d567e8aba5f2a5fab70280ade83f"
63166329
integrity sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==

examples/SampleApp/src/screens/ChannelScreen.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,15 @@ export const ChannelScreen: React.FC<ChannelScreenProps> = ({
220220
>
221221
<ChannelHeader channel={channel} />
222222
{messageListImplementation === 'flashlist' ? (
223-
<MessageFlashList onThreadSelect={onThreadSelect} isLiveStreaming={messageListMode === 'livestream'} />
223+
<MessageFlashList
224+
onThreadSelect={onThreadSelect}
225+
isLiveStreaming={messageListMode === 'livestream'}
226+
/>
224227
) : (
225-
<MessageList onThreadSelect={onThreadSelect} isLiveStreaming={messageListMode === 'livestream'} />
228+
<MessageList
229+
onThreadSelect={onThreadSelect}
230+
isLiveStreaming={messageListMode === 'livestream'}
231+
/>
226232
)}
227233
<AITypingIndicatorView channel={channel} />
228234
<MessageInput />

0 commit comments

Comments
 (0)