Skip to content

Commit 51c9dcd

Browse files
Merge pull request #1198 from GetStream/develop
Next Release
2 parents 329c95f + 7f4d6f2 commit 51c9dcd

File tree

10 files changed

+115
-20
lines changed

10 files changed

+115
-20
lines changed

docusaurus/docs/reactnative/basics/troubleshooting.mdx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -248,14 +248,17 @@ dependencies {
248248

249249
## Blank screen when channel gets delete
250250

251-
When a channel is deleted, and if some user is active on that channel, a blank screen appears by default (as per the default logic) as we return `null` in this case. It might be confusing for end user to see a blank screen and appropriate UX would be to navigate back to channel list screen. You can implement such UX by listening to `channel.deleted` event on channel screen, and navigate to channel list screen with appropriate notification on app.
251+
When a channel is deleted, and if some user is active on that channel, a blank screen appears by default (as per the default logic) as we return `null` in this case.
252+
It might be confusing for end user to see a blank screen and appropriate UX would be to navigate back to channel list screen.
253+
You can implement such UX by listening to `channel.deleted` event on channel screen, and navigate to channel list screen with appropriate notification on app.
252254

253-
````tsx
254-
client.on('channel.deleted', (event) => {
255+
```tsx
256+
client.on('channel.deleted', event => {
255257
if (event.cid === channel.cid) {
256258
// add your action here
257259
}
258-
}),
260+
});
261+
```
259262

260263
## Touchables not working
261264

@@ -266,7 +269,7 @@ This includes ensuring you import `react-native-gesture-handler` at the top of y
266269

267270
```tsx
268271
import 'react-native-gesture-handler';
269-
````
272+
```
270273

271274
And for Android you additionally need to update `MainActivity.java` to override the method for creating the `ReactRootView`.
272275

examples/SampleApp/ios/SampleApp.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@
495495
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
496496
CLANG_ENABLE_MODULES = YES;
497497
CODE_SIGN_IDENTITY = "iPhone Distribution";
498-
CURRENT_PROJECT_VERSION = 66;
498+
CURRENT_PROJECT_VERSION = 67;
499499
DEVELOPMENT_TEAM = EHV7XZLAHA;
500500
ENABLE_BITCODE = NO;
501501
INFOPLIST_FILE = SampleApp/Info.plist;
@@ -525,7 +525,7 @@
525525
CLANG_ENABLE_MODULES = YES;
526526
CODE_SIGN_IDENTITY = "iPhone Distribution";
527527
CODE_SIGN_STYLE = Manual;
528-
CURRENT_PROJECT_VERSION = 66;
528+
CURRENT_PROJECT_VERSION = 67;
529529
DEVELOPMENT_TEAM = EHV7XZLAHA;
530530
INFOPLIST_FILE = SampleApp/Info.plist;
531531
LD_RUNPATH_SEARCH_PATHS = (

examples/SampleApp/ios/SampleApp/Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
<key>CFBundlePackageType</key>
1818
<string>APPL</string>
1919
<key>CFBundleShortVersionString</key>
20-
<string>1.0.0</string>
20+
<string>1.0.1</string>
2121
<key>CFBundleSignature</key>
2222
<string>????</string>
2323
<key>CFBundleVersion</key>
24-
<string>66</string>
24+
<string>67</string>
2525
<key>LSRequiresIPhoneOS</key>
2626
<true />
2727
<key>NSAppTransportSecurity</key>

examples/SampleApp/ios/SampleAppTests/Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
<key>CFBundlePackageType</key>
1616
<string>BNDL</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>1.0.0</string>
18+
<string>1.0.1</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>
22-
<string>66</string>
22+
<string>67</string>
2323
</dict>
2424
</plist>

package/src/components/AttachmentPicker/AttachmentPicker.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -248,13 +248,18 @@ export const AttachmentPicker = React.forwardRef(
248248
}, [selectedPicker]);
249249

250250
useEffect(() => {
251-
if (Platform.OS === 'ios') {
252-
Keyboard.addListener('keyboardWillShow', hideAttachmentPicker);
253-
} else {
254-
Keyboard.addListener('keyboardDidShow', hideAttachmentPicker);
255-
}
251+
const keyboardSubscription =
252+
Platform.OS === 'ios'
253+
? Keyboard.addListener('keyboardWillShow', hideAttachmentPicker)
254+
: Keyboard.addListener('keyboardDidShow', hideAttachmentPicker);
256255

257256
return () => {
257+
if (keyboardSubscription?.remove) {
258+
keyboardSubscription.remove();
259+
return;
260+
}
261+
262+
// To keep compatibility with older versions of React Native, where `remove()` is not available
258263
if (Platform.OS === 'ios') {
259264
Keyboard.removeListener('keyboardWillShow', hideAttachmentPicker);
260265
} else {
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import React, { useState } from 'react';
2+
import { Text } from 'react-native';
3+
4+
import { act } from 'react-test-renderer';
5+
6+
import { render, waitFor } from '@testing-library/react-native';
7+
import type { Channel, ChannelResponse, Event, StreamChat } from 'stream-chat';
8+
9+
import { ChatContext, useChannelUpdated } from '../../../../../index';
10+
11+
describe('useChannelUpdated', () => {
12+
it("defaults to the channels own_capabilities if the event doesn't include it", async () => {
13+
let eventHanler: (event: Event) => void;
14+
const mockChannel = {
15+
cid: 'channeltype:123abc',
16+
data: {
17+
own_capabilities: {
18+
send_messages: true,
19+
},
20+
},
21+
} as unknown as Channel;
22+
23+
const mockEvent = {
24+
channel: {
25+
cid: mockChannel.cid,
26+
} as ChannelResponse,
27+
type: 'channel.updated' as Event['type'],
28+
};
29+
30+
const mockClient = {
31+
off: jest.fn(),
32+
on: jest.fn().mockImplementation((_eventName: string, handler: (event: Event) => void) => {
33+
eventHanler = handler;
34+
}),
35+
} as unknown as StreamChat;
36+
37+
const TestComponent = () => {
38+
const [channels, setChannels] = useState<Channel[]>([mockChannel]);
39+
40+
useChannelUpdated({ setChannels });
41+
42+
if (
43+
channels[0].data?.own_capabilities &&
44+
Object.keys(channels[0].data?.own_capabilities as { [key: string]: boolean }).includes(
45+
'send_messages',
46+
)
47+
) {
48+
return <Text>Send messages enabled</Text>;
49+
}
50+
51+
return <Text>Send messages NOT enabled</Text>;
52+
};
53+
54+
const { getByText } = await waitFor(() =>
55+
render(
56+
<ChatContext.Provider
57+
value={{
58+
client: mockClient,
59+
connectionRecovering: false,
60+
isOnline: true,
61+
mutedUsers: [],
62+
setActiveChannel: () => null,
63+
}}
64+
>
65+
<TestComponent />
66+
</ChatContext.Provider>,
67+
),
68+
);
69+
70+
await waitFor(() => {
71+
expect(getByText('Send messages enabled')).toBeTruthy();
72+
});
73+
74+
act(() => {
75+
eventHanler(mockEvent);
76+
});
77+
78+
await waitFor(() => {
79+
expect(getByText('Send messages enabled')).toBeTruthy();
80+
});
81+
});
82+
});

package/src/components/ChannelList/hooks/listeners/useChannelUpdated.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,14 @@ export const useChannelUpdated = <
3333
(channel) => channel.cid === (event.cid || event.channel?.cid),
3434
);
3535
if (index >= 0 && event.channel) {
36-
channels[index].data = event.channel;
36+
channels[index].data = {
37+
...event.channel,
38+
hidden: event.channel?.hidden ?? channels[index].data?.hidden,
39+
own_capabilities:
40+
event.channel?.own_capabilities ?? channels[index].data?.own_capabilities,
41+
};
3742
}
43+
3844
return [...channels];
3945
});
4046
}

package/src/components/ChannelList/hooks/usePaginatedChannels.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export const usePaginatedChannels = <
6161

6262
const hasUpdatedData =
6363
queryType === 'loadChannels' ||
64+
queryType === 'refresh' ||
6465
[
6566
JSON.stringify(filtersRef.current) !== JSON.stringify(filters),
6667
JSON.stringify(sortRef.current) !== JSON.stringify(sort),

package/src/components/MessageOverlay/MessageOverlay.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ export type MessageOverlayPropsWithContext<
100100
| 'message'
101101
| 'messageReactions'
102102
| 'messageTextNumberOfLines'
103-
| 'overlayOpacity'
104103
> & {
104+
overlayOpacity: Animated.SharedValue<number>;
105105
showScreen?: Animated.SharedValue<number>;
106106
};
107107

package/src/contexts/overlayContext/OverlayContext.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React, { useContext } from 'react';
2-
import type Animated from 'react-native-reanimated';
32

43
import type { BottomSheetMethods } from '@gorhom/bottom-sheet/lib/typescript/types';
54

@@ -53,7 +52,6 @@ export type OverlayProviderProps<
5352
>
5453
> &
5554
Pick<OverlayContextValue, 'translucentStatusBar'> & {
56-
overlayOpacity: Animated.SharedValue<number>;
5755
closePicker?: (ref: React.RefObject<BottomSheetMethods>) => void;
5856
error?: boolean | Error;
5957
/** https://github.com/GetStream/stream-chat-react-native/wiki/Internationalization-(i18n) */

0 commit comments

Comments
 (0)