Skip to content

Commit 2c686a6

Browse files
authoredNov 15, 2024
Merge pull request #2788 from GetStream/develop
Next Release
2 parents 2c7e95a + 9b5b243 commit 2c686a6

File tree

3 files changed

+29
-22
lines changed

3 files changed

+29
-22
lines changed
 

‎package/src/components/ChannelPreview/hooks/__tests__/useChannelPreviewMuted.test.tsx

+7-2
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,17 @@ describe('useChannelPreviewMuted', () => {
2929
});
3030

3131
const mockChannel = {
32-
muteStatus: jest.fn().mockReturnValue(false),
32+
initialized: true,
33+
muteStatus: jest.fn().mockReturnValue({
34+
createdAt: Date.now(),
35+
expiresAt: Date.now() + 5000,
36+
muted: false,
37+
}),
3338
} as unknown as Channel<DefaultStreamChatGenerics>;
3439

3540
it('should return the correct mute status', () => {
3641
const { result } = renderHook(() => useIsChannelMuted(mockChannel));
37-
expect(result.current).toBe(false);
42+
expect(result.current.muted).toBe(false);
3843
});
3944

4045
it("should update the mute status when the notification.channel_mutes_updated event is emitted'", () => {

‎package/src/components/ChannelPreview/hooks/useIsChannelMuted.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@ export const useIsChannelMuted = <
1212
channel: Channel<StreamChatGenerics>,
1313
) => {
1414
const { client } = useChatContext<StreamChatGenerics>();
15+
const initialized = channel?.initialized;
1516

16-
const [muted, setMuted] = useState(channel.muteStatus());
17+
const [muted, setMuted] = useState(() => initialized && channel.muteStatus());
1718

1819
useEffect(() => {
1920
const handleEvent = () => {
20-
setMuted(channel.muteStatus());
21+
setMuted(initialized && channel.muteStatus());
2122
};
2223

2324
client.on('notification.channel_mutes_updated', handleEvent);
2425
return () => client.off('notification.channel_mutes_updated', handleEvent);
25-
// eslint-disable-next-line react-hooks/exhaustive-deps
26-
}, [muted]);
26+
}, [channel, client, initialized, muted]);
2727

28-
return muted;
28+
return muted || { createdAt: null, expiresAt: null, muted: false };
2929
};

‎package/src/components/MessageInput/MessageInput.tsx

+17-15
Original file line numberDiff line numberDiff line change
@@ -895,21 +895,23 @@ const MessageInputWithContext = <
895895
</View>
896896
)}
897897
{showPollCreationDialog ? (
898-
<Modal
899-
animationType='slide'
900-
onRequestClose={closePollCreationDialog}
901-
visible={showPollCreationDialog}
902-
>
903-
<GestureHandlerRootView style={{ flex: 1 }}>
904-
<SafeAreaView style={{ backgroundColor: white, flex: 1 }}>
905-
<CreatePoll
906-
closePollCreationDialog={closePollCreationDialog}
907-
CreatePollContent={CreatePollContent}
908-
sendMessage={sendMessage}
909-
/>
910-
</SafeAreaView>
911-
</GestureHandlerRootView>
912-
</Modal>
898+
<View style={{ alignItems: 'center', flex: 1, justifyContent: 'center' }}>
899+
<Modal
900+
animationType='slide'
901+
onRequestClose={closePollCreationDialog}
902+
visible={showPollCreationDialog}
903+
>
904+
<GestureHandlerRootView style={{ flex: 1 }}>
905+
<SafeAreaView style={{ backgroundColor: white, flex: 1 }}>
906+
<CreatePoll
907+
closePollCreationDialog={closePollCreationDialog}
908+
CreatePollContent={CreatePollContent}
909+
sendMessage={sendMessage}
910+
/>
911+
</SafeAreaView>
912+
</GestureHandlerRootView>
913+
</Modal>
914+
</View>
913915
) : null}
914916
</>
915917
);

0 commit comments

Comments
 (0)