Skip to content

Commit a5f8990

Browse files
authored
fix: state sync mismatch and bottom sheet version (#3366)
## 🎯 Goal This PR is a backport of this fix from `develop`. Additionally, it provides a pinned version of `@gorhom/bottom-sheet` to try better in avoiding buggy version mismatches. ## 🛠 Implementation details <!-- Provide a description of the implementation --> ## 🎨 UI Changes <!-- Add relevant screenshots --> <details> <summary>iOS</summary> <table> <thead> <tr> <td>Before</td> <td>After</td> </tr> </thead> <tbody> <tr> <td> <!--<img src="" /> --> </td> <td> <!--<img src="" /> --> </td> </tr> </tbody> </table> </details> <details> <summary>Android</summary> <table> <thead> <tr> <td>Before</td> <td>After</td> </tr> </thead> <tbody> <tr> <td> <!--<img src="" /> --> </td> <td> <!--<img src="" /> --> </td> </tr> </tbody> </table> </details> ## 🧪 Testing <!-- Explain how this change can be tested (or why it can't be tested) --> ## ☑️ Checklist - [ ] I have signed the [Stream CLA](https://docs.google.com/forms/d/e/1FAIpQLScFKsKkAJI7mhCr7K9rEIOpqIDThrWxuvxnwUq2XkHyG154vQ/viewform) (required) - [ ] PR targets the `develop` branch - [ ] Documentation is updated - [ ] New code is tested in main example apps, including all possible scenarios - [ ] SampleApp iOS and Android - [ ] Expo iOS and Android
1 parent 055a699 commit a5f8990

16 files changed

Lines changed: 183 additions & 240 deletions

File tree

examples/SampleApp/ios/Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3522,7 +3522,7 @@ SPEC CHECKSUMS:
35223522
op-sqlite: b9a4028bef60145d7b98fbbc4341c83420cdcfd5
35233523
PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47
35243524
PromisesSwift: 9d77319bbe72ebf6d872900551f7eeba9bce2851
3525-
RCT-Folly: 846fda9475e61ec7bcbf8a3fe81edfcaeb090669
3525+
RCT-Folly: 59ec0ac1f2f39672a0c6e6cecdd39383b764646f
35263526
RCTDeprecation: 300c5eb91114d4339b0bb39505d0f4824d7299b7
35273527
RCTRequired: e0446b01093475b7082fbeee5d1ef4ad1fe20ac4
35283528
RCTTypeSafety: cb974efcdc6695deedf7bf1eb942f2a0603a063f
Lines changed: 46 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,55 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>en</string>
7+
<key>CFBundleExecutable</key>
8+
<string>$(EXECUTABLE_NAME)</string>
9+
<key>CFBundleIdentifier</key>
10+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11+
<key>CFBundleInfoDictionaryVersion</key>
12+
<string>6.0</string>
13+
<key>CFBundleName</key>
14+
<string>$(PRODUCT_NAME)</string>
15+
<key>CFBundlePackageType</key>
16+
<string>APPL</string>
17+
<key>CFBundleShortVersionString</key>
18+
<string>0.0.22</string>
19+
<key>CFBundleSignature</key>
20+
<string>????</string>
21+
<key>CFBundleVersion</key>
22+
<string>28</string>
23+
<key>LSRequiresIPhoneOS</key>
24+
<true/>
25+
<key>NSAppTransportSecurity</key>
426
<dict>
5-
<key>CFBundleDevelopmentRegion</key>
6-
<string>en</string>
7-
<key>CFBundleExecutable</key>
8-
<string>$(EXECUTABLE_NAME)</string>
9-
<key>CFBundleIdentifier</key>
10-
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11-
<key>CFBundleInfoDictionaryVersion</key>
12-
<string>6.0</string>
13-
<key>CFBundleName</key>
14-
<string>$(PRODUCT_NAME)</string>
15-
<key>CFBundlePackageType</key>
16-
<string>APPL</string>
17-
<key>CFBundleShortVersionString</key>
18-
<string>0.0.22</string>
19-
<key>CFBundleSignature</key>
20-
<string>????</string>
21-
<key>CFBundleVersion</key>
22-
<string>28</string>
23-
<key>LSRequiresIPhoneOS</key>
24-
<true />
25-
<key>NSAppTransportSecurity</key>
27+
<key>NSExceptionDomains</key>
2628
<dict>
27-
<key>NSExceptionDomains</key>
29+
<key>localhost</key>
2830
<dict>
29-
<key>localhost</key>
30-
<dict>
31-
<key>NSExceptionAllowsInsecureHTTPLoads</key>
32-
<true />
33-
</dict>
31+
<key>NSExceptionAllowsInsecureHTTPLoads</key>
32+
<true/>
3433
</dict>
3534
</dict>
36-
<key>NSLocationWhenInUseUsageDescription</key>
37-
<string></string>
38-
<key>UILaunchStoryboardName</key>
39-
<string>LaunchScreen</string>
40-
<key>UIRequiredDeviceCapabilities</key>
41-
<array>
42-
<string>armv7</string>
43-
</array>
44-
<key>UISupportedInterfaceOrientations</key>
45-
<array>
46-
<string>UIInterfaceOrientationPortrait</string>
47-
<string>UIInterfaceOrientationLandscapeLeft</string>
48-
<string>UIInterfaceOrientationLandscapeRight</string>
49-
</array>
50-
<key>UIViewControllerBasedStatusBarAppearance</key>
51-
<false />
5235
</dict>
53-
</plist>
36+
<key>NSLocationWhenInUseUsageDescription</key>
37+
<string></string>
38+
<key>RCTNewArchEnabled</key>
39+
<true/>
40+
<key>UILaunchStoryboardName</key>
41+
<string>LaunchScreen</string>
42+
<key>UIRequiredDeviceCapabilities</key>
43+
<array>
44+
<string>armv7</string>
45+
</array>
46+
<key>UISupportedInterfaceOrientations</key>
47+
<array>
48+
<string>UIInterfaceOrientationPortrait</string>
49+
<string>UIInterfaceOrientationLandscapeLeft</string>
50+
<string>UIInterfaceOrientationLandscapeRight</string>
51+
</array>
52+
<key>UIViewControllerBasedStatusBarAppearance</key>
53+
<false/>
54+
</dict>
55+
</plist>
Lines changed: 59 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,64 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>en</string>
7+
<key>CFBundleDisplayName</key>
8+
<string>ChatSample</string>
9+
<key>CFBundleExecutable</key>
10+
<string>$(EXECUTABLE_NAME)</string>
11+
<key>CFBundleIdentifier</key>
12+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
13+
<key>CFBundleInfoDictionaryVersion</key>
14+
<string>6.0</string>
15+
<key>CFBundleName</key>
16+
<string>$(PRODUCT_NAME)</string>
17+
<key>CFBundlePackageType</key>
18+
<string>APPL</string>
19+
<key>CFBundleShortVersionString</key>
20+
<string>1.11.0</string>
21+
<key>CFBundleSignature</key>
22+
<string>????</string>
23+
<key>CFBundleVersion</key>
24+
<string>154</string>
25+
<key>FirebaseAppDelegateProxyEnabled</key>
26+
<true/>
27+
<key>ITSAppUsesNonExemptEncryption</key>
28+
<false/>
29+
<key>LSRequiresIPhoneOS</key>
30+
<true/>
31+
<key>NSAppTransportSecurity</key>
432
<dict>
5-
<key>CFBundleDevelopmentRegion</key>
6-
<string>en</string>
7-
<key>CFBundleDisplayName</key>
8-
<string>ChatSample</string>
9-
<key>CFBundleExecutable</key>
10-
<string>$(EXECUTABLE_NAME)</string>
11-
<key>CFBundleIdentifier</key>
12-
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
13-
<key>CFBundleInfoDictionaryVersion</key>
14-
<string>6.0</string>
15-
<key>CFBundleName</key>
16-
<string>$(PRODUCT_NAME)</string>
17-
<key>CFBundlePackageType</key>
18-
<string>APPL</string>
19-
<key>CFBundleShortVersionString</key>
20-
<string>1.11.0</string>
21-
<key>CFBundleSignature</key>
22-
<string>????</string>
23-
<key>CFBundleVersion</key>
24-
<string>154</string>
25-
<key>FirebaseAppDelegateProxyEnabled</key>
26-
<true />
27-
<key>ITSAppUsesNonExemptEncryption</key>
28-
<false />
29-
<key>LSRequiresIPhoneOS</key>
30-
<true />
31-
<key>NSAppTransportSecurity</key>
32-
<dict>
33-
<key>NSAllowsArbitraryLoads</key>
34-
<false />
35-
<key>NSAllowsLocalNetworking</key>
36-
<true />
37-
</dict>
38-
<key>NSCameraUsageDescription</key>
39-
<string>$(PRODUCT_NAME) would like to use your camera to share image in a message.</string>
40-
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
41-
<string>$(PRODUCT_NAME) would like share live location always in a message.</string>
42-
<key>NSLocationWhenInUseUsageDescription</key>
43-
<string>$(PRODUCT_NAME) would like share live location when in use in a message.</string>
44-
<key>NSMicrophoneUsageDescription</key>
45-
<string>$(PRODUCT_NAME) would like to use your microphone for voice recording.</string>
46-
<key>NSPhotoLibraryUsageDescription</key>
47-
<string>$(PRODUCT_NAME) would like access to your photo gallery to share image in a message.</string>
48-
<key>UILaunchStoryboardName</key>
49-
<string>LaunchScreen</string>
50-
<key>UIRequiredDeviceCapabilities</key>
51-
<array>
52-
<string>arm64</string>
53-
</array>
54-
<key>UISupportedInterfaceOrientations</key>
55-
<array>
56-
<string>UIInterfaceOrientationPortrait</string>
57-
<string>UIInterfaceOrientationPortraitUpsideDown</string>
58-
</array>
59-
<key>UIViewControllerBasedStatusBarAppearance</key>
60-
<false />
33+
<key>NSAllowsArbitraryLoads</key>
34+
<false/>
35+
<key>NSAllowsLocalNetworking</key>
36+
<true/>
6137
</dict>
62-
</plist>
38+
<key>NSCameraUsageDescription</key>
39+
<string>$(PRODUCT_NAME) would like to use your camera to share image in a message.</string>
40+
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
41+
<string>$(PRODUCT_NAME) would like share live location always in a message.</string>
42+
<key>NSLocationWhenInUseUsageDescription</key>
43+
<string>$(PRODUCT_NAME) would like share live location when in use in a message.</string>
44+
<key>NSMicrophoneUsageDescription</key>
45+
<string>$(PRODUCT_NAME) would like to use your microphone for voice recording.</string>
46+
<key>NSPhotoLibraryUsageDescription</key>
47+
<string>$(PRODUCT_NAME) would like access to your photo gallery to share image in a message.</string>
48+
<key>RCTNewArchEnabled</key>
49+
<true/>
50+
<key>UILaunchStoryboardName</key>
51+
<string>LaunchScreen</string>
52+
<key>UIRequiredDeviceCapabilities</key>
53+
<array>
54+
<string>arm64</string>
55+
</array>
56+
<key>UISupportedInterfaceOrientations</key>
57+
<array>
58+
<string>UIInterfaceOrientationPortrait</string>
59+
<string>UIInterfaceOrientationPortraitUpsideDown</string>
60+
</array>
61+
<key>UIViewControllerBasedStatusBarAppearance</key>
62+
<false/>
63+
</dict>
64+
</plist>

examples/SampleApp/yarn.lock

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,18 +1590,18 @@
15901590
resolved "https://registry.yarnpkg.com/@firebase/webchannel-wrapper/-/webchannel-wrapper-1.0.3.tgz#a73bab8eb491d7b8b7be2f0e6c310647835afe83"
15911591
integrity sha512-2xCRM9q9FlzGZCdgDMJwc0gyUkWFtkosy7Xxr6sFgQwn+wMNIWd7xIvYNauU1r64B5L5rsGKy/n9TKJ0aAFeqQ==
15921592

1593-
"@gorhom/bottom-sheet@^5.1.6":
1594-
version "5.1.6"
1595-
resolved "https://registry.yarnpkg.com/@gorhom/bottom-sheet/-/bottom-sheet-5.1.6.tgz#92365894ae4d4eefdbaa577408cfaf62463a9490"
1596-
integrity sha512-0b5tQj4fTaZAjST1PnkCp0p7d8iRqMezibTcqc8Kkn3N23Vn6upORNTD1fH0bLfwRt6e0WnZ7DjAmq315lrcKQ==
1593+
"@gorhom/bottom-sheet@5.1.8":
1594+
version "5.1.8"
1595+
resolved "https://registry.yarnpkg.com/@gorhom/bottom-sheet/-/bottom-sheet-5.1.8.tgz#65547917f5b1dae5a1291dabd4ea8bfee09feba4"
1596+
integrity sha512-QuYIVjn3K9bW20n5bgOSjvxBYoWG4YQXiLGOheEAMgISuoT6sMcA270ViSkkb0fenPxcIOwzCnFNuxmr739T9A==
15971597
dependencies:
15981598
"@gorhom/portal" "1.0.14"
15991599
invariant "^2.2.4"
16001600

1601-
"@gorhom/bottom-sheet@^5.1.8":
1602-
version "5.1.8"
1603-
resolved "https://registry.yarnpkg.com/@gorhom/bottom-sheet/-/bottom-sheet-5.1.8.tgz#65547917f5b1dae5a1291dabd4ea8bfee09feba4"
1604-
integrity sha512-QuYIVjn3K9bW20n5bgOSjvxBYoWG4YQXiLGOheEAMgISuoT6sMcA270ViSkkb0fenPxcIOwzCnFNuxmr739T9A==
1601+
"@gorhom/bottom-sheet@^5.1.6":
1602+
version "5.1.6"
1603+
resolved "https://registry.yarnpkg.com/@gorhom/bottom-sheet/-/bottom-sheet-5.1.6.tgz#92365894ae4d4eefdbaa577408cfaf62463a9490"
1604+
integrity sha512-0b5tQj4fTaZAjST1PnkCp0p7d8iRqMezibTcqc8Kkn3N23Vn6upORNTD1fH0bLfwRt6e0WnZ7DjAmq315lrcKQ==
16051605
dependencies:
16061606
"@gorhom/portal" "1.0.14"
16071607
invariant "^2.2.4"

package/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
]
6969
},
7070
"dependencies": {
71-
"@gorhom/bottom-sheet": "^5.1.8",
71+
"@gorhom/bottom-sheet": "5.1.8",
7272
"@ungap/structured-clone": "^1.3.0",
7373
"dayjs": "1.11.13",
7474
"emoji-regex": "^10.4.0",

package/src/components/Message/MessageSimple/MessageWrapper.tsx

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useCallback } from 'react';
1+
import React from 'react';
22

33
import { View } from 'react-native';
44

@@ -14,7 +14,6 @@ import { ThemeProvider, useTheme } from '../../../contexts/themeContext/ThemeCon
1414

1515
import { useStateStore } from '../../../hooks/useStateStore';
1616
import { ChannelUnreadStateStoreType } from '../../../state-store/channel-unread-state';
17-
import { MessagePreviousAndNextMessageStoreType } from '../../../state-store/message-list-prev-next-state';
1817

1918
const channelUnreadStateSelector = (state: ChannelUnreadStateStoreType) => ({
2019
first_unread_message_id: state.channelUnreadState?.first_unread_message_id,
@@ -25,10 +24,12 @@ const channelUnreadStateSelector = (state: ChannelUnreadStateStoreType) => ({
2524

2625
export type MessageWrapperProps = {
2726
message: LocalMessage;
27+
previousMessage?: LocalMessage;
28+
nextMessage?: LocalMessage;
2829
};
2930

3031
export const MessageWrapper = React.memo((props: MessageWrapperProps) => {
31-
const { message } = props;
32+
const { message, previousMessage, nextMessage } = props;
3233
const { client } = useChatContext();
3334
const {
3435
channelUnreadStateStore,
@@ -47,35 +48,23 @@ export const MessageWrapper = React.memo((props: MessageWrapperProps) => {
4748
myMessageTheme,
4849
shouldShowUnreadUnderlay,
4950
} = useMessagesContext();
50-
const {
51-
goToMessage,
52-
onThreadSelect,
53-
noGroupByUser,
54-
modifiedTheme,
55-
messageListPreviousAndNextMessageStore,
56-
} = useMessageListItemContext();
51+
const { goToMessage, onThreadSelect, noGroupByUser, modifiedTheme } = useMessageListItemContext();
5752

5853
const dateSeparatorDate = useMessageDateSeparator({
5954
hideDateSeparators,
6055
message,
61-
messageListPreviousAndNextMessageStore,
56+
previousMessage,
6257
});
6358

64-
const selector = useCallback(
65-
(state: MessagePreviousAndNextMessageStoreType) => ({
66-
nextMessage: state.messageList[message.id]?.nextMessage,
67-
}),
68-
[message.id],
69-
);
70-
const { nextMessage } = useStateStore(messageListPreviousAndNextMessageStore.state, selector);
7159
const isNewestMessage = nextMessage === undefined;
7260
const groupStyles = useMessageGroupStyles({
7361
dateSeparatorDate,
7462
getMessageGroupStyle,
7563
maxTimeBetweenGroupedMessages,
7664
message,
77-
messageListPreviousAndNextMessageStore,
65+
nextMessage,
7866
noGroupByUser,
67+
previousMessage,
7968
});
8069

8170
const { first_unread_message_id, last_read_timestamp, last_read_message_id, unread_messages } =

0 commit comments

Comments
 (0)