From 437216f129b02541d8b7b2e857871bac3a71447c Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Thu, 14 Nov 2024 15:10:45 +0000 Subject: [PATCH 01/20] chore(release): 5.42.0 [skip ci] --- package/CHANGELOG.md | 12 ++++++++++++ package/expo-package/package.json | 4 ++-- package/native-package/package.json | 4 ++-- package/package.json | 2 +- package/src/version.json | 2 +- 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/package/CHANGELOG.md b/package/CHANGELOG.md index d733364c4..86e96a10f 100644 --- a/package/CHANGELOG.md +++ b/package/CHANGELOG.md @@ -1,5 +1,17 @@ # Change Log +## [5.42.0](https://github.com/GetStream/stream-chat-react-native/compare/v5.41.4...v5.42.0) (2024-11-14) + + +### Features + +* listen to notification.mark_read and notification.mark_unread event and introduce improvements ([#2776](https://github.com/GetStream/stream-chat-react-native/issues/2776)) ([834d124](https://github.com/GetStream/stream-chat-react-native/commit/834d124c9bb8c9ffc24537a5fe870009fd00e3fa)) + + +### Bug Fixes + +* scroll to recent issues ([#2775](https://github.com/GetStream/stream-chat-react-native/issues/2775)) ([feea8ee](https://github.com/GetStream/stream-chat-react-native/commit/feea8ee4588d4a048e52d5c719aaf6f6c4011454)) + ### [5.41.4](https://github.com/GetStream/stream-chat-react-native/compare/v5.41.3...v5.41.4) (2024-11-08) diff --git a/package/expo-package/package.json b/package/expo-package/package.json index 36cb2af8b..e89567123 100644 --- a/package/expo-package/package.json +++ b/package/expo-package/package.json @@ -1,7 +1,7 @@ { "name": "stream-chat-expo", "description": "The official Expo SDK for Stream Chat, a service for building chat applications", - "version": "5.41.4", + "version": "5.42.0", "author": { "company": "Stream.io Inc", "name": "Stream.io Inc" @@ -10,7 +10,7 @@ "main": "src/index.js", "types": "types/index.d.ts", "dependencies": { - "stream-chat-react-native-core": "5.41.4" + "stream-chat-react-native-core": "5.42.0" }, "peerDependencies": { "@react-native-community/netinfo": ">=6.0.0", diff --git a/package/native-package/package.json b/package/native-package/package.json index 6e54415b1..4142abb17 100644 --- a/package/native-package/package.json +++ b/package/native-package/package.json @@ -1,7 +1,7 @@ { "name": "stream-chat-react-native", "description": "The official React Native SDK for Stream Chat, a service for building chat applications", - "version": "5.41.4", + "version": "5.42.0", "author": { "company": "Stream.io Inc", "name": "Stream.io Inc" @@ -11,7 +11,7 @@ "types": "types/index.d.ts", "dependencies": { "es6-symbol": "^3.1.3", - "stream-chat-react-native-core": "5.41.4" + "stream-chat-react-native-core": "5.42.0" }, "peerDependencies": { "@react-native-camera-roll/camera-roll": ">=5.0.0", diff --git a/package/package.json b/package/package.json index 797f48796..a5e645365 100644 --- a/package/package.json +++ b/package/package.json @@ -1,7 +1,7 @@ { "name": "stream-chat-react-native-core", "description": "The official React Native and Expo components for Stream Chat, a service for building chat applications", - "version": "5.41.4", + "version": "5.42.0", "author": { "company": "Stream.io Inc", "name": "Stream.io Inc" diff --git a/package/src/version.json b/package/src/version.json index 8be309d7f..b3641171b 100644 --- a/package/src/version.json +++ b/package/src/version.json @@ -1,3 +1,3 @@ { - "version": "5.41.4" + "version": "5.42.0" } From 2c7e95a7d40e6d6fb5b17809c94937c71bc13eda Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Thu, 14 Nov 2024 15:12:20 +0000 Subject: [PATCH 02/20] chore(release): 1.31.6 [skip ci] --- examples/SampleApp/CHANGELOG.md | 7 +++++++ examples/SampleApp/package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/examples/SampleApp/CHANGELOG.md b/examples/SampleApp/CHANGELOG.md index 449abe685..edd36379a 100644 --- a/examples/SampleApp/CHANGELOG.md +++ b/examples/SampleApp/CHANGELOG.md @@ -1,5 +1,12 @@ # Change Log +### [1.31.6](https://github.com/GetStream/stream-chat-react-native/compare/sampleapp@v1.31.5...sampleapp@v1.31.6) (2024-11-14) + + +### Workspaces + +* Following linked packages updated: [stream-chat-react-native] + ### [1.31.5](https://github.com/GetStream/stream-chat-react-native/compare/sampleapp@v1.31.4...sampleapp@v1.31.5) (2024-11-08) diff --git a/examples/SampleApp/package.json b/examples/SampleApp/package.json index dd5e1d3fe..009edb6c3 100644 --- a/examples/SampleApp/package.json +++ b/examples/SampleApp/package.json @@ -1,6 +1,6 @@ { "name": "sampleapp", - "version": "1.31.5", + "version": "1.31.6", "private": true, "repository": { "type": "git", From fe646976782353836ee5ca58058125e7b9c53132 Mon Sep 17 00:00:00 2001 From: Ivan Sekovanikj <31964049+isekovanic@users.noreply.github.com> Date: Fri, 15 Nov 2024 16:49:02 +0100 Subject: [PATCH 03/20] fix: android modal size (#2784) --- .../components/MessageInput/MessageInput.tsx | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/package/src/components/MessageInput/MessageInput.tsx b/package/src/components/MessageInput/MessageInput.tsx index 57c642a4b..2a5eb598c 100644 --- a/package/src/components/MessageInput/MessageInput.tsx +++ b/package/src/components/MessageInput/MessageInput.tsx @@ -895,21 +895,23 @@ const MessageInputWithContext = < )} {showPollCreationDialog ? ( - - - - - - - + + + + + + + + + ) : null} ); From 9b5b243cf91bc80a1fbe50913dbbdc954c973bca Mon Sep 17 00:00:00 2001 From: Ivan Sekovanikj <31964049+isekovanic@users.noreply.github.com> Date: Fri, 15 Nov 2024 16:55:07 +0100 Subject: [PATCH 04/20] fix: backport crash fix (#2787) * fix: crash in some instances of useIsChannelMuted hook invocation * fix: properly use hook in channel preview * fix: edge cases and test --- .../hooks/__tests__/useChannelPreviewMuted.test.tsx | 9 +++++++-- .../ChannelPreview/hooks/useIsChannelMuted.ts | 10 +++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/package/src/components/ChannelPreview/hooks/__tests__/useChannelPreviewMuted.test.tsx b/package/src/components/ChannelPreview/hooks/__tests__/useChannelPreviewMuted.test.tsx index f39d28316..1d52486f2 100644 --- a/package/src/components/ChannelPreview/hooks/__tests__/useChannelPreviewMuted.test.tsx +++ b/package/src/components/ChannelPreview/hooks/__tests__/useChannelPreviewMuted.test.tsx @@ -29,12 +29,17 @@ describe('useChannelPreviewMuted', () => { }); const mockChannel = { - muteStatus: jest.fn().mockReturnValue(false), + initialized: true, + muteStatus: jest.fn().mockReturnValue({ + createdAt: Date.now(), + expiresAt: Date.now() + 5000, + muted: false, + }), } as unknown as Channel; it('should return the correct mute status', () => { const { result } = renderHook(() => useIsChannelMuted(mockChannel)); - expect(result.current).toBe(false); + expect(result.current.muted).toBe(false); }); it("should update the mute status when the notification.channel_mutes_updated event is emitted'", () => { diff --git a/package/src/components/ChannelPreview/hooks/useIsChannelMuted.ts b/package/src/components/ChannelPreview/hooks/useIsChannelMuted.ts index 9b8e87fc3..580bd0c41 100644 --- a/package/src/components/ChannelPreview/hooks/useIsChannelMuted.ts +++ b/package/src/components/ChannelPreview/hooks/useIsChannelMuted.ts @@ -12,18 +12,18 @@ export const useIsChannelMuted = < channel: Channel, ) => { const { client } = useChatContext(); + const initialized = channel?.initialized; - const [muted, setMuted] = useState(channel.muteStatus()); + const [muted, setMuted] = useState(() => initialized && channel.muteStatus()); useEffect(() => { const handleEvent = () => { - setMuted(channel.muteStatus()); + setMuted(initialized && channel.muteStatus()); }; client.on('notification.channel_mutes_updated', handleEvent); return () => client.off('notification.channel_mutes_updated', handleEvent); - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [muted]); + }, [channel, client, initialized, muted]); - return muted; + return muted || { createdAt: null, expiresAt: null, muted: false }; }; From 75c39072c2e5f8a570f394b337cce366b82ac756 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Fri, 15 Nov 2024 16:17:37 +0000 Subject: [PATCH 05/20] chore(release): 5.42.1 [skip ci] --- package/CHANGELOG.md | 8 ++++++++ package/expo-package/package.json | 4 ++-- package/expo-package/yarn.lock | 18 +++++++++--------- package/native-package/package.json | 4 ++-- package/native-package/yarn.lock | 18 +++++++++--------- package/package.json | 2 +- package/src/version.json | 2 +- 7 files changed, 32 insertions(+), 24 deletions(-) diff --git a/package/CHANGELOG.md b/package/CHANGELOG.md index 86e96a10f..1195010ad 100644 --- a/package/CHANGELOG.md +++ b/package/CHANGELOG.md @@ -1,5 +1,13 @@ # Change Log +### [5.42.1](https://github.com/GetStream/stream-chat-react-native/compare/v5.42.0...v5.42.1) (2024-11-15) + + +### Bug Fixes + +* android modal size ([#2784](https://github.com/GetStream/stream-chat-react-native/issues/2784)) ([fe64697](https://github.com/GetStream/stream-chat-react-native/commit/fe646976782353836ee5ca58058125e7b9c53132)) +* backport crash fix ([#2787](https://github.com/GetStream/stream-chat-react-native/issues/2787)) ([9b5b243](https://github.com/GetStream/stream-chat-react-native/commit/9b5b243cf91bc80a1fbe50913dbbdc954c973bca)) + ## [5.42.0](https://github.com/GetStream/stream-chat-react-native/compare/v5.41.4...v5.42.0) (2024-11-14) diff --git a/package/expo-package/package.json b/package/expo-package/package.json index e89567123..b67045576 100644 --- a/package/expo-package/package.json +++ b/package/expo-package/package.json @@ -1,7 +1,7 @@ { "name": "stream-chat-expo", "description": "The official Expo SDK for Stream Chat, a service for building chat applications", - "version": "5.42.0", + "version": "5.42.1", "author": { "company": "Stream.io Inc", "name": "Stream.io Inc" @@ -10,7 +10,7 @@ "main": "src/index.js", "types": "types/index.d.ts", "dependencies": { - "stream-chat-react-native-core": "5.42.0" + "stream-chat-react-native-core": "5.42.1" }, "peerDependencies": { "@react-native-community/netinfo": ">=6.0.0", diff --git a/package/expo-package/yarn.lock b/package/expo-package/yarn.lock index 36c806cea..e4aec101d 100644 --- a/package/expo-package/yarn.lock +++ b/package/expo-package/yarn.lock @@ -2929,10 +2929,10 @@ stream-buffers@2.2.x: resolved "https://registry.yarnpkg.com/stream-buffers/-/stream-buffers-2.2.0.tgz#91d5f5130d1cef96dcfa7f726945188741d09ee4" integrity sha512-uyQK/mx5QjHun80FLJTfaWE7JtwfRMKBLkMne6udYOmvH0CawotVa7TfgYHzAnpphn4+TweIx1QKMnRIbipmUg== -stream-chat-react-native-core@5.41.4: - version "5.41.4" - resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.41.4.tgz#55104e1eb10f464b27d82b9566a18005723ea26d" - integrity sha512-Fe2AnbfZ98nRfP5BwMOwR2iae/hT8N5oEiYOb2FwbgtJqot4UFABZDCxMVcoYcFouOK1gc5BkTjdnXYYm/L8EQ== +stream-chat-react-native-core@5.42.0: + version "5.42.0" + resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.42.0.tgz#874751a43f7983ce8fac752951f0353f40afcc97" + integrity sha512-3HI8cBF/5gyWq850YbgsgTxvYSDNFNC0uZTJETMnW5qURyvJAKktyUlVhjilCuD5LI4CBgXdCD+o6qv52JM0Ww== dependencies: "@gorhom/bottom-sheet" "^4.6.4" dayjs "1.10.5" @@ -2945,12 +2945,12 @@ stream-chat-react-native-core@5.41.4: path "0.12.7" react-native-markdown-package "1.8.2" react-native-url-polyfill "^1.3.0" - stream-chat "8.42.0" + stream-chat "8.44.0" -stream-chat@8.42.0: - version "8.42.0" - resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-8.42.0.tgz#124ea2c10c6e8f7990304e1101c66751daf63e6c" - integrity sha512-8xZz+fmdHSOa3L1rHUOC4Wah+ipvLvdiOmeOfGK6uXnLOKlSHMOblwmQErrOoFM4SKfX9Bea3V8viaKUu6bPng== +stream-chat@8.44.0: + version "8.44.0" + resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-8.44.0.tgz#e48446cf91db786e80a2e7358ac4f1601e5e97f0" + integrity sha512-7HNtimD8sT/51rsFibGcD6uBgKj+vlKyYCZMDzjYQEaEsrLqyAg48dOyNM4L2FTF5aXgo9SlxZr21SPleeA2BA== dependencies: "@babel/runtime" "^7.16.3" "@types/jsonwebtoken" "~9.0.0" diff --git a/package/native-package/package.json b/package/native-package/package.json index 4142abb17..fa7975fa2 100644 --- a/package/native-package/package.json +++ b/package/native-package/package.json @@ -1,7 +1,7 @@ { "name": "stream-chat-react-native", "description": "The official React Native SDK for Stream Chat, a service for building chat applications", - "version": "5.42.0", + "version": "5.42.1", "author": { "company": "Stream.io Inc", "name": "Stream.io Inc" @@ -11,7 +11,7 @@ "types": "types/index.d.ts", "dependencies": { "es6-symbol": "^3.1.3", - "stream-chat-react-native-core": "5.42.0" + "stream-chat-react-native-core": "5.42.1" }, "peerDependencies": { "@react-native-camera-roll/camera-roll": ">=5.0.0", diff --git a/package/native-package/yarn.lock b/package/native-package/yarn.lock index 6d776c1e0..4c0ae0ab2 100644 --- a/package/native-package/yarn.lock +++ b/package/native-package/yarn.lock @@ -4244,10 +4244,10 @@ statuses@~1.5.0: resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" integrity sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA== -stream-chat-react-native-core@5.41.4: - version "5.41.4" - resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.41.4.tgz#55104e1eb10f464b27d82b9566a18005723ea26d" - integrity sha512-Fe2AnbfZ98nRfP5BwMOwR2iae/hT8N5oEiYOb2FwbgtJqot4UFABZDCxMVcoYcFouOK1gc5BkTjdnXYYm/L8EQ== +stream-chat-react-native-core@5.42.0: + version "5.42.0" + resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.42.0.tgz#874751a43f7983ce8fac752951f0353f40afcc97" + integrity sha512-3HI8cBF/5gyWq850YbgsgTxvYSDNFNC0uZTJETMnW5qURyvJAKktyUlVhjilCuD5LI4CBgXdCD+o6qv52JM0Ww== dependencies: "@gorhom/bottom-sheet" "^4.6.4" dayjs "1.10.5" @@ -4260,12 +4260,12 @@ stream-chat-react-native-core@5.41.4: path "0.12.7" react-native-markdown-package "1.8.2" react-native-url-polyfill "^1.3.0" - stream-chat "8.42.0" + stream-chat "8.44.0" -stream-chat@8.42.0: - version "8.42.0" - resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-8.42.0.tgz#124ea2c10c6e8f7990304e1101c66751daf63e6c" - integrity sha512-8xZz+fmdHSOa3L1rHUOC4Wah+ipvLvdiOmeOfGK6uXnLOKlSHMOblwmQErrOoFM4SKfX9Bea3V8viaKUu6bPng== +stream-chat@8.44.0: + version "8.44.0" + resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-8.44.0.tgz#e48446cf91db786e80a2e7358ac4f1601e5e97f0" + integrity sha512-7HNtimD8sT/51rsFibGcD6uBgKj+vlKyYCZMDzjYQEaEsrLqyAg48dOyNM4L2FTF5aXgo9SlxZr21SPleeA2BA== dependencies: "@babel/runtime" "^7.16.3" "@types/jsonwebtoken" "~9.0.0" diff --git a/package/package.json b/package/package.json index a5e645365..8d8495397 100644 --- a/package/package.json +++ b/package/package.json @@ -1,7 +1,7 @@ { "name": "stream-chat-react-native-core", "description": "The official React Native and Expo components for Stream Chat, a service for building chat applications", - "version": "5.42.0", + "version": "5.42.1", "author": { "company": "Stream.io Inc", "name": "Stream.io Inc" diff --git a/package/src/version.json b/package/src/version.json index b3641171b..e802ac3c4 100644 --- a/package/src/version.json +++ b/package/src/version.json @@ -1,3 +1,3 @@ { - "version": "5.42.0" + "version": "5.42.1" } From ddd4581ce9cac4f340f8fc36a452b0d5842a6605 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Fri, 15 Nov 2024 16:18:54 +0000 Subject: [PATCH 06/20] chore(release): 1.31.7 [skip ci] --- examples/SampleApp/CHANGELOG.md | 7 +++++++ examples/SampleApp/package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/examples/SampleApp/CHANGELOG.md b/examples/SampleApp/CHANGELOG.md index edd36379a..69597c89f 100644 --- a/examples/SampleApp/CHANGELOG.md +++ b/examples/SampleApp/CHANGELOG.md @@ -1,5 +1,12 @@ # Change Log +### [1.31.7](https://github.com/GetStream/stream-chat-react-native/compare/sampleapp@v1.31.6...sampleapp@v1.31.7) (2024-11-15) + + +### Workspaces + +* Following linked packages updated: [stream-chat-react-native] + ### [1.31.6](https://github.com/GetStream/stream-chat-react-native/compare/sampleapp@v1.31.5...sampleapp@v1.31.6) (2024-11-14) diff --git a/examples/SampleApp/package.json b/examples/SampleApp/package.json index 009edb6c3..cb3acf163 100644 --- a/examples/SampleApp/package.json +++ b/examples/SampleApp/package.json @@ -1,6 +1,6 @@ { "name": "sampleapp", - "version": "1.31.6", + "version": "1.31.7", "private": true, "repository": { "type": "git", From e6908e9ddfa1722d1f610cb0d4d5be2c05f910e1 Mon Sep 17 00:00:00 2001 From: Ivan Sekovanikj <31964049+isekovanic@users.noreply.github.com> Date: Mon, 18 Nov 2024 17:02:54 +0100 Subject: [PATCH 07/20] fix: recursion depth on regex parse issue (#2790) --- .../Message/MessageSimple/utils/generateMarkdownText.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/package/src/components/Message/MessageSimple/utils/generateMarkdownText.ts b/package/src/components/Message/MessageSimple/utils/generateMarkdownText.ts index 2851be137..4e116cc4f 100644 --- a/package/src/components/Message/MessageSimple/utils/generateMarkdownText.ts +++ b/package/src/components/Message/MessageSimple/utils/generateMarkdownText.ts @@ -35,5 +35,11 @@ export const generateMarkdownText = (text?: string) => { resultText = resultText.replace(/[<"'>]/g, '\\$&'); + // Remove whitespaces that come directly after newlines except in code blocks where we deem this allowed. + resultText = resultText.replace(/(```[\s\S]*?```|`.*?`)|\n[ ]{2,}/g, (_, code) => { + if (code) return code; + return '\n'; + }); + return resultText; }; From e8e3dd0af396671949f3c12086816329a962dd08 Mon Sep 17 00:00:00 2001 From: Ivan Sekovanikj Date: Tue, 19 Nov 2024 13:33:01 +0100 Subject: [PATCH 08/20] fix: channel hook regressions --- .../ChannelPreview/ChannelPreview.tsx | 12 ++-- .../__tests__/ChannelPreview.test.tsx | 39 ++++++------ .../hooks/useChannelPreviewData.ts | 60 ++++++++++++++++--- 3 files changed, 78 insertions(+), 33 deletions(-) diff --git a/package/src/components/ChannelPreview/ChannelPreview.tsx b/package/src/components/ChannelPreview/ChannelPreview.tsx index 7eec3e32c..fb8edbbed 100644 --- a/package/src/components/ChannelPreview/ChannelPreview.tsx +++ b/package/src/components/ChannelPreview/ChannelPreview.tsx @@ -3,7 +3,6 @@ import React from 'react'; import type { Channel } from 'stream-chat'; import { useChannelPreviewData } from './hooks/useChannelPreviewData'; -import { useLatestMessagePreview } from './hooks/useLatestMessagePreview'; import { ChannelsContextValue, @@ -31,15 +30,16 @@ export const ChannelPreview = < const { channel, client: propClient, forceUpdate: propForceUpdate, Preview: propPreview } = props; const { client: contextClient } = useChatContext(); - const { forceUpdate: contextForceUpdate, Preview: contextPreview } = - useChannelsContext(); + const { Preview: contextPreview } = useChannelsContext(); const client = propClient || contextClient; - const forceUpdate = propForceUpdate || contextForceUpdate; const Preview = propPreview || contextPreview; - const { lastMessage, muted, unread } = useChannelPreviewData(channel, client, forceUpdate); - const latestMessagePreview = useLatestMessagePreview(channel, forceUpdate, lastMessage); + const { latestMessagePreview, muted, unread } = useChannelPreviewData( + channel, + client, + propForceUpdate, + ); return ( { ); }; + const generateChannelWrapper = (overrides: Record) => + generateChannel({ + countUnread: jest.fn().mockReturnValue(0), + initialized: true, + lastMessage: jest.fn().mockReturnValue(generateMessage()), + muteStatus: jest.fn().mockReturnValue({ muted: false }), + ...overrides, + }); + const useInitializeChannel = async (c: GetOrCreateChannelApiParams) => { useMockedApis(chatClient, [getOrCreateChannelApi(c)]); @@ -89,9 +98,8 @@ describe('ChannelPreview', () => { it("should not update the unread count if the event's cid does not match the channel's cid", async () => { const channelOnMock = jest.fn().mockReturnValue({ unsubscribe: jest.fn() }); - const c = generateChannel({ + const c = generateChannelWrapper({ countUnread: jest.fn().mockReturnValue(10), - muteStatus: jest.fn().mockReturnValue({ muted: false }), on: channelOnMock, }); @@ -117,9 +125,8 @@ describe('ChannelPreview', () => { it('should update the unread count to 0', async () => { const channelOnMock = jest.fn().mockReturnValue({ unsubscribe: jest.fn() }); - const c = generateChannel({ + const c = generateChannelWrapper({ countUnread: jest.fn().mockReturnValue(10), - muteStatus: jest.fn().mockReturnValue({ muted: false }), on: channelOnMock, }); @@ -147,9 +154,7 @@ describe('ChannelPreview', () => { it("should not update the unread count if the event's cid is undefined", async () => { const channelOnMock = jest.fn().mockReturnValue({ unsubscribe: jest.fn() }); - const c = generateChannel({ - countUnread: jest.fn().mockReturnValue(0), - muteStatus: jest.fn().mockReturnValue({ muted: false }), + const c = generateChannelWrapper({ on: channelOnMock, }); @@ -182,9 +187,7 @@ describe('ChannelPreview', () => { it("should not update the unread count if the event's cid does not match the channel's cid", async () => { const channelOnMock = jest.fn().mockReturnValue({ unsubscribe: jest.fn() }); - const c = generateChannel({ - countUnread: jest.fn().mockReturnValue(0), - muteStatus: jest.fn().mockReturnValue({ muted: false }), + const c = generateChannelWrapper({ on: channelOnMock, }); @@ -217,9 +220,7 @@ describe('ChannelPreview', () => { it("should not update the unread count if the event's user id does not match the client's user id", async () => { const channelOnMock = jest.fn().mockReturnValue({ unsubscribe: jest.fn() }); - const c = generateChannel({ - countUnread: jest.fn().mockReturnValue(0), - muteStatus: jest.fn().mockReturnValue({ muted: false }), + const c = generateChannelWrapper({ on: channelOnMock, }); @@ -255,12 +256,10 @@ describe('ChannelPreview', () => { await useInitializeChannel(c); const channelOnMock = jest.fn().mockReturnValue({ unsubscribe: jest.fn() }); - const testChannel = { + const testChannel = generateChannelWrapper({ ...channel, - countUnread: jest.fn().mockReturnValue(0), - muteStatus: jest.fn().mockReturnValue({ muted: false }), on: channelOnMock, - }; + }); const { getByTestId } = render(); @@ -291,9 +290,9 @@ describe('ChannelPreview', () => { it('should update the unread count to 0 if the channel is muted', async () => { const channelOnMock = jest.fn().mockReturnValue({ unsubscribe: jest.fn() }); - const c = generateChannel({ + const c = generateChannelWrapper({ countUnread: jest.fn().mockReturnValue(10), - muteStatus: jest.fn().mockReturnValue({ muted: false }), + muteStatus: jest.fn().mockReturnValue({ muted: true }), on: channelOnMock, }); @@ -304,7 +303,7 @@ describe('ChannelPreview', () => { await waitFor(() => getByTestId('channel-id')); await waitFor(() => { - expect(getByTestId('unread-count')).toHaveTextContent('10'); + expect(getByTestId('unread-count')).toHaveTextContent('0'); }); act(() => { diff --git a/package/src/components/ChannelPreview/hooks/useChannelPreviewData.ts b/package/src/components/ChannelPreview/hooks/useChannelPreviewData.ts index 5fe2dae30..8b35a1685 100644 --- a/package/src/components/ChannelPreview/hooks/useChannelPreviewData.ts +++ b/package/src/components/ChannelPreview/hooks/useChannelPreviewData.ts @@ -5,6 +5,9 @@ import type { Channel, ChannelState, Event, MessageResponse, StreamChat } from ' import { useIsChannelMuted } from './useIsChannelMuted'; +import { useLatestMessagePreview } from './useLatestMessagePreview'; + +import { useChannelsContext } from '../../../contexts'; import type { DefaultStreamChatGenerics } from '../../../types/types'; export const useChannelPreviewData = < @@ -12,14 +15,33 @@ export const useChannelPreviewData = < >( channel: Channel, client: StreamChat, - forceUpdate?: number, + forceUpdateOverride?: number, ) => { + const [forceUpdate, setForceUpdate] = useState(0); const [lastMessage, setLastMessage] = useState< | ReturnType['formatMessage']> | MessageResponse >(channel.state.messages[channel.state.messages.length - 1]); const [unread, setUnread] = useState(channel.countUnread()); const { muted } = useIsChannelMuted(channel); + const { forceUpdate: contextForceUpdate } = useChannelsContext(); + const channelListForceUpdate = forceUpdateOverride ?? contextForceUpdate; + + const channelLastMessage = channel.lastMessage(); + const channelLastMessageString = `${channelLastMessage?.id}${channelLastMessage?.updated_at}`; + + useEffect(() => { + if ( + channelLastMessage && + (channelLastMessage.id !== lastMessage?.id || + channelLastMessage.updated_at !== lastMessage?.updated_at) + ) { + setLastMessage(channelLastMessage); + } + const newUnreadCount = channel.countUnread(); + setUnread(newUnreadCount); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [channel, channelLastMessageString, channelListForceUpdate]); /** * This effect listens for the `notification.mark_read` event and sets the unread count to 0 @@ -27,7 +49,12 @@ export const useChannelPreviewData = < useEffect(() => { const handleReadEvent = (event: Event) => { if (!event.cid) return; - if (channel.cid === event.cid) setUnread(0); + if (channel.cid !== event.cid) return; + if (event?.user?.id === client.userID) { + setUnread(0); + } else if (event?.user?.id) { + setForceUpdate((prev) => prev + 1); + } }; const { unsubscribe } = client.on('notification.mark_read', handleReadEvent); return unsubscribe; @@ -70,16 +97,35 @@ export const useChannelPreviewData = < refreshUnreadCount(); }; + const handleNewMessageEvent = (event: Event) => { + const message = event.message; + if (message && (!message.parent_id || message.show_in_channel)) { + setLastMessage(message); + setUnread(channel.countUnread()); + } + }; + + const handleUpdatedOrDeletedMessage = (event: Event) => { + setLastMessage((prevLastMessage) => { + if (prevLastMessage?.id === event.message?.id) { + return event.message; + } + return prevLastMessage; + }); + }; + const listeners = [ - channel.on('message.new', handleEvent), - channel.on('message.updated', handleEvent), - channel.on('message.deleted', handleEvent), + channel.on('message.new', handleNewMessageEvent), + channel.on('message.updated', handleUpdatedOrDeletedMessage), + channel.on('message.deleted', handleUpdatedOrDeletedMessage), channel.on('message.undeleted', handleEvent), channel.on('channel.truncated', handleEvent), ]; return () => listeners.forEach((l) => l.unsubscribe()); - }, [channel, refreshUnreadCount, forceUpdate]); + }, [channel, refreshUnreadCount, forceUpdate, channelListForceUpdate]); + + const latestMessagePreview = useLatestMessagePreview(channel, forceUpdate, lastMessage); - return { lastMessage, muted, unread }; + return { latestMessagePreview, muted, unread }; }; From fc9b908799a3d517a64b6388bdfd268c2dc16981 Mon Sep 17 00:00:00 2001 From: Ivan Sekovanikj Date: Tue, 19 Nov 2024 15:45:53 +0100 Subject: [PATCH 09/20] fix: expo media library permissions race conditions --- package/expo-package/src/optionalDependencies/pickImage.ts | 2 ++ package/native-package/src/optionalDependencies/pickImage.ts | 1 + 2 files changed, 3 insertions(+) diff --git a/package/expo-package/src/optionalDependencies/pickImage.ts b/package/expo-package/src/optionalDependencies/pickImage.ts index 9d2ce1153..fa6b98d03 100644 --- a/package/expo-package/src/optionalDependencies/pickImage.ts +++ b/package/expo-package/src/optionalDependencies/pickImage.ts @@ -53,8 +53,10 @@ export const pickImage = ImagePicker return { cancelled: true }; } } + return { cancelled: true }; } catch (error) { console.log('Error while picking image', error); + return { cancelled: true }; } } : null; diff --git a/package/native-package/src/optionalDependencies/pickImage.ts b/package/native-package/src/optionalDependencies/pickImage.ts index 574c1538e..5ab35fcd7 100644 --- a/package/native-package/src/optionalDependencies/pickImage.ts +++ b/package/native-package/src/optionalDependencies/pickImage.ts @@ -35,6 +35,7 @@ export const pickImage = ImagePicker } } catch (error) { console.log('Error picking image: ', error); + return { cancelled: true }; } } : null; From 5a58a65106d963cd95d3d2df31afe2459b2b902e Mon Sep 17 00:00:00 2001 From: Ivan Sekovanikj Date: Tue, 19 Nov 2024 18:31:21 +0100 Subject: [PATCH 10/20] fix: listen to correct channel read events --- .../ChannelPreview/hooks/useChannelPreviewData.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/package/src/components/ChannelPreview/hooks/useChannelPreviewData.ts b/package/src/components/ChannelPreview/hooks/useChannelPreviewData.ts index 8b35a1685..a678e7042 100644 --- a/package/src/components/ChannelPreview/hooks/useChannelPreviewData.ts +++ b/package/src/components/ChannelPreview/hooks/useChannelPreviewData.ts @@ -30,6 +30,13 @@ export const useChannelPreviewData = < const channelLastMessage = channel.lastMessage(); const channelLastMessageString = `${channelLastMessage?.id}${channelLastMessage?.updated_at}`; + useEffect(() => { + const { unsubscribe } = client.on('notification.mark_read', () => { + setUnread(channel.countUnread()); + }); + return unsubscribe; + }, [channel, client]); + useEffect(() => { if ( channelLastMessage && @@ -56,7 +63,7 @@ export const useChannelPreviewData = < setForceUpdate((prev) => prev + 1); } }; - const { unsubscribe } = client.on('notification.mark_read', handleReadEvent); + const { unsubscribe } = client.on('message.read', handleReadEvent); return unsubscribe; }, [client, channel]); From f021dd33ee14d08db7d8d26fb92039687719ece6 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Tue, 19 Nov 2024 21:25:07 +0000 Subject: [PATCH 11/20] chore(release): 5.42.2 [skip ci] --- package/CHANGELOG.md | 11 +++++++++++ package/expo-package/package.json | 4 ++-- package/expo-package/yarn.lock | 8 ++++---- package/native-package/package.json | 4 ++-- package/native-package/yarn.lock | 8 ++++---- package/package.json | 2 +- package/src/version.json | 2 +- 7 files changed, 25 insertions(+), 14 deletions(-) diff --git a/package/CHANGELOG.md b/package/CHANGELOG.md index 1195010ad..40abc5ed7 100644 --- a/package/CHANGELOG.md +++ b/package/CHANGELOG.md @@ -1,5 +1,16 @@ # Change Log +### [5.42.2](https://github.com/GetStream/stream-chat-react-native/compare/v5.42.1...v5.42.2) (2024-11-19) + + +### Bug Fixes + +* backporting variety fixes ([008cf01](https://github.com/GetStream/stream-chat-react-native/commit/008cf01ddaa31e105ac2bab7052e1340b7583507)) +* channel hook regressions ([e8e3dd0](https://github.com/GetStream/stream-chat-react-native/commit/e8e3dd0af396671949f3c12086816329a962dd08)) +* expo media library permissions race conditions ([fc9b908](https://github.com/GetStream/stream-chat-react-native/commit/fc9b908799a3d517a64b6388bdfd268c2dc16981)) +* listen to correct channel read events ([5a58a65](https://github.com/GetStream/stream-chat-react-native/commit/5a58a65106d963cd95d3d2df31afe2459b2b902e)) +* recursion depth on regex parse issue ([#2790](https://github.com/GetStream/stream-chat-react-native/issues/2790)) ([e6908e9](https://github.com/GetStream/stream-chat-react-native/commit/e6908e9ddfa1722d1f610cb0d4d5be2c05f910e1)) + ### [5.42.1](https://github.com/GetStream/stream-chat-react-native/compare/v5.42.0...v5.42.1) (2024-11-15) diff --git a/package/expo-package/package.json b/package/expo-package/package.json index b67045576..52588dce9 100644 --- a/package/expo-package/package.json +++ b/package/expo-package/package.json @@ -1,7 +1,7 @@ { "name": "stream-chat-expo", "description": "The official Expo SDK for Stream Chat, a service for building chat applications", - "version": "5.42.1", + "version": "5.42.2", "author": { "company": "Stream.io Inc", "name": "Stream.io Inc" @@ -10,7 +10,7 @@ "main": "src/index.js", "types": "types/index.d.ts", "dependencies": { - "stream-chat-react-native-core": "5.42.1" + "stream-chat-react-native-core": "5.42.2" }, "peerDependencies": { "@react-native-community/netinfo": ">=6.0.0", diff --git a/package/expo-package/yarn.lock b/package/expo-package/yarn.lock index e4aec101d..fc09f09af 100644 --- a/package/expo-package/yarn.lock +++ b/package/expo-package/yarn.lock @@ -2929,10 +2929,10 @@ stream-buffers@2.2.x: resolved "https://registry.yarnpkg.com/stream-buffers/-/stream-buffers-2.2.0.tgz#91d5f5130d1cef96dcfa7f726945188741d09ee4" integrity sha512-uyQK/mx5QjHun80FLJTfaWE7JtwfRMKBLkMne6udYOmvH0CawotVa7TfgYHzAnpphn4+TweIx1QKMnRIbipmUg== -stream-chat-react-native-core@5.42.0: - version "5.42.0" - resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.42.0.tgz#874751a43f7983ce8fac752951f0353f40afcc97" - integrity sha512-3HI8cBF/5gyWq850YbgsgTxvYSDNFNC0uZTJETMnW5qURyvJAKktyUlVhjilCuD5LI4CBgXdCD+o6qv52JM0Ww== +stream-chat-react-native-core@5.42.1: + version "5.42.1" + resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.42.1.tgz#4e58ae50130b7ce47bfe13f76f970a6b1688eb97" + integrity sha512-GVFtsjup3pjx9yN1i5suGIG/I14dSmgY/7bOq0n3NXxrf5i3IiWTjogk4m9N51P94VzNHENZQtd/lxa3hli35A== dependencies: "@gorhom/bottom-sheet" "^4.6.4" dayjs "1.10.5" diff --git a/package/native-package/package.json b/package/native-package/package.json index fa7975fa2..cf0c40a99 100644 --- a/package/native-package/package.json +++ b/package/native-package/package.json @@ -1,7 +1,7 @@ { "name": "stream-chat-react-native", "description": "The official React Native SDK for Stream Chat, a service for building chat applications", - "version": "5.42.1", + "version": "5.42.2", "author": { "company": "Stream.io Inc", "name": "Stream.io Inc" @@ -11,7 +11,7 @@ "types": "types/index.d.ts", "dependencies": { "es6-symbol": "^3.1.3", - "stream-chat-react-native-core": "5.42.1" + "stream-chat-react-native-core": "5.42.2" }, "peerDependencies": { "@react-native-camera-roll/camera-roll": ">=5.0.0", diff --git a/package/native-package/yarn.lock b/package/native-package/yarn.lock index 4c0ae0ab2..e0d686c8a 100644 --- a/package/native-package/yarn.lock +++ b/package/native-package/yarn.lock @@ -4244,10 +4244,10 @@ statuses@~1.5.0: resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" integrity sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA== -stream-chat-react-native-core@5.42.0: - version "5.42.0" - resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.42.0.tgz#874751a43f7983ce8fac752951f0353f40afcc97" - integrity sha512-3HI8cBF/5gyWq850YbgsgTxvYSDNFNC0uZTJETMnW5qURyvJAKktyUlVhjilCuD5LI4CBgXdCD+o6qv52JM0Ww== +stream-chat-react-native-core@5.42.1: + version "5.42.1" + resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.42.1.tgz#4e58ae50130b7ce47bfe13f76f970a6b1688eb97" + integrity sha512-GVFtsjup3pjx9yN1i5suGIG/I14dSmgY/7bOq0n3NXxrf5i3IiWTjogk4m9N51P94VzNHENZQtd/lxa3hli35A== dependencies: "@gorhom/bottom-sheet" "^4.6.4" dayjs "1.10.5" diff --git a/package/package.json b/package/package.json index 8d8495397..fe6784e83 100644 --- a/package/package.json +++ b/package/package.json @@ -1,7 +1,7 @@ { "name": "stream-chat-react-native-core", "description": "The official React Native and Expo components for Stream Chat, a service for building chat applications", - "version": "5.42.1", + "version": "5.42.2", "author": { "company": "Stream.io Inc", "name": "Stream.io Inc" diff --git a/package/src/version.json b/package/src/version.json index e802ac3c4..94df49b6c 100644 --- a/package/src/version.json +++ b/package/src/version.json @@ -1,3 +1,3 @@ { - "version": "5.42.1" + "version": "5.42.2" } From cd6ba0133317ebd57233be7322b63023d71c3f5f Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Tue, 19 Nov 2024 21:26:23 +0000 Subject: [PATCH 12/20] chore(release): 1.31.8 [skip ci] --- examples/SampleApp/CHANGELOG.md | 7 +++++++ examples/SampleApp/package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/examples/SampleApp/CHANGELOG.md b/examples/SampleApp/CHANGELOG.md index 69597c89f..bed667ed8 100644 --- a/examples/SampleApp/CHANGELOG.md +++ b/examples/SampleApp/CHANGELOG.md @@ -1,5 +1,12 @@ # Change Log +### [1.31.8](https://github.com/GetStream/stream-chat-react-native/compare/sampleapp@v1.31.7...sampleapp@v1.31.8) (2024-11-19) + + +### Workspaces + +* Following linked packages updated: [stream-chat-react-native] + ### [1.31.7](https://github.com/GetStream/stream-chat-react-native/compare/sampleapp@v1.31.6...sampleapp@v1.31.7) (2024-11-15) diff --git a/examples/SampleApp/package.json b/examples/SampleApp/package.json index cb3acf163..5ba7a1e9a 100644 --- a/examples/SampleApp/package.json +++ b/examples/SampleApp/package.json @@ -1,6 +1,6 @@ { "name": "sampleapp", - "version": "1.31.7", + "version": "1.31.8", "private": true, "repository": { "type": "git", From 9c55bd543215a6c615b3e088238154bba34a958f Mon Sep 17 00:00:00 2001 From: Ivan Sekovanikj <31964049+isekovanic@users.noreply.github.com> Date: Wed, 20 Nov 2024 13:58:48 +0100 Subject: [PATCH 13/20] feat: moderation v2 support (#2801) * feat: enable moderation v2 on the sdk and sample apps * chore: update yarn.lock files as well --- examples/ExpoMessaging/yarn.lock | 33 +++++++++++++++++++------- examples/SampleApp/yarn.lock | 33 +++++++++++++++++++------- examples/TypeScriptMessaging/yarn.lock | 33 +++++++++++++++++++------- package/expo-package/yarn.lock | 8 +++---- package/native-package/yarn.lock | 8 +++---- package/package.json | 2 +- package/src/utils/utils.ts | 5 +++- package/yarn.lock | 8 +++---- 8 files changed, 89 insertions(+), 41 deletions(-) diff --git a/examples/ExpoMessaging/yarn.lock b/examples/ExpoMessaging/yarn.lock index 0ae2aa17f..1b81592ba 100644 --- a/examples/ExpoMessaging/yarn.lock +++ b/examples/ExpoMessaging/yarn.lock @@ -7310,10 +7310,10 @@ stream-buffers@2.2.x, stream-buffers@~2.2.0: version "0.0.0" uid "" -stream-chat-react-native-core@5.41.0: - version "5.41.0" - resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.41.0.tgz#defaeee932459c6357147c553167adee8d34493d" - integrity sha512-x46BYWWfRaRw3FbLLzCoJP636jHQrX+my9DG680t9p8wNWKX59imnqX9LjZVcOYo45vpJ8T5Zjs0kYXbDgppTQ== +stream-chat-react-native-core@5.42.2: + version "5.42.2" + resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.42.2.tgz#edb92b490d4beb894ba549c7deefc770f501360c" + integrity sha512-eA2fK3eYdhr2RSbB22s1ha29y4EPbj9yPAskWxGo1aJK+KXwXDlAYqGtJa/8saRSSU4DdV89yG5ihvTFgP+Huw== dependencies: "@gorhom/bottom-sheet" "^4.6.4" dayjs "1.10.5" @@ -7326,16 +7326,31 @@ stream-chat-react-native-core@5.41.0: path "0.12.7" react-native-markdown-package "1.8.2" react-native-url-polyfill "^1.3.0" - stream-chat "8.42.0" + stream-chat "8.44.0" "stream-chat-react-native-core@link:../../package": version "0.0.0" uid "" -stream-chat@8.42.0: - version "8.42.0" - resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-8.42.0.tgz#124ea2c10c6e8f7990304e1101c66751daf63e6c" - integrity sha512-8xZz+fmdHSOa3L1rHUOC4Wah+ipvLvdiOmeOfGK6uXnLOKlSHMOblwmQErrOoFM4SKfX9Bea3V8viaKUu6bPng== +stream-chat@8.44.0: + version "8.44.0" + resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-8.44.0.tgz#e48446cf91db786e80a2e7358ac4f1601e5e97f0" + integrity sha512-7HNtimD8sT/51rsFibGcD6uBgKj+vlKyYCZMDzjYQEaEsrLqyAg48dOyNM4L2FTF5aXgo9SlxZr21SPleeA2BA== + dependencies: + "@babel/runtime" "^7.16.3" + "@types/jsonwebtoken" "~9.0.0" + "@types/ws" "^7.4.0" + axios "^1.6.0" + base64-js "^1.5.1" + form-data "^4.0.0" + isomorphic-ws "^4.0.1" + jsonwebtoken "~9.0.0" + ws "^7.5.10" + +stream-chat@8.45.1: + version "8.45.1" + resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-8.45.1.tgz#001f452520602ebffe45f1634b5f5dd1ff036ec5" + integrity sha512-7OMpL2RHUd+PXSWzhTUAIjjXlI9Oqc4HhUBRfc5i6dK+Ug9S5ertb7RvyzGL5N4ITpq/6ZUAwXtTqRaN9+UUkw== dependencies: "@babel/runtime" "^7.16.3" "@types/jsonwebtoken" "~9.0.0" diff --git a/examples/SampleApp/yarn.lock b/examples/SampleApp/yarn.lock index 5bb870ebe..fe345d8a8 100644 --- a/examples/SampleApp/yarn.lock +++ b/examples/SampleApp/yarn.lock @@ -6837,10 +6837,10 @@ statuses@~1.5.0: resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" integrity sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA== -stream-chat-react-native-core@5.41.0: - version "5.41.0" - resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.41.0.tgz#defaeee932459c6357147c553167adee8d34493d" - integrity sha512-x46BYWWfRaRw3FbLLzCoJP636jHQrX+my9DG680t9p8wNWKX59imnqX9LjZVcOYo45vpJ8T5Zjs0kYXbDgppTQ== +stream-chat-react-native-core@5.42.2: + version "5.42.2" + resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.42.2.tgz#edb92b490d4beb894ba549c7deefc770f501360c" + integrity sha512-eA2fK3eYdhr2RSbB22s1ha29y4EPbj9yPAskWxGo1aJK+KXwXDlAYqGtJa/8saRSSU4DdV89yG5ihvTFgP+Huw== dependencies: "@gorhom/bottom-sheet" "^4.6.4" dayjs "1.10.5" @@ -6853,7 +6853,7 @@ stream-chat-react-native-core@5.41.0: path "0.12.7" react-native-markdown-package "1.8.2" react-native-url-polyfill "^1.3.0" - stream-chat "8.42.0" + stream-chat "8.44.0" "stream-chat-react-native-core@link:../../package": version "0.0.0" @@ -6863,10 +6863,25 @@ stream-chat-react-native-core@5.41.0: version "0.0.0" uid "" -stream-chat@8.42.0: - version "8.42.0" - resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-8.42.0.tgz#124ea2c10c6e8f7990304e1101c66751daf63e6c" - integrity sha512-8xZz+fmdHSOa3L1rHUOC4Wah+ipvLvdiOmeOfGK6uXnLOKlSHMOblwmQErrOoFM4SKfX9Bea3V8viaKUu6bPng== +stream-chat@8.44.0: + version "8.44.0" + resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-8.44.0.tgz#e48446cf91db786e80a2e7358ac4f1601e5e97f0" + integrity sha512-7HNtimD8sT/51rsFibGcD6uBgKj+vlKyYCZMDzjYQEaEsrLqyAg48dOyNM4L2FTF5aXgo9SlxZr21SPleeA2BA== + dependencies: + "@babel/runtime" "^7.16.3" + "@types/jsonwebtoken" "~9.0.0" + "@types/ws" "^7.4.0" + axios "^1.6.0" + base64-js "^1.5.1" + form-data "^4.0.0" + isomorphic-ws "^4.0.1" + jsonwebtoken "~9.0.0" + ws "^7.5.10" + +stream-chat@8.45.1: + version "8.45.1" + resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-8.45.1.tgz#001f452520602ebffe45f1634b5f5dd1ff036ec5" + integrity sha512-7OMpL2RHUd+PXSWzhTUAIjjXlI9Oqc4HhUBRfc5i6dK+Ug9S5ertb7RvyzGL5N4ITpq/6ZUAwXtTqRaN9+UUkw== dependencies: "@babel/runtime" "^7.16.3" "@types/jsonwebtoken" "~9.0.0" diff --git a/examples/TypeScriptMessaging/yarn.lock b/examples/TypeScriptMessaging/yarn.lock index de8554e21..b3af9d70d 100644 --- a/examples/TypeScriptMessaging/yarn.lock +++ b/examples/TypeScriptMessaging/yarn.lock @@ -6899,10 +6899,10 @@ statuses@~1.5.0: resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" integrity sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA== -stream-chat-react-native-core@5.41.0: - version "5.41.0" - resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.41.0.tgz#defaeee932459c6357147c553167adee8d34493d" - integrity sha512-x46BYWWfRaRw3FbLLzCoJP636jHQrX+my9DG680t9p8wNWKX59imnqX9LjZVcOYo45vpJ8T5Zjs0kYXbDgppTQ== +stream-chat-react-native-core@5.42.2: + version "5.42.2" + resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.42.2.tgz#edb92b490d4beb894ba549c7deefc770f501360c" + integrity sha512-eA2fK3eYdhr2RSbB22s1ha29y4EPbj9yPAskWxGo1aJK+KXwXDlAYqGtJa/8saRSSU4DdV89yG5ihvTFgP+Huw== dependencies: "@gorhom/bottom-sheet" "^4.6.4" dayjs "1.10.5" @@ -6915,7 +6915,7 @@ stream-chat-react-native-core@5.41.0: path "0.12.7" react-native-markdown-package "1.8.2" react-native-url-polyfill "^1.3.0" - stream-chat "8.42.0" + stream-chat "8.44.0" "stream-chat-react-native-core@link:../../package": version "0.0.0" @@ -6930,10 +6930,25 @@ stream-chat-react-native-devtools@^1.1.0: version "0.0.0" uid "" -stream-chat@8.42.0: - version "8.42.0" - resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-8.42.0.tgz#124ea2c10c6e8f7990304e1101c66751daf63e6c" - integrity sha512-8xZz+fmdHSOa3L1rHUOC4Wah+ipvLvdiOmeOfGK6uXnLOKlSHMOblwmQErrOoFM4SKfX9Bea3V8viaKUu6bPng== +stream-chat@8.44.0: + version "8.44.0" + resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-8.44.0.tgz#e48446cf91db786e80a2e7358ac4f1601e5e97f0" + integrity sha512-7HNtimD8sT/51rsFibGcD6uBgKj+vlKyYCZMDzjYQEaEsrLqyAg48dOyNM4L2FTF5aXgo9SlxZr21SPleeA2BA== + dependencies: + "@babel/runtime" "^7.16.3" + "@types/jsonwebtoken" "~9.0.0" + "@types/ws" "^7.4.0" + axios "^1.6.0" + base64-js "^1.5.1" + form-data "^4.0.0" + isomorphic-ws "^4.0.1" + jsonwebtoken "~9.0.0" + ws "^7.5.10" + +stream-chat@8.45.1: + version "8.45.1" + resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-8.45.1.tgz#001f452520602ebffe45f1634b5f5dd1ff036ec5" + integrity sha512-7OMpL2RHUd+PXSWzhTUAIjjXlI9Oqc4HhUBRfc5i6dK+Ug9S5ertb7RvyzGL5N4ITpq/6ZUAwXtTqRaN9+UUkw== dependencies: "@babel/runtime" "^7.16.3" "@types/jsonwebtoken" "~9.0.0" diff --git a/package/expo-package/yarn.lock b/package/expo-package/yarn.lock index fc09f09af..fde2c7fb4 100644 --- a/package/expo-package/yarn.lock +++ b/package/expo-package/yarn.lock @@ -2929,10 +2929,10 @@ stream-buffers@2.2.x: resolved "https://registry.yarnpkg.com/stream-buffers/-/stream-buffers-2.2.0.tgz#91d5f5130d1cef96dcfa7f726945188741d09ee4" integrity sha512-uyQK/mx5QjHun80FLJTfaWE7JtwfRMKBLkMne6udYOmvH0CawotVa7TfgYHzAnpphn4+TweIx1QKMnRIbipmUg== -stream-chat-react-native-core@5.42.1: - version "5.42.1" - resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.42.1.tgz#4e58ae50130b7ce47bfe13f76f970a6b1688eb97" - integrity sha512-GVFtsjup3pjx9yN1i5suGIG/I14dSmgY/7bOq0n3NXxrf5i3IiWTjogk4m9N51P94VzNHENZQtd/lxa3hli35A== +stream-chat-react-native-core@5.42.2: + version "5.42.2" + resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.42.2.tgz#edb92b490d4beb894ba549c7deefc770f501360c" + integrity sha512-eA2fK3eYdhr2RSbB22s1ha29y4EPbj9yPAskWxGo1aJK+KXwXDlAYqGtJa/8saRSSU4DdV89yG5ihvTFgP+Huw== dependencies: "@gorhom/bottom-sheet" "^4.6.4" dayjs "1.10.5" diff --git a/package/native-package/yarn.lock b/package/native-package/yarn.lock index e0d686c8a..e73111725 100644 --- a/package/native-package/yarn.lock +++ b/package/native-package/yarn.lock @@ -4244,10 +4244,10 @@ statuses@~1.5.0: resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" integrity sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA== -stream-chat-react-native-core@5.42.1: - version "5.42.1" - resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.42.1.tgz#4e58ae50130b7ce47bfe13f76f970a6b1688eb97" - integrity sha512-GVFtsjup3pjx9yN1i5suGIG/I14dSmgY/7bOq0n3NXxrf5i3IiWTjogk4m9N51P94VzNHENZQtd/lxa3hli35A== +stream-chat-react-native-core@5.42.2: + version "5.42.2" + resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.42.2.tgz#edb92b490d4beb894ba549c7deefc770f501360c" + integrity sha512-eA2fK3eYdhr2RSbB22s1ha29y4EPbj9yPAskWxGo1aJK+KXwXDlAYqGtJa/8saRSSU4DdV89yG5ihvTFgP+Huw== dependencies: "@gorhom/bottom-sheet" "^4.6.4" dayjs "1.10.5" diff --git a/package/package.json b/package/package.json index fe6784e83..93447ffc9 100644 --- a/package/package.json +++ b/package/package.json @@ -78,7 +78,7 @@ "path": "0.12.7", "react-native-markdown-package": "1.8.2", "react-native-url-polyfill": "^1.3.0", - "stream-chat": "8.44.0" + "stream-chat": "8.45.1" }, "peerDependencies": { "react-native-quick-sqlite": ">=5.1.0", diff --git a/package/src/utils/utils.ts b/package/src/utils/utils.ts index 3cffd7600..009ba2585 100644 --- a/package/src/utils/utils.ts +++ b/package/src/utils/utils.ts @@ -94,7 +94,10 @@ export const isBouncedMessage = < StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics, >( message: MessageType, -) => message.type === 'error' && message.moderation_details !== undefined; +) => + (message.type === 'error' && + message?.moderation_details?.action === 'MESSAGE_RESPONSE_ACTION_BOUNCE') || + message?.moderation?.action === 'bounce'; /** * Utility to check if the message is a edited message. diff --git a/package/yarn.lock b/package/yarn.lock index f25887e86..056f9600a 100644 --- a/package/yarn.lock +++ b/package/yarn.lock @@ -10664,10 +10664,10 @@ stream-browserify@^2.0.1: inherits "~2.0.1" readable-stream "^2.0.2" -stream-chat@8.44.0: - version "8.44.0" - resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-8.44.0.tgz#e48446cf91db786e80a2e7358ac4f1601e5e97f0" - integrity sha512-7HNtimD8sT/51rsFibGcD6uBgKj+vlKyYCZMDzjYQEaEsrLqyAg48dOyNM4L2FTF5aXgo9SlxZr21SPleeA2BA== +stream-chat@8.45.1: + version "8.45.1" + resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-8.45.1.tgz#001f452520602ebffe45f1634b5f5dd1ff036ec5" + integrity sha512-7OMpL2RHUd+PXSWzhTUAIjjXlI9Oqc4HhUBRfc5i6dK+Ug9S5ertb7RvyzGL5N4ITpq/6ZUAwXtTqRaN9+UUkw== dependencies: "@babel/runtime" "^7.16.3" "@types/jsonwebtoken" "~9.0.0" From 376ac7d5bd5a5c34080b2272601300633b3412f1 Mon Sep 17 00:00:00 2001 From: Ivan Sekovanikj <31964049+isekovanic@users.noreply.github.com> Date: Wed, 20 Nov 2024 13:58:59 +0100 Subject: [PATCH 14/20] feat: add support for membership customization (#2802) * feat: add support for membership customization * fix: lint issues --- examples/ExpoMessaging/types.ts | 6 +- .../NewDirectMessagingSendButton.tsx | 63 +++++-------------- examples/SampleApp/src/types.ts | 2 + examples/TypeScriptMessaging/App.tsx | 2 + package/src/types/types.ts | 1 + 5 files changed, 24 insertions(+), 50 deletions(-) diff --git a/examples/ExpoMessaging/types.ts b/examples/ExpoMessaging/types.ts index 5128439cb..6607eb8e6 100644 --- a/examples/ExpoMessaging/types.ts +++ b/examples/ExpoMessaging/types.ts @@ -5,14 +5,16 @@ export type LocalEventType = Record; export type LocalMessageType = Record; export type LocalReactionType = Record; export type LocalUserType = Record; -type LocalPollOptionType = Record; -type LocalPollType = Record; +export type LocalPollOptionType = Record; +export type LocalPollType = Record; +export type LocalMemberType = Record; export type StreamChatGenerics = { attachmentType: LocalAttachmentType; channelType: LocalChannelType; commandType: LocalCommandType; eventType: LocalEventType; + memberType: LocalMemberType; messageType: LocalMessageType; pollOptionType: LocalPollOptionType; pollType: LocalPollType; diff --git a/examples/SampleApp/src/components/NewDirectMessagingSendButton.tsx b/examples/SampleApp/src/components/NewDirectMessagingSendButton.tsx index a0c8d716a..557820c63 100644 --- a/examples/SampleApp/src/components/NewDirectMessagingSendButton.tsx +++ b/examples/SampleApp/src/components/NewDirectMessagingSendButton.tsx @@ -4,18 +4,11 @@ import { TouchableOpacity } from 'react-native-gesture-handler'; import { useNavigation } from '@react-navigation/core'; import { - DefaultAttachmentType, - DefaultChannelType, - DefaultCommandType, - DefaultEventType, - DefaultMessageType, - DefaultReactionType, - DefaultUserType, + DefaultStreamChatGenerics, MessageInputContextValue, Search, SendRight, SendUp, - UnknownType, useChannelContext, useMessageInputContext, useTheme, @@ -23,30 +16,18 @@ import { import { NewDirectMessagingScreenNavigationProp } from '../screens/NewDirectMessagingScreen'; -import { StreamChatGenerics } from '../types'; +import { StreamChatGenerics as LocalStreamChatGenerics } from '../types'; type NewDirectMessagingSendButtonPropsWithContext< - At extends UnknownType = DefaultAttachmentType, - Ch extends UnknownType = DefaultChannelType, - Co extends string = DefaultCommandType, - Ev extends UnknownType = DefaultEventType, - Me extends UnknownType = DefaultMessageType, - Re extends UnknownType = DefaultReactionType, - Us extends UnknownType = DefaultUserType, -> = Pick, 'giphyActive' | 'sendMessage'> & { + StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics, +> = Pick, 'giphyActive' | 'sendMessage'> & { /** Disables the button */ disabled: boolean; }; const SendButtonWithContext = < - At extends UnknownType = DefaultAttachmentType, - Ch extends UnknownType = DefaultChannelType, - Co extends string = DefaultCommandType, - Ev extends UnknownType = DefaultEventType, - Me extends UnknownType = DefaultMessageType, - Re extends UnknownType = DefaultReactionType, - Us extends UnknownType = DefaultUserType, + StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics, >( - props: NewDirectMessagingSendButtonPropsWithContext, + props: NewDirectMessagingSendButtonPropsWithContext, ) => { const { disabled = false, giphyActive, sendMessage } = props; const { @@ -70,17 +51,9 @@ const SendButtonWithContext = < ); }; -const areEqual = < - At extends UnknownType = DefaultAttachmentType, - Ch extends UnknownType = DefaultChannelType, - Co extends string = DefaultCommandType, - Ev extends UnknownType = DefaultEventType, - Me extends UnknownType = DefaultMessageType, - Re extends UnknownType = DefaultReactionType, - Us extends UnknownType = DefaultUserType, ->( - prevProps: NewDirectMessagingSendButtonPropsWithContext, - nextProps: NewDirectMessagingSendButtonPropsWithContext, +const areEqual = ( + prevProps: NewDirectMessagingSendButtonPropsWithContext, + nextProps: NewDirectMessagingSendButtonPropsWithContext, ) => { const { disabled: prevDisabled, @@ -117,23 +90,17 @@ const MemoizedNewDirectMessagingSendButton = React.memo( ) as typeof SendButtonWithContext; export type SendButtonProps< - At extends UnknownType = DefaultAttachmentType, - Ch extends UnknownType = DefaultChannelType, - Co extends string = DefaultCommandType, - Ev extends UnknownType = DefaultEventType, - Me extends UnknownType = DefaultMessageType, - Re extends UnknownType = DefaultReactionType, - Us extends UnknownType = DefaultUserType, -> = Partial>; + StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics, +> = Partial>; /** * UI Component for send button in MessageInput component. */ -export const NewDirectMessagingSendButton = (props: SendButtonProps) => { +export const NewDirectMessagingSendButton = (props: SendButtonProps) => { const navigation = useNavigation(); - const { channel } = useChannelContext(); + const { channel } = useChannelContext(); - const { giphyActive, text } = useMessageInputContext(); + const { giphyActive, text } = useMessageInputContext(); const sendMessage = async () => { if (!channel) { @@ -152,7 +119,7 @@ export const NewDirectMessagingSendButton = (props: SendButtonProps + {...{ giphyActive, sendMessage }} {...props} {...{ disabled: props.disabled || false }} diff --git a/examples/SampleApp/src/types.ts b/examples/SampleApp/src/types.ts index 25467f87d..fb95c6a0e 100644 --- a/examples/SampleApp/src/types.ts +++ b/examples/SampleApp/src/types.ts @@ -17,12 +17,14 @@ export type LocalUserType = { }; type LocalPollOptionType = Record; type LocalPollType = Record; +type LocalMemberType = Record; export type StreamChatGenerics = { attachmentType: LocalAttachmentType; channelType: LocalChannelType; commandType: LocalCommandType; eventType: LocalEventType; + memberType: LocalMemberType; messageType: LocalMessageType; pollOptionType: LocalPollOptionType; pollType: LocalPollType; diff --git a/examples/TypeScriptMessaging/App.tsx b/examples/TypeScriptMessaging/App.tsx index 44bd02155..7cb110d2a 100644 --- a/examples/TypeScriptMessaging/App.tsx +++ b/examples/TypeScriptMessaging/App.tsx @@ -38,12 +38,14 @@ type LocalReactionType = Record; type LocalUserType = Record; type LocalPollOptionType = Record; type LocalPollType = Record; +type LocalMemberType = Record; type StreamChatGenerics = { attachmentType: LocalAttachmentType; channelType: LocalChannelType; commandType: LocalCommandType; eventType: LocalEventType; + memberType: LocalMemberType; messageType: LocalMessageType; pollOptionType: LocalPollOptionType; pollType: LocalPollType; diff --git a/package/src/types/types.ts b/package/src/types/types.ts index 3ff97c89f..f9ef9d0ed 100644 --- a/package/src/types/types.ts +++ b/package/src/types/types.ts @@ -82,6 +82,7 @@ export interface DefaultStreamChatGenerics extends ExtendableGenerics { channelType: DefaultChannelType; commandType: LiteralStringForUnion; eventType: UnknownType; + memberType: UnknownType; messageType: UnknownType; reactionType: UnknownType; userType: DefaultUserType; From ee801014fadc9d949ebd5adae47ee7e3e39da79a Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 20 Nov 2024 13:55:36 +0000 Subject: [PATCH 15/20] chore(release): 5.43.0 [skip ci] --- package/CHANGELOG.md | 8 ++++++++ package/expo-package/package.json | 4 ++-- package/native-package/package.json | 4 ++-- package/package.json | 2 +- package/src/version.json | 2 +- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/package/CHANGELOG.md b/package/CHANGELOG.md index 40abc5ed7..a6e8b47c8 100644 --- a/package/CHANGELOG.md +++ b/package/CHANGELOG.md @@ -1,5 +1,13 @@ # Change Log +## [5.43.0](https://github.com/GetStream/stream-chat-react-native/compare/v5.42.2...v5.43.0) (2024-11-20) + + +### Features + +* add support for membership customization ([#2802](https://github.com/GetStream/stream-chat-react-native/issues/2802)) ([376ac7d](https://github.com/GetStream/stream-chat-react-native/commit/376ac7d5bd5a5c34080b2272601300633b3412f1)) +* moderation v2 support ([#2801](https://github.com/GetStream/stream-chat-react-native/issues/2801)) ([9c55bd5](https://github.com/GetStream/stream-chat-react-native/commit/9c55bd543215a6c615b3e088238154bba34a958f)) + ### [5.42.2](https://github.com/GetStream/stream-chat-react-native/compare/v5.42.1...v5.42.2) (2024-11-19) diff --git a/package/expo-package/package.json b/package/expo-package/package.json index 52588dce9..91b435a80 100644 --- a/package/expo-package/package.json +++ b/package/expo-package/package.json @@ -1,7 +1,7 @@ { "name": "stream-chat-expo", "description": "The official Expo SDK for Stream Chat, a service for building chat applications", - "version": "5.42.2", + "version": "5.43.0", "author": { "company": "Stream.io Inc", "name": "Stream.io Inc" @@ -10,7 +10,7 @@ "main": "src/index.js", "types": "types/index.d.ts", "dependencies": { - "stream-chat-react-native-core": "5.42.2" + "stream-chat-react-native-core": "5.43.0" }, "peerDependencies": { "@react-native-community/netinfo": ">=6.0.0", diff --git a/package/native-package/package.json b/package/native-package/package.json index cf0c40a99..2362be940 100644 --- a/package/native-package/package.json +++ b/package/native-package/package.json @@ -1,7 +1,7 @@ { "name": "stream-chat-react-native", "description": "The official React Native SDK for Stream Chat, a service for building chat applications", - "version": "5.42.2", + "version": "5.43.0", "author": { "company": "Stream.io Inc", "name": "Stream.io Inc" @@ -11,7 +11,7 @@ "types": "types/index.d.ts", "dependencies": { "es6-symbol": "^3.1.3", - "stream-chat-react-native-core": "5.42.2" + "stream-chat-react-native-core": "5.43.0" }, "peerDependencies": { "@react-native-camera-roll/camera-roll": ">=5.0.0", diff --git a/package/package.json b/package/package.json index 93447ffc9..aaa4f0053 100644 --- a/package/package.json +++ b/package/package.json @@ -1,7 +1,7 @@ { "name": "stream-chat-react-native-core", "description": "The official React Native and Expo components for Stream Chat, a service for building chat applications", - "version": "5.42.2", + "version": "5.43.0", "author": { "company": "Stream.io Inc", "name": "Stream.io Inc" diff --git a/package/src/version.json b/package/src/version.json index 94df49b6c..159b242b4 100644 --- a/package/src/version.json +++ b/package/src/version.json @@ -1,3 +1,3 @@ { - "version": "5.42.2" + "version": "5.43.0" } From b3c0c82cf580db074241ff71917d635e4edf633a Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 20 Nov 2024 13:56:53 +0000 Subject: [PATCH 16/20] chore(release): 1.32.0 [skip ci] --- examples/SampleApp/CHANGELOG.md | 13 +++++++++++++ examples/SampleApp/package.json | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/examples/SampleApp/CHANGELOG.md b/examples/SampleApp/CHANGELOG.md index bed667ed8..8f61de3e3 100644 --- a/examples/SampleApp/CHANGELOG.md +++ b/examples/SampleApp/CHANGELOG.md @@ -1,5 +1,18 @@ # Change Log +## [1.32.0](https://github.com/GetStream/stream-chat-react-native/compare/sampleapp@v1.31.8...sampleapp@v1.32.0) (2024-11-20) + + +### Features + +* add support for membership customization ([#2802](https://github.com/GetStream/stream-chat-react-native/issues/2802)) ([376ac7d](https://github.com/GetStream/stream-chat-react-native/commit/376ac7d5bd5a5c34080b2272601300633b3412f1)) +* moderation v2 support ([#2801](https://github.com/GetStream/stream-chat-react-native/issues/2801)) ([9c55bd5](https://github.com/GetStream/stream-chat-react-native/commit/9c55bd543215a6c615b3e088238154bba34a958f)) + + +### Workspaces + +* Following linked packages updated: [stream-chat-react-native] + ### [1.31.8](https://github.com/GetStream/stream-chat-react-native/compare/sampleapp@v1.31.7...sampleapp@v1.31.8) (2024-11-19) diff --git a/examples/SampleApp/package.json b/examples/SampleApp/package.json index 5ba7a1e9a..f6f93ebb8 100644 --- a/examples/SampleApp/package.json +++ b/examples/SampleApp/package.json @@ -1,6 +1,6 @@ { "name": "sampleapp", - "version": "1.31.8", + "version": "1.32.0", "private": true, "repository": { "type": "git", From 54ff925405ad3cc3c269f92b054955fff3086e0a Mon Sep 17 00:00:00 2001 From: Ivan Sekovanikj <31964049+isekovanic@users.noreply.github.com> Date: Fri, 22 Nov 2024 13:46:37 +0100 Subject: [PATCH 17/20] fix: channel.state break on going to background (#2809) --- package/src/components/Chat/hooks/useIsOnline.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/package/src/components/Chat/hooks/useIsOnline.ts b/package/src/components/Chat/hooks/useIsOnline.ts index b177c40cd..661866d99 100644 --- a/package/src/components/Chat/hooks/useIsOnline.ts +++ b/package/src/components/Chat/hooks/useIsOnline.ts @@ -30,11 +30,6 @@ export const useIsOnline = < const onBackground = useCallback(() => { if (!closeConnectionOnBackground || !clientExists) return; - for (const cid in client.activeChannels) { - const channel = client.activeChannels[cid]; - channel?.state.setIsUpToDate(false); - } - client.closeConnection(); setIsOnline(false); }, [closeConnectionOnBackground, client, clientExists]); From 0c22dcada383e0fe38f3ee6ced7b985324cf2731 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Fri, 22 Nov 2024 15:48:49 +0000 Subject: [PATCH 18/20] chore(release): 5.43.1 [skip ci] --- package/CHANGELOG.md | 7 +++++++ package/expo-package/package.json | 4 ++-- package/expo-package/yarn.lock | 18 +++++++++--------- package/native-package/package.json | 4 ++-- package/native-package/yarn.lock | 18 +++++++++--------- package/package.json | 2 +- package/src/version.json | 2 +- 7 files changed, 31 insertions(+), 24 deletions(-) diff --git a/package/CHANGELOG.md b/package/CHANGELOG.md index a6e8b47c8..7a0f6f355 100644 --- a/package/CHANGELOG.md +++ b/package/CHANGELOG.md @@ -1,5 +1,12 @@ # Change Log +### [5.43.1](https://github.com/GetStream/stream-chat-react-native/compare/v5.43.0...v5.43.1) (2024-11-22) + + +### Bug Fixes + +* channel.state break on going to background ([#2809](https://github.com/GetStream/stream-chat-react-native/issues/2809)) ([54ff925](https://github.com/GetStream/stream-chat-react-native/commit/54ff925405ad3cc3c269f92b054955fff3086e0a)) + ## [5.43.0](https://github.com/GetStream/stream-chat-react-native/compare/v5.42.2...v5.43.0) (2024-11-20) diff --git a/package/expo-package/package.json b/package/expo-package/package.json index 91b435a80..96a50b2f6 100644 --- a/package/expo-package/package.json +++ b/package/expo-package/package.json @@ -1,7 +1,7 @@ { "name": "stream-chat-expo", "description": "The official Expo SDK for Stream Chat, a service for building chat applications", - "version": "5.43.0", + "version": "5.43.1", "author": { "company": "Stream.io Inc", "name": "Stream.io Inc" @@ -10,7 +10,7 @@ "main": "src/index.js", "types": "types/index.d.ts", "dependencies": { - "stream-chat-react-native-core": "5.43.0" + "stream-chat-react-native-core": "5.43.1" }, "peerDependencies": { "@react-native-community/netinfo": ">=6.0.0", diff --git a/package/expo-package/yarn.lock b/package/expo-package/yarn.lock index fde2c7fb4..98027ff1a 100644 --- a/package/expo-package/yarn.lock +++ b/package/expo-package/yarn.lock @@ -2929,10 +2929,10 @@ stream-buffers@2.2.x: resolved "https://registry.yarnpkg.com/stream-buffers/-/stream-buffers-2.2.0.tgz#91d5f5130d1cef96dcfa7f726945188741d09ee4" integrity sha512-uyQK/mx5QjHun80FLJTfaWE7JtwfRMKBLkMne6udYOmvH0CawotVa7TfgYHzAnpphn4+TweIx1QKMnRIbipmUg== -stream-chat-react-native-core@5.42.2: - version "5.42.2" - resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.42.2.tgz#edb92b490d4beb894ba549c7deefc770f501360c" - integrity sha512-eA2fK3eYdhr2RSbB22s1ha29y4EPbj9yPAskWxGo1aJK+KXwXDlAYqGtJa/8saRSSU4DdV89yG5ihvTFgP+Huw== +stream-chat-react-native-core@5.43.0: + version "5.43.0" + resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.43.0.tgz#d6f4eaeedc6fc35e5902f06cf895e47e95c2255e" + integrity sha512-Cfgt4ZtP/5yXh6eNzhRVyVtMjzhFdJKFu6injDM4TXClHThdjqv5v9G/s/znpm0QDq2x8vktPEB0evrtyezsNg== dependencies: "@gorhom/bottom-sheet" "^4.6.4" dayjs "1.10.5" @@ -2945,12 +2945,12 @@ stream-chat-react-native-core@5.42.2: path "0.12.7" react-native-markdown-package "1.8.2" react-native-url-polyfill "^1.3.0" - stream-chat "8.44.0" + stream-chat "8.45.1" -stream-chat@8.44.0: - version "8.44.0" - resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-8.44.0.tgz#e48446cf91db786e80a2e7358ac4f1601e5e97f0" - integrity sha512-7HNtimD8sT/51rsFibGcD6uBgKj+vlKyYCZMDzjYQEaEsrLqyAg48dOyNM4L2FTF5aXgo9SlxZr21SPleeA2BA== +stream-chat@8.45.1: + version "8.45.1" + resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-8.45.1.tgz#001f452520602ebffe45f1634b5f5dd1ff036ec5" + integrity sha512-7OMpL2RHUd+PXSWzhTUAIjjXlI9Oqc4HhUBRfc5i6dK+Ug9S5ertb7RvyzGL5N4ITpq/6ZUAwXtTqRaN9+UUkw== dependencies: "@babel/runtime" "^7.16.3" "@types/jsonwebtoken" "~9.0.0" diff --git a/package/native-package/package.json b/package/native-package/package.json index 2362be940..a7dc0a292 100644 --- a/package/native-package/package.json +++ b/package/native-package/package.json @@ -1,7 +1,7 @@ { "name": "stream-chat-react-native", "description": "The official React Native SDK for Stream Chat, a service for building chat applications", - "version": "5.43.0", + "version": "5.43.1", "author": { "company": "Stream.io Inc", "name": "Stream.io Inc" @@ -11,7 +11,7 @@ "types": "types/index.d.ts", "dependencies": { "es6-symbol": "^3.1.3", - "stream-chat-react-native-core": "5.43.0" + "stream-chat-react-native-core": "5.43.1" }, "peerDependencies": { "@react-native-camera-roll/camera-roll": ">=5.0.0", diff --git a/package/native-package/yarn.lock b/package/native-package/yarn.lock index e73111725..4db6c7558 100644 --- a/package/native-package/yarn.lock +++ b/package/native-package/yarn.lock @@ -4244,10 +4244,10 @@ statuses@~1.5.0: resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" integrity sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA== -stream-chat-react-native-core@5.42.2: - version "5.42.2" - resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.42.2.tgz#edb92b490d4beb894ba549c7deefc770f501360c" - integrity sha512-eA2fK3eYdhr2RSbB22s1ha29y4EPbj9yPAskWxGo1aJK+KXwXDlAYqGtJa/8saRSSU4DdV89yG5ihvTFgP+Huw== +stream-chat-react-native-core@5.43.0: + version "5.43.0" + resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.43.0.tgz#d6f4eaeedc6fc35e5902f06cf895e47e95c2255e" + integrity sha512-Cfgt4ZtP/5yXh6eNzhRVyVtMjzhFdJKFu6injDM4TXClHThdjqv5v9G/s/znpm0QDq2x8vktPEB0evrtyezsNg== dependencies: "@gorhom/bottom-sheet" "^4.6.4" dayjs "1.10.5" @@ -4260,12 +4260,12 @@ stream-chat-react-native-core@5.42.2: path "0.12.7" react-native-markdown-package "1.8.2" react-native-url-polyfill "^1.3.0" - stream-chat "8.44.0" + stream-chat "8.45.1" -stream-chat@8.44.0: - version "8.44.0" - resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-8.44.0.tgz#e48446cf91db786e80a2e7358ac4f1601e5e97f0" - integrity sha512-7HNtimD8sT/51rsFibGcD6uBgKj+vlKyYCZMDzjYQEaEsrLqyAg48dOyNM4L2FTF5aXgo9SlxZr21SPleeA2BA== +stream-chat@8.45.1: + version "8.45.1" + resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-8.45.1.tgz#001f452520602ebffe45f1634b5f5dd1ff036ec5" + integrity sha512-7OMpL2RHUd+PXSWzhTUAIjjXlI9Oqc4HhUBRfc5i6dK+Ug9S5ertb7RvyzGL5N4ITpq/6ZUAwXtTqRaN9+UUkw== dependencies: "@babel/runtime" "^7.16.3" "@types/jsonwebtoken" "~9.0.0" diff --git a/package/package.json b/package/package.json index aaa4f0053..f80b3bb09 100644 --- a/package/package.json +++ b/package/package.json @@ -1,7 +1,7 @@ { "name": "stream-chat-react-native-core", "description": "The official React Native and Expo components for Stream Chat, a service for building chat applications", - "version": "5.43.0", + "version": "5.43.1", "author": { "company": "Stream.io Inc", "name": "Stream.io Inc" diff --git a/package/src/version.json b/package/src/version.json index 159b242b4..7825e6c06 100644 --- a/package/src/version.json +++ b/package/src/version.json @@ -1,3 +1,3 @@ { - "version": "5.43.0" + "version": "5.43.1" } From 6accaecba888b04f7dfe19324af122d4729895e3 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Fri, 22 Nov 2024 15:50:00 +0000 Subject: [PATCH 19/20] chore(release): 1.32.1 [skip ci] --- examples/SampleApp/CHANGELOG.md | 7 +++++++ examples/SampleApp/package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/examples/SampleApp/CHANGELOG.md b/examples/SampleApp/CHANGELOG.md index 8f61de3e3..9403170fb 100644 --- a/examples/SampleApp/CHANGELOG.md +++ b/examples/SampleApp/CHANGELOG.md @@ -1,5 +1,12 @@ # Change Log +### [1.32.1](https://github.com/GetStream/stream-chat-react-native/compare/sampleapp@v1.32.0...sampleapp@v1.32.1) (2024-11-22) + + +### Workspaces + +* Following linked packages updated: [stream-chat-react-native] + ## [1.32.0](https://github.com/GetStream/stream-chat-react-native/compare/sampleapp@v1.31.8...sampleapp@v1.32.0) (2024-11-20) diff --git a/examples/SampleApp/package.json b/examples/SampleApp/package.json index f6f93ebb8..eb4202189 100644 --- a/examples/SampleApp/package.json +++ b/examples/SampleApp/package.json @@ -1,6 +1,6 @@ { "name": "sampleapp", - "version": "1.32.0", + "version": "1.32.1", "private": true, "repository": { "type": "git", From a26b64c7eecd3ed851420ef4e3b2f3151686991d Mon Sep 17 00:00:00 2001 From: Khushal Agarwal Date: Mon, 25 Nov 2024 15:44:55 +0530 Subject: [PATCH 20/20] chore: resolve conflicts from develop on v6 --- examples/ExpoMessaging/types.ts | 6 +- examples/ExpoMessaging/yarn.lock | 18 +- examples/SampleApp/CHANGELOG.md | 73 ++++-- examples/SampleApp/ios/Podfile.lock | 4 +- examples/SampleApp/package.json | 2 +- .../NewDirectMessagingSendButton.tsx | 63 ++--- examples/SampleApp/src/types.ts | 2 + examples/SampleApp/yarn.lock | 18 +- examples/TypeScriptMessaging/App.tsx | 2 + examples/TypeScriptMessaging/ios/Podfile.lock | 4 +- examples/TypeScriptMessaging/yarn.lock | 18 +- package/CHANGELOG.md | 84 +++++-- package/expo-package/package.json | 4 +- .../src/optionalDependencies/pickImage.ts | 2 + package/expo-package/yarn.lock | 18 +- package/native-package/package.json | 4 +- .../src/optionalDependencies/pickImage.ts | 1 + package/native-package/yarn.lock | 18 +- package/package.json | 4 +- package/src/components/Channel/Channel.tsx | 27 +- .../ChannelPreview/ChannelPreview.tsx | 135 +++------- .../ChannelPreviewMessenger.tsx | 20 +- .../ChannelPreviewMutedStatus.tsx | 9 +- .../__tests__/ChannelPreview.test.tsx | 236 +++++++++++++++++- .../useChannelPreviewDisplayName.test.tsx | 2 +- .../__tests__/useChannelPreviewMuted.test.tsx | 62 +++++ .../hooks/useChannelPreviewData.ts | 138 ++++++++++ .../ChannelPreview/hooks/useIsChannelMuted.ts | 29 +++ .../src/components/Chat/hooks/useIsOnline.ts | 5 - .../utils/generateMarkdownText.ts | 6 + .../components/MessageInput/MessageInput.tsx | 32 +-- .../components/MessageList/MessageList.tsx | 4 +- .../src/components/ThreadList/ThreadList.tsx | 2 - package/src/components/index.ts | 2 + .../event/notificationChannelMutesUpdated.js | 7 + .../event/notificationMarkRead.js | 7 + .../event/notificationMarkUnread.js | 9 + .../src/mock-builders/generator/channel.ts | 1 + package/src/types/types.ts | 1 + package/src/utils/utils.ts | 5 +- package/src/version.json | 2 +- package/yarn.lock | 8 +- 42 files changed, 755 insertions(+), 339 deletions(-) create mode 100644 package/src/components/ChannelPreview/hooks/__tests__/useChannelPreviewMuted.test.tsx create mode 100644 package/src/components/ChannelPreview/hooks/useChannelPreviewData.ts create mode 100644 package/src/components/ChannelPreview/hooks/useIsChannelMuted.ts create mode 100644 package/src/mock-builders/event/notificationChannelMutesUpdated.js create mode 100644 package/src/mock-builders/event/notificationMarkRead.js create mode 100644 package/src/mock-builders/event/notificationMarkUnread.js diff --git a/examples/ExpoMessaging/types.ts b/examples/ExpoMessaging/types.ts index 5128439cb..6607eb8e6 100644 --- a/examples/ExpoMessaging/types.ts +++ b/examples/ExpoMessaging/types.ts @@ -5,14 +5,16 @@ export type LocalEventType = Record; export type LocalMessageType = Record; export type LocalReactionType = Record; export type LocalUserType = Record; -type LocalPollOptionType = Record; -type LocalPollType = Record; +export type LocalPollOptionType = Record; +export type LocalPollType = Record; +export type LocalMemberType = Record; export type StreamChatGenerics = { attachmentType: LocalAttachmentType; channelType: LocalChannelType; commandType: LocalCommandType; eventType: LocalEventType; + memberType: LocalMemberType; messageType: LocalMessageType; pollOptionType: LocalPollOptionType; pollType: LocalPollType; diff --git a/examples/ExpoMessaging/yarn.lock b/examples/ExpoMessaging/yarn.lock index 63c921c12..df6ba8fc0 100644 --- a/examples/ExpoMessaging/yarn.lock +++ b/examples/ExpoMessaging/yarn.lock @@ -7513,10 +7513,10 @@ stream-buffers@2.2.x, stream-buffers@~2.2.0: version "0.0.0" uid "" -stream-chat-react-native-core@5.39.4: - version "5.39.4" - resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.39.4.tgz#39db32070ccf95aa32ceb2fec96f777c27f0a8d2" - integrity sha512-XKrPnIKVVOz9mi4/oVkMX8zD8JnqDIxjiqhYZelT4Hb2qMrhvpmCmxq60Fz++JZf7lFgtnoAx+oec1ns4g0VWg== +stream-chat-react-native-core@5.43.1: + version "5.43.1" + resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.43.1.tgz#ec0d5a06e329c8991c46cff5bd0211bc94d2b26f" + integrity sha512-qj/WfjFeCCP2wcp1YZGFJgRYGdSWXd0maG3hn3oURgFR6p/BmO6lDL2g3jnLq0SEkD8x+KZeNBS9cs1gW5Gblw== dependencies: "@gorhom/bottom-sheet" "^4.6.4" dayjs "1.10.5" @@ -7529,16 +7529,16 @@ stream-chat-react-native-core@5.39.4: path "0.12.7" react-native-markdown-package "1.8.2" react-native-url-polyfill "^1.3.0" - stream-chat "8.40.8" + stream-chat "8.45.1" "stream-chat-react-native-core@link:../../package": version "0.0.0" uid "" -stream-chat@8.40.8: - version "8.40.8" - resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-8.40.8.tgz#0f5320bd8b03d1cbff377f8c7ae2f8afe24d0515" - integrity sha512-nYLvYAkrvXRzuPO52TIofNiInCkDdXrnBc/658297lC6hzrHNc87mmTht264BXmXLlpasTNP3rLKxR6MxhpgKg== +stream-chat@8.45.1: + version "8.45.1" + resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-8.45.1.tgz#001f452520602ebffe45f1634b5f5dd1ff036ec5" + integrity sha512-7OMpL2RHUd+PXSWzhTUAIjjXlI9Oqc4HhUBRfc5i6dK+Ug9S5ertb7RvyzGL5N4ITpq/6ZUAwXtTqRaN9+UUkw== dependencies: "@babel/runtime" "^7.16.3" "@types/jsonwebtoken" "~9.0.0" diff --git a/examples/SampleApp/CHANGELOG.md b/examples/SampleApp/CHANGELOG.md index c0f4aa587..5d3c4efc8 100644 --- a/examples/SampleApp/CHANGELOG.md +++ b/examples/SampleApp/CHANGELOG.md @@ -1,85 +1,108 @@ # Change Log -### [1.31.5](https://github.com/GetStream/stream-chat-react-native/compare/sampleapp@v1.31.4...sampleapp@v1.31.5) (2024-11-08) +### [1.32.1](https://github.com/GetStream/stream-chat-react-native/compare/sampleapp@v1.32.0...sampleapp@v1.32.1) (2024-11-22) + +### Workspaces +- Following linked packages updated: [stream-chat-react-native] + +## [1.32.0](https://github.com/GetStream/stream-chat-react-native/compare/sampleapp@v1.31.8...sampleapp@v1.32.0) (2024-11-20) + +### Features + +- add support for membership customization ([#2802](https://github.com/GetStream/stream-chat-react-native/issues/2802)) ([376ac7d](https://github.com/GetStream/stream-chat-react-native/commit/376ac7d5bd5a5c34080b2272601300633b3412f1)) +- moderation v2 support ([#2801](https://github.com/GetStream/stream-chat-react-native/issues/2801)) ([9c55bd5](https://github.com/GetStream/stream-chat-react-native/commit/9c55bd543215a6c615b3e088238154bba34a958f)) ### Workspaces -* Following linked packages updated: [stream-chat-react-native] +- Following linked packages updated: [stream-chat-react-native] -### [1.31.4](https://github.com/GetStream/stream-chat-react-native/compare/sampleapp@v1.31.3...sampleapp@v1.31.4) (2024-11-07) +### [1.31.8](https://github.com/GetStream/stream-chat-react-native/compare/sampleapp@v1.31.7...sampleapp@v1.31.8) (2024-11-19) +### Workspaces + +- Following linked packages updated: [stream-chat-react-native] + +### [1.31.7](https://github.com/GetStream/stream-chat-react-native/compare/sampleapp@v1.31.6...sampleapp@v1.31.7) (2024-11-15) ### Workspaces -* Following linked packages updated: [stream-chat-react-native] +- Following linked packages updated: [stream-chat-react-native] -### [1.31.3](https://github.com/GetStream/stream-chat-react-native/compare/sampleapp@v1.31.2...sampleapp@v1.31.3) (2024-11-04) +### [1.31.6](https://github.com/GetStream/stream-chat-react-native/compare/sampleapp@v1.31.5...sampleapp@v1.31.6) (2024-11-14) + +### Workspaces + +- Following linked packages updated: [stream-chat-react-native] +### [1.31.5](https://github.com/GetStream/stream-chat-react-native/compare/sampleapp@v1.31.4...sampleapp@v1.31.5) (2024-11-08) ### Workspaces -* Following linked packages updated: [stream-chat-react-native] +- Following linked packages updated: [stream-chat-react-native] + +### [1.31.4](https://github.com/GetStream/stream-chat-react-native/compare/sampleapp@v1.31.3...sampleapp@v1.31.4) (2024-11-07) -### [1.31.2](https://github.com/GetStream/stream-chat-react-native/compare/sampleapp@v1.31.1...sampleapp@v1.31.2) (2024-11-01) +### Workspaces + +- Following linked packages updated: [stream-chat-react-native] +### [1.31.3](https://github.com/GetStream/stream-chat-react-native/compare/sampleapp@v1.31.2...sampleapp@v1.31.3) (2024-11-04) ### Workspaces -* Following linked packages updated: [stream-chat-react-native] +- Following linked packages updated: [stream-chat-react-native] -### [1.31.1](https://github.com/GetStream/stream-chat-react-native/compare/sampleapp@v1.31.0...sampleapp@v1.31.1) (2024-10-31) +### [1.31.2](https://github.com/GetStream/stream-chat-react-native/compare/sampleapp@v1.31.1...sampleapp@v1.31.2) (2024-11-01) +### Workspaces + +- Following linked packages updated: [stream-chat-react-native] + +### [1.31.1](https://github.com/GetStream/stream-chat-react-native/compare/sampleapp@v1.31.0...sampleapp@v1.31.1) (2024-10-31) ### Workspaces -* Following linked packages updated: [stream-chat-react-native] +- Following linked packages updated: [stream-chat-react-native] ## [1.31.0](https://github.com/GetStream/stream-chat-react-native/compare/sampleapp@v1.30.6...sampleapp@v1.31.0) (2024-10-31) - ### Features -* polls implementation ([#2719](https://github.com/GetStream/stream-chat-react-native/issues/2719)) ([c770854](https://github.com/GetStream/stream-chat-react-native/commit/c7708544d49e27dab4a2fee08c235fb39afd2178)) - +- polls implementation ([#2719](https://github.com/GetStream/stream-chat-react-native/issues/2719)) ([c770854](https://github.com/GetStream/stream-chat-react-native/commit/c7708544d49e27dab4a2fee08c235fb39afd2178)) ### Bug Fixes -* bump sample apps and store issues ([#2735](https://github.com/GetStream/stream-chat-react-native/issues/2735)) ([424aefb](https://github.com/GetStream/stream-chat-react-native/commit/424aefba4b90b2de8c5bff59e52c0e9aaa580d09)) -* remove macos deployment destination ([#2736](https://github.com/GetStream/stream-chat-react-native/issues/2736)) ([e81c6bc](https://github.com/GetStream/stream-chat-react-native/commit/e81c6bc9a0e5734e7af02d59f8d644e7dbde36cb)) - +- bump sample apps and store issues ([#2735](https://github.com/GetStream/stream-chat-react-native/issues/2735)) ([424aefb](https://github.com/GetStream/stream-chat-react-native/commit/424aefba4b90b2de8c5bff59e52c0e9aaa580d09)) +- remove macos deployment destination ([#2736](https://github.com/GetStream/stream-chat-react-native/issues/2736)) ([e81c6bc](https://github.com/GetStream/stream-chat-react-native/commit/e81c6bc9a0e5734e7af02d59f8d644e7dbde36cb)) ### Workspaces -* Following linked packages updated: [stream-chat-react-native] +- Following linked packages updated: [stream-chat-react-native] ### [1.30.6](https://github.com/GetStream/stream-chat-react-native/compare/sampleapp@v1.30.5...sampleapp@v1.30.6) (2024-10-28) - ### Workspaces -* Following linked packages updated: [stream-chat-react-native] +- Following linked packages updated: [stream-chat-react-native] ### [1.30.5](https://github.com/GetStream/stream-chat-react-native/compare/sampleapp@v1.30.4...sampleapp@v1.30.5) (2024-10-24) - ### Workspaces -* Following linked packages updated: [stream-chat-react-native] +- Following linked packages updated: [stream-chat-react-native] ### [1.30.4](https://github.com/GetStream/stream-chat-react-native/compare/sampleapp@v1.30.3...sampleapp@v1.30.4) (2024-10-21) - ### Workspaces -* Following linked packages updated: [stream-chat-react-native] +- Following linked packages updated: [stream-chat-react-native] ### [1.30.3](https://github.com/GetStream/stream-chat-react-native/compare/sampleapp@v1.30.2...sampleapp@v1.30.3) (2024-10-15) - ### Workspaces -* Following linked packages updated: [stream-chat-react-native] +- Following linked packages updated: [stream-chat-react-native] ### [1.30.2](https://github.com/GetStream/stream-chat-react-native/compare/sampleapp@v1.30.1...sampleapp@v1.30.2) (2024-10-14) diff --git a/examples/SampleApp/ios/Podfile.lock b/examples/SampleApp/ios/Podfile.lock index 598a4f957..7806c7661 100644 --- a/examples/SampleApp/ios/Podfile.lock +++ b/examples/SampleApp/ios/Podfile.lock @@ -2187,7 +2187,7 @@ PODS: - libwebp (~> 1.0) - SDWebImage/Core (~> 5.10) - SocketRocket (0.7.1) - - stream-chat-react-native (5.41.4): + - stream-chat-react-native (5.43.1): - DoubleConversion - glog - hermes-engine @@ -2603,7 +2603,7 @@ SPEC CHECKSUMS: SDWebImage: a7f831e1a65eb5e285e3fb046a23fcfbf08e696d SDWebImageWebPCoder: 908b83b6adda48effe7667cd2b7f78c897e5111d SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748 - stream-chat-react-native: 5f358230d87074128d47ea6bee43ef6a81720186 + stream-chat-react-native: 98ee8e5faacce9bbdcbf8579802c6d04897e48d0 Yoga: 83048fe4b4ce15018a5e9ccbf0b06bd76fc643d4 PODFILE CHECKSUM: 4f662370295f8f9cee909f1a4c59a614999a209d diff --git a/examples/SampleApp/package.json b/examples/SampleApp/package.json index 329abc4f6..2f1e4142f 100644 --- a/examples/SampleApp/package.json +++ b/examples/SampleApp/package.json @@ -1,6 +1,6 @@ { "name": "sampleapp", - "version": "1.31.5", + "version": "1.32.1", "private": true, "repository": { "type": "git", diff --git a/examples/SampleApp/src/components/NewDirectMessagingSendButton.tsx b/examples/SampleApp/src/components/NewDirectMessagingSendButton.tsx index a0c8d716a..557820c63 100644 --- a/examples/SampleApp/src/components/NewDirectMessagingSendButton.tsx +++ b/examples/SampleApp/src/components/NewDirectMessagingSendButton.tsx @@ -4,18 +4,11 @@ import { TouchableOpacity } from 'react-native-gesture-handler'; import { useNavigation } from '@react-navigation/core'; import { - DefaultAttachmentType, - DefaultChannelType, - DefaultCommandType, - DefaultEventType, - DefaultMessageType, - DefaultReactionType, - DefaultUserType, + DefaultStreamChatGenerics, MessageInputContextValue, Search, SendRight, SendUp, - UnknownType, useChannelContext, useMessageInputContext, useTheme, @@ -23,30 +16,18 @@ import { import { NewDirectMessagingScreenNavigationProp } from '../screens/NewDirectMessagingScreen'; -import { StreamChatGenerics } from '../types'; +import { StreamChatGenerics as LocalStreamChatGenerics } from '../types'; type NewDirectMessagingSendButtonPropsWithContext< - At extends UnknownType = DefaultAttachmentType, - Ch extends UnknownType = DefaultChannelType, - Co extends string = DefaultCommandType, - Ev extends UnknownType = DefaultEventType, - Me extends UnknownType = DefaultMessageType, - Re extends UnknownType = DefaultReactionType, - Us extends UnknownType = DefaultUserType, -> = Pick, 'giphyActive' | 'sendMessage'> & { + StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics, +> = Pick, 'giphyActive' | 'sendMessage'> & { /** Disables the button */ disabled: boolean; }; const SendButtonWithContext = < - At extends UnknownType = DefaultAttachmentType, - Ch extends UnknownType = DefaultChannelType, - Co extends string = DefaultCommandType, - Ev extends UnknownType = DefaultEventType, - Me extends UnknownType = DefaultMessageType, - Re extends UnknownType = DefaultReactionType, - Us extends UnknownType = DefaultUserType, + StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics, >( - props: NewDirectMessagingSendButtonPropsWithContext, + props: NewDirectMessagingSendButtonPropsWithContext, ) => { const { disabled = false, giphyActive, sendMessage } = props; const { @@ -70,17 +51,9 @@ const SendButtonWithContext = < ); }; -const areEqual = < - At extends UnknownType = DefaultAttachmentType, - Ch extends UnknownType = DefaultChannelType, - Co extends string = DefaultCommandType, - Ev extends UnknownType = DefaultEventType, - Me extends UnknownType = DefaultMessageType, - Re extends UnknownType = DefaultReactionType, - Us extends UnknownType = DefaultUserType, ->( - prevProps: NewDirectMessagingSendButtonPropsWithContext, - nextProps: NewDirectMessagingSendButtonPropsWithContext, +const areEqual = ( + prevProps: NewDirectMessagingSendButtonPropsWithContext, + nextProps: NewDirectMessagingSendButtonPropsWithContext, ) => { const { disabled: prevDisabled, @@ -117,23 +90,17 @@ const MemoizedNewDirectMessagingSendButton = React.memo( ) as typeof SendButtonWithContext; export type SendButtonProps< - At extends UnknownType = DefaultAttachmentType, - Ch extends UnknownType = DefaultChannelType, - Co extends string = DefaultCommandType, - Ev extends UnknownType = DefaultEventType, - Me extends UnknownType = DefaultMessageType, - Re extends UnknownType = DefaultReactionType, - Us extends UnknownType = DefaultUserType, -> = Partial>; + StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics, +> = Partial>; /** * UI Component for send button in MessageInput component. */ -export const NewDirectMessagingSendButton = (props: SendButtonProps) => { +export const NewDirectMessagingSendButton = (props: SendButtonProps) => { const navigation = useNavigation(); - const { channel } = useChannelContext(); + const { channel } = useChannelContext(); - const { giphyActive, text } = useMessageInputContext(); + const { giphyActive, text } = useMessageInputContext(); const sendMessage = async () => { if (!channel) { @@ -152,7 +119,7 @@ export const NewDirectMessagingSendButton = (props: SendButtonProps + {...{ giphyActive, sendMessage }} {...props} {...{ disabled: props.disabled || false }} diff --git a/examples/SampleApp/src/types.ts b/examples/SampleApp/src/types.ts index 25467f87d..fb95c6a0e 100644 --- a/examples/SampleApp/src/types.ts +++ b/examples/SampleApp/src/types.ts @@ -17,12 +17,14 @@ export type LocalUserType = { }; type LocalPollOptionType = Record; type LocalPollType = Record; +type LocalMemberType = Record; export type StreamChatGenerics = { attachmentType: LocalAttachmentType; channelType: LocalChannelType; commandType: LocalCommandType; eventType: LocalEventType; + memberType: LocalMemberType; messageType: LocalMessageType; pollOptionType: LocalPollOptionType; pollType: LocalPollType; diff --git a/examples/SampleApp/yarn.lock b/examples/SampleApp/yarn.lock index b73c13e4a..2156e729a 100644 --- a/examples/SampleApp/yarn.lock +++ b/examples/SampleApp/yarn.lock @@ -7361,10 +7361,10 @@ statuses@~1.5.0: resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" integrity sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA== -stream-chat-react-native-core@5.41.4: - version "5.41.4" - resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.41.4.tgz#55104e1eb10f464b27d82b9566a18005723ea26d" - integrity sha512-Fe2AnbfZ98nRfP5BwMOwR2iae/hT8N5oEiYOb2FwbgtJqot4UFABZDCxMVcoYcFouOK1gc5BkTjdnXYYm/L8EQ== +stream-chat-react-native-core@5.43.1: + version "5.43.1" + resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.43.1.tgz#ec0d5a06e329c8991c46cff5bd0211bc94d2b26f" + integrity sha512-qj/WfjFeCCP2wcp1YZGFJgRYGdSWXd0maG3hn3oURgFR6p/BmO6lDL2g3jnLq0SEkD8x+KZeNBS9cs1gW5Gblw== dependencies: "@gorhom/bottom-sheet" "^4.6.4" dayjs "1.10.5" @@ -7377,7 +7377,7 @@ stream-chat-react-native-core@5.41.4: path "0.12.7" react-native-markdown-package "1.8.2" react-native-url-polyfill "^1.3.0" - stream-chat "8.42.0" + stream-chat "8.45.1" "stream-chat-react-native-core@link:../../package": version "0.0.0" @@ -7387,10 +7387,10 @@ stream-chat-react-native-core@5.41.4: version "0.0.0" uid "" -stream-chat@8.42.0: - version "8.42.0" - resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-8.42.0.tgz#124ea2c10c6e8f7990304e1101c66751daf63e6c" - integrity sha512-8xZz+fmdHSOa3L1rHUOC4Wah+ipvLvdiOmeOfGK6uXnLOKlSHMOblwmQErrOoFM4SKfX9Bea3V8viaKUu6bPng== +stream-chat@8.45.1: + version "8.45.1" + resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-8.45.1.tgz#001f452520602ebffe45f1634b5f5dd1ff036ec5" + integrity sha512-7OMpL2RHUd+PXSWzhTUAIjjXlI9Oqc4HhUBRfc5i6dK+Ug9S5ertb7RvyzGL5N4ITpq/6ZUAwXtTqRaN9+UUkw== dependencies: "@babel/runtime" "^7.16.3" "@types/jsonwebtoken" "~9.0.0" diff --git a/examples/TypeScriptMessaging/App.tsx b/examples/TypeScriptMessaging/App.tsx index f0722eda2..459efc898 100644 --- a/examples/TypeScriptMessaging/App.tsx +++ b/examples/TypeScriptMessaging/App.tsx @@ -36,12 +36,14 @@ type LocalReactionType = Record; type LocalUserType = Record; type LocalPollOptionType = Record; type LocalPollType = Record; +type LocalMemberType = Record; type StreamChatGenerics = { attachmentType: LocalAttachmentType; channelType: LocalChannelType; commandType: LocalCommandType; eventType: LocalEventType; + memberType: LocalMemberType; messageType: LocalMessageType; pollOptionType: LocalPollOptionType; pollType: LocalPollType; diff --git a/examples/TypeScriptMessaging/ios/Podfile.lock b/examples/TypeScriptMessaging/ios/Podfile.lock index 1106a344a..61cf267f9 100644 --- a/examples/TypeScriptMessaging/ios/Podfile.lock +++ b/examples/TypeScriptMessaging/ios/Podfile.lock @@ -1991,7 +1991,7 @@ PODS: - ReactCommon/turbomodule/core - Yoga - SocketRocket (0.7.1) - - stream-chat-react-native (5.41.4): + - stream-chat-react-native (5.43.1): - DoubleConversion - glog - hermes-engine @@ -2344,7 +2344,7 @@ SPEC CHECKSUMS: RNShare: 4305edead1b8f614ab994046c68193e8d50aaadc RNSVG: 536cd3c866c878faf72beaba166c8b02fe2b762b SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748 - stream-chat-react-native: 3dd1b4ffe7aa3dba15f4f7ed23c19712b25ad230 + stream-chat-react-native: 29e7961f8f0e5c8f80fcc421450122673d82d355 Yoga: db69236006b8b1c6d55ab453390c882306cbf219 PODFILE CHECKSUM: 6b7a4b74915b42bfe4ffddaf67cbf5e7a2bfeab3 diff --git a/examples/TypeScriptMessaging/yarn.lock b/examples/TypeScriptMessaging/yarn.lock index c9cfcaa98..a2df4c063 100644 --- a/examples/TypeScriptMessaging/yarn.lock +++ b/examples/TypeScriptMessaging/yarn.lock @@ -6807,10 +6807,10 @@ statuses@~1.5.0: resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" integrity sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA== -stream-chat-react-native-core@5.41.4: - version "5.41.4" - resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.41.4.tgz#55104e1eb10f464b27d82b9566a18005723ea26d" - integrity sha512-Fe2AnbfZ98nRfP5BwMOwR2iae/hT8N5oEiYOb2FwbgtJqot4UFABZDCxMVcoYcFouOK1gc5BkTjdnXYYm/L8EQ== +stream-chat-react-native-core@5.43.1: + version "5.43.1" + resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.43.1.tgz#ec0d5a06e329c8991c46cff5bd0211bc94d2b26f" + integrity sha512-qj/WfjFeCCP2wcp1YZGFJgRYGdSWXd0maG3hn3oURgFR6p/BmO6lDL2g3jnLq0SEkD8x+KZeNBS9cs1gW5Gblw== dependencies: "@gorhom/bottom-sheet" "^4.6.4" dayjs "1.10.5" @@ -6823,7 +6823,7 @@ stream-chat-react-native-core@5.41.4: path "0.12.7" react-native-markdown-package "1.8.2" react-native-url-polyfill "^1.3.0" - stream-chat "8.42.0" + stream-chat "8.45.1" "stream-chat-react-native-core@link:../../package": version "0.0.0" @@ -6833,10 +6833,10 @@ stream-chat-react-native-core@5.41.4: version "0.0.0" uid "" -stream-chat@8.42.0: - version "8.42.0" - resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-8.42.0.tgz#124ea2c10c6e8f7990304e1101c66751daf63e6c" - integrity sha512-8xZz+fmdHSOa3L1rHUOC4Wah+ipvLvdiOmeOfGK6uXnLOKlSHMOblwmQErrOoFM4SKfX9Bea3V8viaKUu6bPng== +stream-chat@8.45.1: + version "8.45.1" + resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-8.45.1.tgz#001f452520602ebffe45f1634b5f5dd1ff036ec5" + integrity sha512-7OMpL2RHUd+PXSWzhTUAIjjXlI9Oqc4HhUBRfc5i6dK+Ug9S5ertb7RvyzGL5N4ITpq/6ZUAwXtTqRaN9+UUkw== dependencies: "@babel/runtime" "^7.16.3" "@types/jsonwebtoken" "~9.0.0" diff --git a/package/CHANGELOG.md b/package/CHANGELOG.md index 8742ce2ff..0953026b5 100644 --- a/package/CHANGELOG.md +++ b/package/CHANGELOG.md @@ -1,81 +1,111 @@ # Change Log -### [5.41.4](https://github.com/GetStream/stream-chat-react-native/compare/v5.41.3...v5.41.4) (2024-11-08) +### [5.43.1](https://github.com/GetStream/stream-chat-react-native/compare/v5.43.0...v5.43.1) (2024-11-22) + +### Bug Fixes +- channel.state break on going to background ([#2809](https://github.com/GetStream/stream-chat-react-native/issues/2809)) ([54ff925](https://github.com/GetStream/stream-chat-react-native/commit/54ff925405ad3cc3c269f92b054955fff3086e0a)) + +## [5.43.0](https://github.com/GetStream/stream-chat-react-native/compare/v5.42.2...v5.43.0) (2024-11-20) + +### Features + +- add support for membership customization ([#2802](https://github.com/GetStream/stream-chat-react-native/issues/2802)) ([376ac7d](https://github.com/GetStream/stream-chat-react-native/commit/376ac7d5bd5a5c34080b2272601300633b3412f1)) +- moderation v2 support ([#2801](https://github.com/GetStream/stream-chat-react-native/issues/2801)) ([9c55bd5](https://github.com/GetStream/stream-chat-react-native/commit/9c55bd543215a6c615b3e088238154bba34a958f)) + +### [5.42.2](https://github.com/GetStream/stream-chat-react-native/compare/v5.42.1...v5.42.2) (2024-11-19) ### Bug Fixes -* poll edge cases ([#2768](https://github.com/GetStream/stream-chat-react-native/issues/2768)) ([b26b98c](https://github.com/GetStream/stream-chat-react-native/commit/b26b98c5cb34e5446c1600026fbaa1f442d8dbcb)) -* theme for the message bubble and replies ([#2766](https://github.com/GetStream/stream-chat-react-native/issues/2766)) ([980c383](https://github.com/GetStream/stream-chat-react-native/commit/980c3832a4a59ebab07c67f1d24a50ebe587e8fe)) +- backporting variety fixes ([008cf01](https://github.com/GetStream/stream-chat-react-native/commit/008cf01ddaa31e105ac2bab7052e1340b7583507)) +- channel hook regressions ([e8e3dd0](https://github.com/GetStream/stream-chat-react-native/commit/e8e3dd0af396671949f3c12086816329a962dd08)) +- expo media library permissions race conditions ([fc9b908](https://github.com/GetStream/stream-chat-react-native/commit/fc9b908799a3d517a64b6388bdfd268c2dc16981)) +- listen to correct channel read events ([5a58a65](https://github.com/GetStream/stream-chat-react-native/commit/5a58a65106d963cd95d3d2df31afe2459b2b902e)) +- recursion depth on regex parse issue ([#2790](https://github.com/GetStream/stream-chat-react-native/issues/2790)) ([e6908e9](https://github.com/GetStream/stream-chat-react-native/commit/e6908e9ddfa1722d1f610cb0d4d5be2c05f910e1)) -### [5.41.3](https://github.com/GetStream/stream-chat-react-native/compare/v5.41.2...v5.41.3) (2024-11-07) +### [5.42.1](https://github.com/GetStream/stream-chat-react-native/compare/v5.42.0...v5.42.1) (2024-11-15) +### Bug Fixes + +- android modal size ([#2784](https://github.com/GetStream/stream-chat-react-native/issues/2784)) ([fe64697](https://github.com/GetStream/stream-chat-react-native/commit/fe646976782353836ee5ca58058125e7b9c53132)) +- backport crash fix ([#2787](https://github.com/GetStream/stream-chat-react-native/issues/2787)) ([9b5b243](https://github.com/GetStream/stream-chat-react-native/commit/9b5b243cf91bc80a1fbe50913dbbdc954c973bca)) + +## [5.42.0](https://github.com/GetStream/stream-chat-react-native/compare/v5.41.4...v5.42.0) (2024-11-14) + +### Features + +- listen to notification.mark_read and notification.mark_unread event and introduce improvements ([#2776](https://github.com/GetStream/stream-chat-react-native/issues/2776)) ([834d124](https://github.com/GetStream/stream-chat-react-native/commit/834d124c9bb8c9ffc24537a5fe870009fd00e3fa)) ### Bug Fixes -* check for channel validity before consuming config ([#2760](https://github.com/GetStream/stream-chat-react-native/issues/2760)) ([ff53399](https://github.com/GetStream/stream-chat-react-native/commit/ff5339982914051b6e8f941a4799fc772ce409aa)) -* message disallowed indicator display ([#2754](https://github.com/GetStream/stream-chat-react-native/issues/2754)) ([fe08bd7](https://github.com/GetStream/stream-chat-react-native/commit/fe08bd75ea1d7d3041b86b1e8519f2f04b9c19bc)) -* native image picker poll control ([#2762](https://github.com/GetStream/stream-chat-react-native/issues/2762)) ([b9c49be](https://github.com/GetStream/stream-chat-react-native/commit/b9c49be85b8d7927dc64f55d7e9ba01b11737016)) -* receiverMessageBackgroundColor hotfix ([#2763](https://github.com/GetStream/stream-chat-react-native/issues/2763)) ([5258a18](https://github.com/GetStream/stream-chat-react-native/commit/5258a18468fe9716918ec9e663ae5e0861b17df5)) +- scroll to recent issues ([#2775](https://github.com/GetStream/stream-chat-react-native/issues/2775)) ([feea8ee](https://github.com/GetStream/stream-chat-react-native/commit/feea8ee4588d4a048e52d5c719aaf6f6c4011454)) -### [5.41.2](https://github.com/GetStream/stream-chat-react-native/compare/v5.41.1...v5.41.2) (2024-11-04) +### [5.41.4](https://github.com/GetStream/stream-chat-react-native/compare/v5.41.3...v5.41.4) (2024-11-08) +### Bug Fixes + +- poll edge cases ([#2768](https://github.com/GetStream/stream-chat-react-native/issues/2768)) ([b26b98c](https://github.com/GetStream/stream-chat-react-native/commit/b26b98c5cb34e5446c1600026fbaa1f442d8dbcb)) +- theme for the message bubble and replies ([#2766](https://github.com/GetStream/stream-chat-react-native/issues/2766)) ([980c383](https://github.com/GetStream/stream-chat-react-native/commit/980c3832a4a59ebab07c67f1d24a50ebe587e8fe)) + +### [5.41.3](https://github.com/GetStream/stream-chat-react-native/compare/v5.41.2...v5.41.3) (2024-11-07) ### Bug Fixes -* add polyfill for Array.prototype.at ([#2752](https://github.com/GetStream/stream-chat-react-native/issues/2752)) ([c5a3046](https://github.com/GetStream/stream-chat-react-native/commit/c5a3046c8612581b6beaa9ed88a05925fb043a11)) -* disable typing events when offline ([#2753](https://github.com/GetStream/stream-chat-react-native/issues/2753)) ([ba9bccd](https://github.com/GetStream/stream-chat-react-native/commit/ba9bccd89a6b490d15cf34ad22d030622bc5255b)) +- check for channel validity before consuming config ([#2760](https://github.com/GetStream/stream-chat-react-native/issues/2760)) ([ff53399](https://github.com/GetStream/stream-chat-react-native/commit/ff5339982914051b6e8f941a4799fc772ce409aa)) +- message disallowed indicator display ([#2754](https://github.com/GetStream/stream-chat-react-native/issues/2754)) ([fe08bd7](https://github.com/GetStream/stream-chat-react-native/commit/fe08bd75ea1d7d3041b86b1e8519f2f04b9c19bc)) +- native image picker poll control ([#2762](https://github.com/GetStream/stream-chat-react-native/issues/2762)) ([b9c49be](https://github.com/GetStream/stream-chat-react-native/commit/b9c49be85b8d7927dc64f55d7e9ba01b11737016)) +- receiverMessageBackgroundColor hotfix ([#2763](https://github.com/GetStream/stream-chat-react-native/issues/2763)) ([5258a18](https://github.com/GetStream/stream-chat-react-native/commit/5258a18468fe9716918ec9e663ae5e0861b17df5)) -### [5.41.1](https://github.com/GetStream/stream-chat-react-native/compare/v5.41.0...v5.41.1) (2024-11-01) +### [5.41.2](https://github.com/GetStream/stream-chat-react-native/compare/v5.41.1...v5.41.2) (2024-11-04) + +### Bug Fixes +- add polyfill for Array.prototype.at ([#2752](https://github.com/GetStream/stream-chat-react-native/issues/2752)) ([c5a3046](https://github.com/GetStream/stream-chat-react-native/commit/c5a3046c8612581b6beaa9ed88a05925fb043a11)) +- disable typing events when offline ([#2753](https://github.com/GetStream/stream-chat-react-native/issues/2753)) ([ba9bccd](https://github.com/GetStream/stream-chat-react-native/commit/ba9bccd89a6b490d15cf34ad22d030622bc5255b)) + +### [5.41.1](https://github.com/GetStream/stream-chat-react-native/compare/v5.41.0...v5.41.1) (2024-11-01) ### Bug Fixes -* Channel thread type ([#2748](https://github.com/GetStream/stream-chat-react-native/issues/2748)) ([d7deaf4](https://github.com/GetStream/stream-chat-react-native/commit/d7deaf47674cde28e711488488e6054e78ad072e)) +- Channel thread type ([#2748](https://github.com/GetStream/stream-chat-react-native/issues/2748)) ([d7deaf4](https://github.com/GetStream/stream-chat-react-native/commit/d7deaf47674cde28e711488488e6054e78ad072e)) ## [5.41.0](https://github.com/GetStream/stream-chat-react-native/compare/v5.40.0...v5.41.0) (2024-10-31) - ### Features -* rename poll state selector props ([#2745](https://github.com/GetStream/stream-chat-react-native/issues/2745)) ([45e5959](https://github.com/GetStream/stream-chat-react-native/commit/45e5959a85a096423bb49e1c5411a4505cfdd6ca)) +- rename poll state selector props ([#2745](https://github.com/GetStream/stream-chat-react-native/issues/2745)) ([45e5959](https://github.com/GetStream/stream-chat-react-native/commit/45e5959a85a096423bb49e1c5411a4505cfdd6ca)) ## [5.40.0](https://github.com/GetStream/stream-chat-react-native/compare/v5.39.6...v5.40.0) (2024-10-31) - ### Features -* polls implementation ([#2719](https://github.com/GetStream/stream-chat-react-native/issues/2719)) ([c770854](https://github.com/GetStream/stream-chat-react-native/commit/c7708544d49e27dab4a2fee08c235fb39afd2178)) +- polls implementation ([#2719](https://github.com/GetStream/stream-chat-react-native/issues/2719)) ([c770854](https://github.com/GetStream/stream-chat-react-native/commit/c7708544d49e27dab4a2fee08c235fb39afd2178)) ### [5.39.6](https://github.com/GetStream/stream-chat-react-native/compare/v5.39.5...v5.39.6) (2024-10-28) - ### Bug Fixes -* state store with new api ([#2726](https://github.com/GetStream/stream-chat-react-native/issues/2726)) ([19d8fda](https://github.com/GetStream/stream-chat-react-native/commit/19d8fda7ee17ad9b19c80d3aa6d2e3ca13c5d9b8)) +- state store with new api ([#2726](https://github.com/GetStream/stream-chat-react-native/issues/2726)) ([19d8fda](https://github.com/GetStream/stream-chat-react-native/commit/19d8fda7ee17ad9b19c80d3aa6d2e3ca13c5d9b8)) ### [5.39.5](https://github.com/GetStream/stream-chat-react-native/compare/v5.39.4...v5.39.5) (2024-10-24) - ### Bug Fixes -* add theme for overlay reaction list icon and introduce shouldShowUnreadOverlay for message bubble ([#2722](https://github.com/GetStream/stream-chat-react-native/issues/2722)) ([2a7cee3](https://github.com/GetStream/stream-chat-react-native/commit/2a7cee35be31546028dc45b6c6659b9e93220df4)) -* inline date separator not being rendered for deleted message appropriately ([#2716](https://github.com/GetStream/stream-chat-react-native/issues/2716)) ([9f2bb15](https://github.com/GetStream/stream-chat-react-native/commit/9f2bb15e8c52f3d8b4011108c84608e37ab90667)) +- add theme for overlay reaction list icon and introduce shouldShowUnreadOverlay for message bubble ([#2722](https://github.com/GetStream/stream-chat-react-native/issues/2722)) ([2a7cee3](https://github.com/GetStream/stream-chat-react-native/commit/2a7cee35be31546028dc45b6c6659b9e93220df4)) +- inline date separator not being rendered for deleted message appropriately ([#2716](https://github.com/GetStream/stream-chat-react-native/issues/2716)) ([9f2bb15](https://github.com/GetStream/stream-chat-react-native/commit/9f2bb15e8c52f3d8b4011108c84608e37ab90667)) ### [5.39.4](https://github.com/GetStream/stream-chat-react-native/compare/v5.39.3...v5.39.4) (2024-10-21) - ### Bug Fixes -* add sender and receiver background color for message bubble in message overlay ([#2710](https://github.com/GetStream/stream-chat-react-native/issues/2710)) ([7e64290](https://github.com/GetStream/stream-chat-react-native/commit/7e64290c4131c15666102478ca94ce50910d0189)) -* double loading when targetting a message ([#2711](https://github.com/GetStream/stream-chat-react-native/issues/2711)) ([fdb4f17](https://github.com/GetStream/stream-chat-react-native/commit/fdb4f17991ffde7f9c59dd690f8913e9a75e8560)) +- add sender and receiver background color for message bubble in message overlay ([#2710](https://github.com/GetStream/stream-chat-react-native/issues/2710)) ([7e64290](https://github.com/GetStream/stream-chat-react-native/commit/7e64290c4131c15666102478ca94ce50910d0189)) +- double loading when targetting a message ([#2711](https://github.com/GetStream/stream-chat-react-native/issues/2711)) ([fdb4f17](https://github.com/GetStream/stream-chat-react-native/commit/fdb4f17991ffde7f9c59dd690f8913e9a75e8560)) ### [5.39.3](https://github.com/GetStream/stream-chat-react-native/compare/v5.39.2...v5.39.3) (2024-10-15) - ### Bug Fixes -* ChannelAvatar crash when used outside of ChannelList ([#2708](https://github.com/GetStream/stream-chat-react-native/issues/2708)) ([85f4ab2](https://github.com/GetStream/stream-chat-react-native/commit/85f4ab21adf4b0da636475f0285e3360d9b1309b)) +- ChannelAvatar crash when used outside of ChannelList ([#2708](https://github.com/GetStream/stream-chat-react-native/issues/2708)) ([85f4ab2](https://github.com/GetStream/stream-chat-react-native/commit/85f4ab21adf4b0da636475f0285e3360d9b1309b)) ### [5.39.2](https://github.com/GetStream/stream-chat-react-native/compare/v5.39.1...v5.39.2) (2024-10-14) diff --git a/package/expo-package/package.json b/package/expo-package/package.json index d194952ca..0afd65efd 100644 --- a/package/expo-package/package.json +++ b/package/expo-package/package.json @@ -1,7 +1,7 @@ { "name": "stream-chat-expo", "description": "The official Expo SDK for Stream Chat, a service for building chat applications", - "version": "5.41.4", + "version": "5.43.1", "author": { "company": "Stream.io Inc", "name": "Stream.io Inc" @@ -10,7 +10,7 @@ "main": "src/index.js", "types": "types/index.d.ts", "dependencies": { - "stream-chat-react-native-core": "5.41.4" + "stream-chat-react-native-core": "5.43.1" }, "peerDependencies": { "expo": ">=51.0.0", diff --git a/package/expo-package/src/optionalDependencies/pickImage.ts b/package/expo-package/src/optionalDependencies/pickImage.ts index 9d2ce1153..fa6b98d03 100644 --- a/package/expo-package/src/optionalDependencies/pickImage.ts +++ b/package/expo-package/src/optionalDependencies/pickImage.ts @@ -53,8 +53,10 @@ export const pickImage = ImagePicker return { cancelled: true }; } } + return { cancelled: true }; } catch (error) { console.log('Error while picking image', error); + return { cancelled: true }; } } : null; diff --git a/package/expo-package/yarn.lock b/package/expo-package/yarn.lock index a8db4e9d2..ad6bd47ed 100644 --- a/package/expo-package/yarn.lock +++ b/package/expo-package/yarn.lock @@ -5113,10 +5113,10 @@ stream-buffers@2.2.x, stream-buffers@~2.2.0: resolved "https://registry.yarnpkg.com/stream-buffers/-/stream-buffers-2.2.0.tgz#91d5f5130d1cef96dcfa7f726945188741d09ee4" integrity sha512-uyQK/mx5QjHun80FLJTfaWE7JtwfRMKBLkMne6udYOmvH0CawotVa7TfgYHzAnpphn4+TweIx1QKMnRIbipmUg== -stream-chat-react-native-core@5.41.4: - version "5.41.4" - resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.41.4.tgz#55104e1eb10f464b27d82b9566a18005723ea26d" - integrity sha512-Fe2AnbfZ98nRfP5BwMOwR2iae/hT8N5oEiYOb2FwbgtJqot4UFABZDCxMVcoYcFouOK1gc5BkTjdnXYYm/L8EQ== +stream-chat-react-native-core@5.43.1: + version "5.43.1" + resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.43.1.tgz#ec0d5a06e329c8991c46cff5bd0211bc94d2b26f" + integrity sha512-qj/WfjFeCCP2wcp1YZGFJgRYGdSWXd0maG3hn3oURgFR6p/BmO6lDL2g3jnLq0SEkD8x+KZeNBS9cs1gW5Gblw== dependencies: "@gorhom/bottom-sheet" "^4.6.4" dayjs "1.10.5" @@ -5129,12 +5129,12 @@ stream-chat-react-native-core@5.41.4: path "0.12.7" react-native-markdown-package "1.8.2" react-native-url-polyfill "^1.3.0" - stream-chat "8.42.0" + stream-chat "8.45.1" -stream-chat@8.42.0: - version "8.42.0" - resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-8.42.0.tgz#124ea2c10c6e8f7990304e1101c66751daf63e6c" - integrity sha512-8xZz+fmdHSOa3L1rHUOC4Wah+ipvLvdiOmeOfGK6uXnLOKlSHMOblwmQErrOoFM4SKfX9Bea3V8viaKUu6bPng== +stream-chat@8.45.1: + version "8.45.1" + resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-8.45.1.tgz#001f452520602ebffe45f1634b5f5dd1ff036ec5" + integrity sha512-7OMpL2RHUd+PXSWzhTUAIjjXlI9Oqc4HhUBRfc5i6dK+Ug9S5ertb7RvyzGL5N4ITpq/6ZUAwXtTqRaN9+UUkw== dependencies: "@babel/runtime" "^7.16.3" "@types/jsonwebtoken" "~9.0.0" diff --git a/package/native-package/package.json b/package/native-package/package.json index 095ba68bc..f421c9a38 100644 --- a/package/native-package/package.json +++ b/package/native-package/package.json @@ -1,7 +1,7 @@ { "name": "stream-chat-react-native", "description": "The official React Native SDK for Stream Chat, a service for building chat applications", - "version": "5.41.4", + "version": "5.43.1", "homepage": "https://www.npmjs.com/package/stream-chat-react-native", "author": { "company": "Stream.io Inc", @@ -20,7 +20,7 @@ "types": "types/index.d.ts", "dependencies": { "es6-symbol": "^3.1.3", - "stream-chat-react-native-core": "5.41.4" + "stream-chat-react-native-core": "5.43.1" }, "peerDependencies": { "@react-native-camera-roll/camera-roll": ">=7.8.0", diff --git a/package/native-package/src/optionalDependencies/pickImage.ts b/package/native-package/src/optionalDependencies/pickImage.ts index 574c1538e..5ab35fcd7 100644 --- a/package/native-package/src/optionalDependencies/pickImage.ts +++ b/package/native-package/src/optionalDependencies/pickImage.ts @@ -35,6 +35,7 @@ export const pickImage = ImagePicker } } catch (error) { console.log('Error picking image: ', error); + return { cancelled: true }; } } : null; diff --git a/package/native-package/yarn.lock b/package/native-package/yarn.lock index 9a8108dbd..210e554e7 100644 --- a/package/native-package/yarn.lock +++ b/package/native-package/yarn.lock @@ -4242,10 +4242,10 @@ statuses@~1.5.0: resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" integrity sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA== -stream-chat-react-native-core@5.41.4: - version "5.41.4" - resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.41.4.tgz#55104e1eb10f464b27d82b9566a18005723ea26d" - integrity sha512-Fe2AnbfZ98nRfP5BwMOwR2iae/hT8N5oEiYOb2FwbgtJqot4UFABZDCxMVcoYcFouOK1gc5BkTjdnXYYm/L8EQ== +stream-chat-react-native-core@5.43.1: + version "5.43.1" + resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.43.1.tgz#ec0d5a06e329c8991c46cff5bd0211bc94d2b26f" + integrity sha512-qj/WfjFeCCP2wcp1YZGFJgRYGdSWXd0maG3hn3oURgFR6p/BmO6lDL2g3jnLq0SEkD8x+KZeNBS9cs1gW5Gblw== dependencies: "@gorhom/bottom-sheet" "^4.6.4" dayjs "1.10.5" @@ -4258,12 +4258,12 @@ stream-chat-react-native-core@5.41.4: path "0.12.7" react-native-markdown-package "1.8.2" react-native-url-polyfill "^1.3.0" - stream-chat "8.42.0" + stream-chat "8.45.1" -stream-chat@8.42.0: - version "8.42.0" - resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-8.42.0.tgz#124ea2c10c6e8f7990304e1101c66751daf63e6c" - integrity sha512-8xZz+fmdHSOa3L1rHUOC4Wah+ipvLvdiOmeOfGK6uXnLOKlSHMOblwmQErrOoFM4SKfX9Bea3V8viaKUu6bPng== +stream-chat@8.45.1: + version "8.45.1" + resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-8.45.1.tgz#001f452520602ebffe45f1634b5f5dd1ff036ec5" + integrity sha512-7OMpL2RHUd+PXSWzhTUAIjjXlI9Oqc4HhUBRfc5i6dK+Ug9S5ertb7RvyzGL5N4ITpq/6ZUAwXtTqRaN9+UUkw== dependencies: "@babel/runtime" "^7.16.3" "@types/jsonwebtoken" "~9.0.0" diff --git a/package/package.json b/package/package.json index 83e89f5ad..2d69d91ce 100644 --- a/package/package.json +++ b/package/package.json @@ -1,7 +1,7 @@ { "name": "stream-chat-react-native-core", "description": "The official React Native and Expo components for Stream Chat, a service for building chat applications", - "version": "5.41.4", + "version": "5.43.1", "author": { "company": "Stream.io Inc", "name": "Stream.io Inc" @@ -77,7 +77,7 @@ "path": "0.12.7", "react-native-markdown-package": "1.8.2", "react-native-url-polyfill": "^1.3.0", - "stream-chat": "8.42.0" + "stream-chat": "8.45.1" }, "peerDependencies": { "@op-engineering/op-sqlite": ">=9.3.0", diff --git a/package/src/components/Channel/Channel.tsx b/package/src/components/Channel/Channel.tsx index f44ad45dc..486a031a9 100644 --- a/package/src/components/Channel/Channel.tsx +++ b/package/src/components/Channel/Channel.tsx @@ -1203,6 +1203,7 @@ const ChannelWithContext = < await channel.query({}, 'latest'); } await channel.state.loadMessageIntoState('latest'); + setMessages([...channel.state.messages]); }); const loadChannel = () => @@ -1399,13 +1400,17 @@ const ChannelWithContext = < }, [enableOfflineSupport, shouldSyncChannel]); const reloadChannel = () => - channelQueryCallRef.current(async () => { - setLoading(true); - await loadLatestMessagesRef.current(true); - setLoading(false); - channel?.state.setIsUpToDate(true); - setHasNoMoreRecentMessagesToLoad(true); - }); + channelQueryCallRef.current( + async () => { + setLoading(true); + await loadLatestMessagesRef.current(true); + setLoading(false); + }, + () => { + channel?.state.setIsUpToDate(true); + setHasNoMoreRecentMessagesToLoad(true); + }, + ); // In case the channel is disconnected which may happen when channel is deleted, // underlying js client throws an error. Following function ensures that Channel component @@ -1795,10 +1800,12 @@ const ChannelWithContext = < const latestLengthBeforeMerge = latestMessageSet?.messages.length || 0; const didMerge = mergeOverlappingMessageSetsRef.current(true); if (didMerge) { - if (latestMessageSet && latestLengthBeforeMerge >= limit) { + if (latestMessageSet && latestLengthBeforeMerge > 0) { + const shouldSetStateUpToDate = + latestMessageSet.messages.length < limit && latestMessageSet.isCurrent; setLoadingMoreRecent(true); - channel.state.setIsUpToDate(true); - setHasNoMoreRecentMessagesToLoad(true); + channel.state.setIsUpToDate(shouldSetStateUpToDate); + setHasNoMoreRecentMessagesToLoad(shouldSetStateUpToDate); loadMoreRecentFinished(channel.state.messages); restartSetsMergeFuncRef.current(); return; diff --git a/package/src/components/ChannelPreview/ChannelPreview.tsx b/package/src/components/ChannelPreview/ChannelPreview.tsx index 928d44c35..fb8edbbed 100644 --- a/package/src/components/ChannelPreview/ChannelPreview.tsx +++ b/package/src/components/ChannelPreview/ChannelPreview.tsx @@ -1,8 +1,8 @@ -import React, { useEffect, useState } from 'react'; +import React from 'react'; -import type { Channel, ChannelState, Event, MessageResponse } from 'stream-chat'; +import type { Channel } from 'stream-chat'; -import { useLatestMessagePreview } from './hooks/useLatestMessagePreview'; +import { useChannelPreviewData } from './hooks/useChannelPreviewData'; import { ChannelsContextValue, @@ -12,120 +12,41 @@ import { ChatContextValue, useChatContext } from '../../contexts/chatContext/Cha import type { DefaultStreamChatGenerics } from '../../types/types'; -export type ChannelPreviewPropsWithContext< +export type ChannelPreviewProps< StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics, -> = Pick, 'client'> & - Pick, 'Preview' | 'forceUpdate'> & { +> = Partial, 'client'>> & + Partial, 'Preview' | 'forceUpdate'>> & { /** * Instance of Channel from stream-chat package. */ channel: Channel; }; -/** - * This component manages state for the ChannelPreviewMessenger UI component and receives - * all props from the ChannelListMessenger component. - */ -const ChannelPreviewWithContext = < - StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics, ->( - props: ChannelPreviewPropsWithContext, -) => { - const { channel, client, forceUpdate: channelListForceUpdate, Preview } = props; - - const [lastMessage, setLastMessage] = useState< - | ReturnType['formatMessage']> - | MessageResponse - | undefined - >(channel.state.messages[channel.state.messages.length - 1]); - - const [forceUpdate, setForceUpdate] = useState(0); - const [unread, setUnread] = useState(channel.countUnread()); - - const latestMessagePreview = useLatestMessagePreview(channel, forceUpdate, lastMessage); - - const channelLastMessage = channel.lastMessage(); - const channelLastMessageString = `${channelLastMessage?.id}${channelLastMessage?.updated_at}`; - - useEffect(() => { - const { unsubscribe } = client.on('notification.mark_read', () => { - setUnread(channel.countUnread()); - }); - return unsubscribe; - // eslint-disable-next-line react-hooks/exhaustive-deps - }, []); - - useEffect(() => { - if ( - channelLastMessage && - (channelLastMessage.id !== lastMessage?.id || - channelLastMessage.updated_at !== lastMessage?.updated_at) - ) { - setLastMessage(channelLastMessage); - } - - const newUnreadCount = channel.countUnread(); - setUnread(newUnreadCount); - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [channelLastMessageString, channelListForceUpdate]); - - useEffect(() => { - const handleNewMessageEvent = (event: Event) => { - const message = event.message; - if (message && (!message.parent_id || message.show_in_channel)) { - setLastMessage(event.message); - setUnread(channel.countUnread()); - } - }; - - const handleUpdatedOrDeletedMessage = (event: Event) => { - setLastMessage((prevLastMessage) => { - if (prevLastMessage?.id === event.message?.id) { - return event.message; - } - return prevLastMessage; - }); - }; - - const listeners = [ - channel.on('message.new', handleNewMessageEvent), - channel.on('message.updated', handleUpdatedOrDeletedMessage), - channel.on('message.deleted', handleUpdatedOrDeletedMessage), - ]; - - return () => listeners.forEach((l) => l.unsubscribe()); - // eslint-disable-next-line react-hooks/exhaustive-deps - }, []); - - useEffect(() => { - const handleReadEvent = (event: Event) => { - if (event.user?.id === client.userID) { - setUnread(0); - } else if (event.user?.id) { - setForceUpdate((prev) => prev + 1); - } - }; - - const listener = channel.on('message.read', handleReadEvent); - return () => listener.unsubscribe(); - // eslint-disable-next-line react-hooks/exhaustive-deps - }, []); - - return ; -}; - -export type ChannelPreviewProps< - StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics, -> = Partial, 'channel'>> & - Pick, 'channel'>; - export const ChannelPreview = < StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics, >( props: ChannelPreviewProps, ) => { - const { client } = useChatContext(); - const { forceUpdate, Preview } = useChannelsContext(); - - return ; + const { channel, client: propClient, forceUpdate: propForceUpdate, Preview: propPreview } = props; + + const { client: contextClient } = useChatContext(); + const { Preview: contextPreview } = useChannelsContext(); + + const client = propClient || contextClient; + const Preview = propPreview || contextPreview; + + const { latestMessagePreview, muted, unread } = useChannelPreviewData( + channel, + client, + propForceUpdate, + ); + + return ( + + ); }; diff --git a/package/src/components/ChannelPreview/ChannelPreviewMessenger.tsx b/package/src/components/ChannelPreview/ChannelPreviewMessenger.tsx index 641f7c4c1..2805b6132 100644 --- a/package/src/components/ChannelPreview/ChannelPreviewMessenger.tsx +++ b/package/src/components/ChannelPreview/ChannelPreviewMessenger.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from 'react'; +import React from 'react'; import { StyleSheet, View } from 'react-native'; import { TouchableOpacity } from 'react-native-gesture-handler'; @@ -17,7 +17,6 @@ import { ChannelsContextValue, useChannelsContext, } from '../../contexts/channelsContext/ChannelsContext'; -import { useChatContext } from '../../contexts/chatContext/ChatContext'; import { useTheme } from '../../contexts/themeContext/ThemeContext'; import { useViewport } from '../../hooks/useViewport'; import type { DefaultStreamChatGenerics } from '../../types/types'; @@ -95,6 +94,8 @@ export type ChannelPreviewMessengerPropsWithContext< * default formatted date. This default logic is part of ChannelPreview component. */ formatLatestMessageDate?: (date: Date) => string; + /** If the channel is muted. */ + muted?: boolean; /** Number of unread messages on the channel */ unread?: number; }; @@ -109,6 +110,7 @@ const ChannelPreviewMessengerWithContext = < formatLatestMessageDate, latestMessagePreview, maxUnreadCount, + muted, onSelect, PreviewAvatar = ChannelAvatar, PreviewMessage = ChannelPreviewMessage, @@ -129,23 +131,11 @@ const ChannelPreviewMessengerWithContext = < }, } = useTheme(); - const { client } = useChatContext(); - const displayName = useChannelPreviewDisplayName( channel, Math.floor(maxWidth / ((title.fontSize || styles.title.fontSize) / 2)), ); - const [isChannelMuted, setIsChannelMuted] = useState(() => channel.muteStatus().muted); - - useEffect(() => { - const handleEvent = () => setIsChannelMuted(channel.muteStatus().muted); - - client.on('notification.channel_mutes_updated', handleEvent); - return () => client.off('notification.channel_mutes_updated', handleEvent); - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [client]); - return ( { @@ -168,7 +158,7 @@ const ChannelPreviewMessengerWithContext = < - {isChannelMuted && } + {muted && } diff --git a/package/src/components/ChannelPreview/ChannelPreviewMutedStatus.tsx b/package/src/components/ChannelPreview/ChannelPreviewMutedStatus.tsx index a3d26ee52..6cecff6ed 100644 --- a/package/src/components/ChannelPreview/ChannelPreviewMutedStatus.tsx +++ b/package/src/components/ChannelPreview/ChannelPreviewMutedStatus.tsx @@ -20,16 +20,11 @@ export const ChannelPreviewMutedStatus = () => { channelPreview: { mutedStatus: { height, iconStyle, width }, }, - colors: { grey_dark }, + colors: { grey }, }, } = useTheme(); return ( - + ); }; diff --git a/package/src/components/ChannelPreview/__tests__/ChannelPreview.test.tsx b/package/src/components/ChannelPreview/__tests__/ChannelPreview.test.tsx index b6c1dd50b..99e5329b2 100644 --- a/package/src/components/ChannelPreview/__tests__/ChannelPreview.test.tsx +++ b/package/src/components/ChannelPreview/__tests__/ChannelPreview.test.tsx @@ -11,8 +11,9 @@ import { } from '../../../mock-builders/api/getOrCreateChannel'; import { useMockedApis } from '../../../mock-builders/api/useMockedApis'; import dispatchMessageNewEvent from '../../../mock-builders/event/messageNew'; -import dispatchMessageReadEvent from '../../../mock-builders/event/messageRead'; -import { generateChannelResponse } from '../../../mock-builders/generator/channel'; +import dispatchNotificationMarkRead from '../../../mock-builders/event/notificationMarkRead'; +import dispatchNotificationMarkUnread from '../../../mock-builders/event/notificationMarkUnread'; +import { generateChannel, generateChannelResponse } from '../../../mock-builders/generator/channel'; import { generateMessage } from '../../../mock-builders/generator/message'; import { generateUser } from '../../../mock-builders/generator/user'; import { getTestClientWithUser } from '../../../mock-builders/mock'; @@ -68,6 +69,15 @@ describe('ChannelPreview', () => { ); }; + const generateChannelWrapper = (overrides: Record) => + generateChannel({ + countUnread: jest.fn().mockReturnValue(0), + initialized: true, + lastMessage: jest.fn().mockReturnValue(generateMessage()), + muteStatus: jest.fn().mockReturnValue({ muted: false }), + ...overrides, + }); + const useInitializeChannel = async (c: GetOrCreateChannelApiParams) => { useMockedApis(chatClient, [getOrCreateChannelApi(c)]); @@ -84,22 +94,228 @@ describe('ChannelPreview', () => { channel = null; }); - it('should mark channel as read, when message.read event is received for current user', async () => { - const c = generateChannelResponse(); - await useInitializeChannel(c); + describe('notification.mark_read event', () => { + it("should not update the unread count if the event's cid does not match the channel's cid", async () => { + const channelOnMock = jest.fn().mockReturnValue({ unsubscribe: jest.fn() }); - if (channel !== null) { - channel.countUnread = () => 20; - } + const c = generateChannelWrapper({ + countUnread: jest.fn().mockReturnValue(10), + on: channelOnMock, + }); + + channel = c as unknown as Channel; + + const { getByTestId } = render(); + + await waitFor(() => getByTestId('channel-id')); + + await waitFor(() => { + expect(getByTestId('unread-count')).toHaveTextContent('10'); + }); + + act(() => { + dispatchNotificationMarkRead(chatClient, { cid: 'channel-id' }); + }); + + await waitFor(() => { + expect(getByTestId('unread-count')).toHaveTextContent('10'); + }); + }); + + it('should update the unread count to 0', async () => { + const channelOnMock = jest.fn().mockReturnValue({ unsubscribe: jest.fn() }); + + const c = generateChannelWrapper({ + countUnread: jest.fn().mockReturnValue(10), + on: channelOnMock, + }); + + channel = c as unknown as Channel; + + const { getByTestId } = render(); + + await waitFor(() => getByTestId('channel-id')); + + await waitFor(() => { + expect(getByTestId('unread-count')).toHaveTextContent('10'); + }); + + act(() => { + dispatchNotificationMarkRead(chatClient, channel || {}); + }); + + await waitFor(() => { + expect(getByTestId('unread-count')).toHaveTextContent('0'); + }); + }); + }); + + describe('notification.mark_unread event', () => { + it("should not update the unread count if the event's cid is undefined", async () => { + const channelOnMock = jest.fn().mockReturnValue({ unsubscribe: jest.fn() }); + + const c = generateChannelWrapper({ + on: channelOnMock, + }); + + channel = c as unknown as Channel; + + const { getByTestId } = render(); + + await waitFor(() => getByTestId('channel-id')); + + await waitFor(() => { + expect(getByTestId('unread-count')).toHaveTextContent('0'); + }); + + act(() => { + dispatchNotificationMarkUnread( + chatClient, + {}, + { + unread_channels: 2, + unread_messages: 5, + }, + ); + }); + + await waitFor(() => { + expect(getByTestId('unread-count')).toHaveTextContent('0'); + }); + }); + + it("should not update the unread count if the event's cid does not match the channel's cid", async () => { + const channelOnMock = jest.fn().mockReturnValue({ unsubscribe: jest.fn() }); + + const c = generateChannelWrapper({ + on: channelOnMock, + }); + + channel = c as unknown as Channel; + + const { getByTestId } = render(); + + await waitFor(() => getByTestId('channel-id')); + + await waitFor(() => { + expect(getByTestId('unread-count')).toHaveTextContent('0'); + }); + + act(() => { + dispatchNotificationMarkUnread( + chatClient, + { cid: 'channel-id' }, + { + unread_channels: 2, + unread_messages: 5, + }, + ); + }); + + await waitFor(() => { + expect(getByTestId('unread-count')).toHaveTextContent('0'); + }); + }); + + it("should not update the unread count if the event's user id does not match the client's user id", async () => { + const channelOnMock = jest.fn().mockReturnValue({ unsubscribe: jest.fn() }); + + const c = generateChannelWrapper({ + on: channelOnMock, + }); + + channel = c as unknown as Channel; + + const { getByTestId } = render(); + + await waitFor(() => getByTestId('channel-id')); + + await waitFor(() => { + expect(getByTestId('unread-count')).toHaveTextContent('0'); + }); + + act(() => { + dispatchNotificationMarkUnread( + chatClient, + { cid: channel?.cid }, + { + unread_channels: 2, + unread_messages: 5, + user: { id: 'random-id' }, + }, + ); + }); + + await waitFor(() => { + expect(getByTestId('unread-count')).toHaveTextContent('0'); + }); + }); + + it("should update the unread count if the event's user id matches the client's user id", async () => { + const c = generateChannelResponse(); + await useInitializeChannel(c); + const channelOnMock = jest.fn().mockReturnValue({ unsubscribe: jest.fn() }); + + const testChannel = generateChannelWrapper({ + ...channel, + on: channelOnMock, + }); + + const { getByTestId } = render(); + + await waitFor(() => getByTestId('channel-id')); + + await waitFor(() => { + expect(getByTestId('unread-count')).toHaveTextContent('0'); + }); + + act(() => { + dispatchNotificationMarkUnread( + chatClient, + { cid: testChannel?.cid }, + { + unread_channels: 2, + unread_messages: 5, + user: { id: clientUser.id }, + }, + ); + }); + + await waitFor(() => { + expect(getByTestId('unread-count')).toHaveTextContent('5'); + }); + }); + }); + + it('should update the unread count to 0 if the channel is muted', async () => { + const channelOnMock = jest.fn().mockReturnValue({ unsubscribe: jest.fn() }); + + const c = generateChannelWrapper({ + countUnread: jest.fn().mockReturnValue(10), + muteStatus: jest.fn().mockReturnValue({ muted: true }), + on: channelOnMock, + }); + + channel = c as unknown as Channel; const { getByTestId } = render(); await waitFor(() => getByTestId('channel-id')); - expect(getByTestId('unread-count')).toHaveTextContent('20'); + await waitFor(() => { + expect(getByTestId('unread-count')).toHaveTextContent('0'); + }); act(() => { - dispatchMessageReadEvent(chatClient, clientUser, channel || {}); + dispatchNotificationMarkUnread( + chatClient, + { cid: channel?.cid }, + { + unread_channels: 2, + unread_messages: 5, + user: { id: clientUser.id }, + }, + ); }); await waitFor(() => { diff --git a/package/src/components/ChannelPreview/hooks/__tests__/useChannelPreviewDisplayName.test.tsx b/package/src/components/ChannelPreview/hooks/__tests__/useChannelPreviewDisplayName.test.tsx index fb341a4bd..786535536 100644 --- a/package/src/components/ChannelPreview/hooks/__tests__/useChannelPreviewDisplayName.test.tsx +++ b/package/src/components/ChannelPreview/hooks/__tests__/useChannelPreviewDisplayName.test.tsx @@ -3,7 +3,6 @@ import { Text } from 'react-native'; import { render, screen, waitFor } from '@testing-library/react-native'; -import type { DefaultStreamChatGenerics } from 'src/types/types'; import type { Channel, ChannelMemberResponse, DefaultGenerics, StreamChat } from 'stream-chat'; import { @@ -13,6 +12,7 @@ import { } from '../../../../mock-builders/api/queryMembers'; import { generateUser } from '../../../../mock-builders/generator/user'; import { getTestClientWithUser } from '../../../../mock-builders/mock'; +import type { DefaultStreamChatGenerics } from '../../../../types/types'; import { getChannelPreviewDisplayName, useChannelPreviewDisplayName, diff --git a/package/src/components/ChannelPreview/hooks/__tests__/useChannelPreviewMuted.test.tsx b/package/src/components/ChannelPreview/hooks/__tests__/useChannelPreviewMuted.test.tsx new file mode 100644 index 000000000..1d52486f2 --- /dev/null +++ b/package/src/components/ChannelPreview/hooks/__tests__/useChannelPreviewMuted.test.tsx @@ -0,0 +1,62 @@ +import { act, renderHook, waitFor } from '@testing-library/react-native'; +import { Channel, DefaultGenerics, StreamChat } from 'stream-chat'; + +import * as ChatContext from '../../../../contexts/chatContext/ChatContext'; +import dispatchNotificationChannelMutesUpdated from '../../../../mock-builders/event/notificationChannelMutesUpdated'; +import { generateUser } from '../../../../mock-builders/generator/user'; +import { getTestClientWithUser } from '../../../../mock-builders/mock'; +import { DefaultStreamChatGenerics } from '../../../../types/types'; +import { useIsChannelMuted } from '../useIsChannelMuted'; + +describe('useChannelPreviewMuted', () => { + const clientUser = generateUser(); + let chatClient: StreamChat | StreamChat; + + beforeEach(async () => { + chatClient = await getTestClientWithUser(clientUser); + jest.spyOn(ChatContext, 'useChatContext').mockImplementation( + jest.fn( + () => + ({ + client: chatClient, + } as unknown as ChatContext.ChatContextValue), + ), + ); + }); + + afterEach(() => { + jest.clearAllMocks(); + }); + + const mockChannel = { + initialized: true, + muteStatus: jest.fn().mockReturnValue({ + createdAt: Date.now(), + expiresAt: Date.now() + 5000, + muted: false, + }), + } as unknown as Channel; + + it('should return the correct mute status', () => { + const { result } = renderHook(() => useIsChannelMuted(mockChannel)); + expect(result.current.muted).toBe(false); + }); + + it("should update the mute status when the notification.channel_mutes_updated event is emitted'", () => { + renderHook(() => useIsChannelMuted(mockChannel)); + + act(() => dispatchNotificationChannelMutesUpdated(chatClient, mockChannel)); + + expect(mockChannel.muteStatus).toHaveBeenCalledTimes(2); + }); + + it('should clean up the event listener when the component is unmounted', async () => { + const { unmount } = renderHook(() => useIsChannelMuted(mockChannel)); + + unmount(); + + await waitFor(() => { + expect(mockChannel.muteStatus).toHaveBeenCalledTimes(1); + }); + }); +}); diff --git a/package/src/components/ChannelPreview/hooks/useChannelPreviewData.ts b/package/src/components/ChannelPreview/hooks/useChannelPreviewData.ts new file mode 100644 index 000000000..a678e7042 --- /dev/null +++ b/package/src/components/ChannelPreview/hooks/useChannelPreviewData.ts @@ -0,0 +1,138 @@ +import { useEffect, useMemo, useState } from 'react'; + +import throttle from 'lodash/throttle'; +import type { Channel, ChannelState, Event, MessageResponse, StreamChat } from 'stream-chat'; + +import { useIsChannelMuted } from './useIsChannelMuted'; + +import { useLatestMessagePreview } from './useLatestMessagePreview'; + +import { useChannelsContext } from '../../../contexts'; +import type { DefaultStreamChatGenerics } from '../../../types/types'; + +export const useChannelPreviewData = < + StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics, +>( + channel: Channel, + client: StreamChat, + forceUpdateOverride?: number, +) => { + const [forceUpdate, setForceUpdate] = useState(0); + const [lastMessage, setLastMessage] = useState< + | ReturnType['formatMessage']> + | MessageResponse + >(channel.state.messages[channel.state.messages.length - 1]); + const [unread, setUnread] = useState(channel.countUnread()); + const { muted } = useIsChannelMuted(channel); + const { forceUpdate: contextForceUpdate } = useChannelsContext(); + const channelListForceUpdate = forceUpdateOverride ?? contextForceUpdate; + + const channelLastMessage = channel.lastMessage(); + const channelLastMessageString = `${channelLastMessage?.id}${channelLastMessage?.updated_at}`; + + useEffect(() => { + const { unsubscribe } = client.on('notification.mark_read', () => { + setUnread(channel.countUnread()); + }); + return unsubscribe; + }, [channel, client]); + + useEffect(() => { + if ( + channelLastMessage && + (channelLastMessage.id !== lastMessage?.id || + channelLastMessage.updated_at !== lastMessage?.updated_at) + ) { + setLastMessage(channelLastMessage); + } + const newUnreadCount = channel.countUnread(); + setUnread(newUnreadCount); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [channel, channelLastMessageString, channelListForceUpdate]); + + /** + * This effect listens for the `notification.mark_read` event and sets the unread count to 0 + */ + useEffect(() => { + const handleReadEvent = (event: Event) => { + if (!event.cid) return; + if (channel.cid !== event.cid) return; + if (event?.user?.id === client.userID) { + setUnread(0); + } else if (event?.user?.id) { + setForceUpdate((prev) => prev + 1); + } + }; + const { unsubscribe } = client.on('message.read', handleReadEvent); + return unsubscribe; + }, [client, channel]); + + /** + * This effect listens for the `notification.mark_unread` event and updates the unread count + */ + useEffect(() => { + const handleUnreadEvent = (event: Event) => { + if (!event.cid) return; + if (channel.cid !== event.cid) return; + if (event.user?.id !== client.user?.id) return; + setUnread(channel.countUnread()); + }; + const { unsubscribe } = client.on('notification.mark_unread', handleUnreadEvent); + return unsubscribe; + }, [client, channel]); + + const refreshUnreadCount = useMemo( + () => + throttle(() => { + if (muted) { + setUnread(0); + } else { + setUnread(channel.countUnread()); + } + }, 400), + [channel, muted], + ); + + /** + * This effect listens for the `message.new`, `message.updated`, `message.deleted`, `message.undeleted`, and `channel.truncated` events + */ + useEffect(() => { + refreshUnreadCount(); + + const handleEvent = () => { + setLastMessage(channel.state.latestMessages[channel.state.latestMessages.length - 1]); + refreshUnreadCount(); + }; + + const handleNewMessageEvent = (event: Event) => { + const message = event.message; + if (message && (!message.parent_id || message.show_in_channel)) { + setLastMessage(message); + setUnread(channel.countUnread()); + } + }; + + const handleUpdatedOrDeletedMessage = (event: Event) => { + setLastMessage((prevLastMessage) => { + if (prevLastMessage?.id === event.message?.id) { + return event.message; + } + return prevLastMessage; + }); + }; + + const listeners = [ + channel.on('message.new', handleNewMessageEvent), + channel.on('message.updated', handleUpdatedOrDeletedMessage), + channel.on('message.deleted', handleUpdatedOrDeletedMessage), + channel.on('message.undeleted', handleEvent), + channel.on('channel.truncated', handleEvent), + ]; + + return () => listeners.forEach((l) => l.unsubscribe()); + }, [channel, refreshUnreadCount, forceUpdate, channelListForceUpdate]); + + const latestMessagePreview = useLatestMessagePreview(channel, forceUpdate, lastMessage); + + return { latestMessagePreview, muted, unread }; +}; diff --git a/package/src/components/ChannelPreview/hooks/useIsChannelMuted.ts b/package/src/components/ChannelPreview/hooks/useIsChannelMuted.ts new file mode 100644 index 000000000..580bd0c41 --- /dev/null +++ b/package/src/components/ChannelPreview/hooks/useIsChannelMuted.ts @@ -0,0 +1,29 @@ +import { useEffect, useState } from 'react'; + +import type { Channel } from 'stream-chat'; + +import { useChatContext } from '../../../contexts/chatContext/ChatContext'; + +import type { DefaultStreamChatGenerics } from '../../../types/types'; + +export const useIsChannelMuted = < + StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics, +>( + channel: Channel, +) => { + const { client } = useChatContext(); + const initialized = channel?.initialized; + + const [muted, setMuted] = useState(() => initialized && channel.muteStatus()); + + useEffect(() => { + const handleEvent = () => { + setMuted(initialized && channel.muteStatus()); + }; + + client.on('notification.channel_mutes_updated', handleEvent); + return () => client.off('notification.channel_mutes_updated', handleEvent); + }, [channel, client, initialized, muted]); + + return muted || { createdAt: null, expiresAt: null, muted: false }; +}; diff --git a/package/src/components/Chat/hooks/useIsOnline.ts b/package/src/components/Chat/hooks/useIsOnline.ts index a9c60b5c1..44db843fe 100644 --- a/package/src/components/Chat/hooks/useIsOnline.ts +++ b/package/src/components/Chat/hooks/useIsOnline.ts @@ -29,11 +29,6 @@ export const useIsOnline = < const onBackground = useCallback(() => { if (!closeConnectionOnBackground || !clientExists) return; - for (const cid in client.activeChannels) { - const channel = client.activeChannels[cid]; - channel?.state.setIsUpToDate(false); - } - client.closeConnection(); setIsOnline(false); }, [closeConnectionOnBackground, client, clientExists]); diff --git a/package/src/components/Message/MessageSimple/utils/generateMarkdownText.ts b/package/src/components/Message/MessageSimple/utils/generateMarkdownText.ts index 2851be137..4e116cc4f 100644 --- a/package/src/components/Message/MessageSimple/utils/generateMarkdownText.ts +++ b/package/src/components/Message/MessageSimple/utils/generateMarkdownText.ts @@ -35,5 +35,11 @@ export const generateMarkdownText = (text?: string) => { resultText = resultText.replace(/[<"'>]/g, '\\$&'); + // Remove whitespaces that come directly after newlines except in code blocks where we deem this allowed. + resultText = resultText.replace(/(```[\s\S]*?```|`.*?`)|\n[ ]{2,}/g, (_, code) => { + if (code) return code; + return '\n'; + }); + return resultText; }; diff --git a/package/src/components/MessageInput/MessageInput.tsx b/package/src/components/MessageInput/MessageInput.tsx index 087ac1a7c..15e394cee 100644 --- a/package/src/components/MessageInput/MessageInput.tsx +++ b/package/src/components/MessageInput/MessageInput.tsx @@ -894,21 +894,23 @@ const MessageInputWithContext = < )} {showPollCreationDialog ? ( - - - - - - - + + + + + + + + + ) : null} ); diff --git a/package/src/components/MessageList/MessageList.tsx b/package/src/components/MessageList/MessageList.tsx index e0cd15e34..e2c0ecde5 100644 --- a/package/src/components/MessageList/MessageList.tsx +++ b/package/src/components/MessageList/MessageList.tsx @@ -862,9 +862,7 @@ const MessageListWithContext = < const goToNewMessages = async () => { const isNotLatestSet = channel.state.messages !== channel.state.latestMessages; - if (isNotLatestSet && hasNoMoreRecentMessagesToLoad) { - loadChannelAroundMessage({}); - } else if (!hasNoMoreRecentMessagesToLoad) { + if (isNotLatestSet) { resetPaginationTrackersRef.current(); await reloadChannel(); } else if (flatListRef.current) { diff --git a/package/src/components/ThreadList/ThreadList.tsx b/package/src/components/ThreadList/ThreadList.tsx index 003b054ff..952cc31c3 100644 --- a/package/src/components/ThreadList/ThreadList.tsx +++ b/package/src/components/ThreadList/ThreadList.tsx @@ -103,8 +103,6 @@ export const ThreadList = (props: ThreadListProps) => { client.threads.reload({ force: true }); }); - client.threads.reload({ force: true }); - return () => { client.threads.deactivate(); listener.unsubscribe(); diff --git a/package/src/components/index.ts b/package/src/components/index.ts index c2fa0e8d9..79fd95691 100644 --- a/package/src/components/index.ts +++ b/package/src/components/index.ts @@ -67,6 +67,8 @@ export * from './ChannelPreview/hooks/useChannelPreviewDisplayAvatar'; export * from './ChannelPreview/hooks/useChannelPreviewDisplayName'; export * from './ChannelPreview/hooks/useChannelPreviewDisplayPresence'; export * from './ChannelPreview/hooks/useLatestMessagePreview'; +export * from './ChannelPreview/hooks/useChannelPreviewData'; +export * from './ChannelPreview/hooks/useIsChannelMuted'; export * from './Chat/Chat'; export * from './Chat/hooks/useCreateChatClient'; diff --git a/package/src/mock-builders/event/notificationChannelMutesUpdated.js b/package/src/mock-builders/event/notificationChannelMutesUpdated.js new file mode 100644 index 000000000..360009268 --- /dev/null +++ b/package/src/mock-builders/event/notificationChannelMutesUpdated.js @@ -0,0 +1,7 @@ +export default (client, channel = {}) => { + client.dispatchEvent({ + channel, + cid: channel.cid, + type: 'notification.channel_mutes_updated', + }); +}; diff --git a/package/src/mock-builders/event/notificationMarkRead.js b/package/src/mock-builders/event/notificationMarkRead.js new file mode 100644 index 000000000..8978706f8 --- /dev/null +++ b/package/src/mock-builders/event/notificationMarkRead.js @@ -0,0 +1,7 @@ +export default (client, channel = {}) => { + client.dispatchEvent({ + channel, + cid: channel.cid, + type: 'notification.mark_read', + }); +}; diff --git a/package/src/mock-builders/event/notificationMarkUnread.js b/package/src/mock-builders/event/notificationMarkUnread.js new file mode 100644 index 000000000..862802cf1 --- /dev/null +++ b/package/src/mock-builders/event/notificationMarkUnread.js @@ -0,0 +1,9 @@ +export default (client, channel = {}, payload = {}, user = {}) => { + client.dispatchEvent({ + channel, + cid: channel.cid, + type: 'notification.mark_unread', + user, + ...payload, + }); +}; diff --git a/package/src/mock-builders/generator/channel.ts b/package/src/mock-builders/generator/channel.ts index d86a2b763..8fde5071f 100644 --- a/package/src/mock-builders/generator/channel.ts +++ b/package/src/mock-builders/generator/channel.ts @@ -58,6 +58,7 @@ const getChannelDefaults = ( { id, type }: { [key: string]: any } = { id: uuidv4(), type: 'messaging' }, ) => ({ _client: {}, + cid: `${type}:${id}`, data: { cid: `${type}:${id}`, config: { diff --git a/package/src/types/types.ts b/package/src/types/types.ts index 2aba21d59..d5a761784 100644 --- a/package/src/types/types.ts +++ b/package/src/types/types.ts @@ -89,6 +89,7 @@ export interface DefaultStreamChatGenerics extends ExtendableGenerics { channelType: DefaultChannelType; commandType: LiteralStringForUnion; eventType: UnknownType; + memberType: UnknownType; messageType: UnknownType; reactionType: UnknownType; userType: DefaultUserType; diff --git a/package/src/utils/utils.ts b/package/src/utils/utils.ts index 3cffd7600..009ba2585 100644 --- a/package/src/utils/utils.ts +++ b/package/src/utils/utils.ts @@ -94,7 +94,10 @@ export const isBouncedMessage = < StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics, >( message: MessageType, -) => message.type === 'error' && message.moderation_details !== undefined; +) => + (message.type === 'error' && + message?.moderation_details?.action === 'MESSAGE_RESPONSE_ACTION_BOUNCE') || + message?.moderation?.action === 'bounce'; /** * Utility to check if the message is a edited message. diff --git a/package/src/version.json b/package/src/version.json index 8be309d7f..7825e6c06 100644 --- a/package/src/version.json +++ b/package/src/version.json @@ -1,3 +1,3 @@ { - "version": "5.41.4" + "version": "5.43.1" } diff --git a/package/yarn.lock b/package/yarn.lock index 5f6be67e3..9f103b8b1 100644 --- a/package/yarn.lock +++ b/package/yarn.lock @@ -9311,10 +9311,10 @@ statuses@~1.5.0: resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" integrity sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA== -stream-chat@8.42.0: - version "8.42.0" - resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-8.42.0.tgz#124ea2c10c6e8f7990304e1101c66751daf63e6c" - integrity sha512-8xZz+fmdHSOa3L1rHUOC4Wah+ipvLvdiOmeOfGK6uXnLOKlSHMOblwmQErrOoFM4SKfX9Bea3V8viaKUu6bPng== +stream-chat@8.45.1: + version "8.45.1" + resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-8.45.1.tgz#001f452520602ebffe45f1634b5f5dd1ff036ec5" + integrity sha512-7OMpL2RHUd+PXSWzhTUAIjjXlI9Oqc4HhUBRfc5i6dK+Ug9S5ertb7RvyzGL5N4ITpq/6ZUAwXtTqRaN9+UUkw== dependencies: "@babel/runtime" "^7.16.3" "@types/jsonwebtoken" "~9.0.0"