From 58753d74976cd928a1a7c016ab5a4220a45506da Mon Sep 17 00:00:00 2001 From: Tommaso Barbugli Date: Tue, 1 Dec 2026 09:51:00 +0100 Subject: [PATCH 1/5] ci: migrate macOS workflows to scaleway-macos runner group (#4028) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary Migrate macOS workflow jobs to the org self-hosted `scaleway-macos` runner group. With the `GetStream` organization IP allow list enabled ([SEC-2475](https://linear.app/stream/issue/SEC-2475/github-hardening)), standard dynamic-IP GitHub-hosted macOS runners (`macos-*`, `xcode-*`) are blocked from authenticated GitHub API and git access (`GITHUB_TOKEN`). The `scaleway-macos` pool runs ephemeral Tart macOS VMs (`ghcr.io/getstream/runner-macos:latest`) on Scaleway Apple Silicon hosts behind a single allow-listed static NAT IP (`51.15.135.209`). This repository has already been granted access to the `scaleway-macos` runner group. ### Updated workflows (4 file(s), 4 `runs-on` update(s)) - `.github/workflows/build-ios-spm.yml` (1 `runs-on` update(s)) - `.github/workflows/e2e-test-cron.yml` (1 `runs-on` update(s)) - `.github/workflows/e2e-test.yml` (1 `runs-on` update(s)) - `.github/workflows/sample-distribution.yml` (1 `runs-on` update(s)) ### Notes > **Xcode 27 note:** `.github/workflows/e2e-test-cron.yml` and `sample-distribution.yml` pin `xcode-version: '27.2'` (previously `xcode-27`). The current `ghcr.io/getstream/runner-macos:latest` image ships Xcode `16.0`โ€“`26.3`; add Xcode 27 to the runner image before merging jobs that require Xcode 27. --- .github/workflows/build-ios-spm.yml | 2 +- .github/workflows/e2e-test-cron.yml | 2 +- .github/workflows/e2e-test.yml | 2 +- .github/workflows/sample-distribution.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-ios-spm.yml b/.github/workflows/build-ios-spm.yml index 33b2598154..f7d7d0a0c3 100644 --- a/.github/workflows/build-ios-spm.yml +++ b/.github/workflows/build-ios-spm.yml @@ -28,7 +28,7 @@ permissions: jobs: build_ios_spm: name: Build SampleApp iOS (Swift Package Manager) - runs-on: [macos-15] + runs-on: { group: scaleway-macos } env: STREAM_CHAT_SPM_ONLY: '1' # `pod deintegrate`, run by `react-native spm add --deintegrate`, needs a UTF-8 locale. diff --git a/.github/workflows/e2e-test-cron.yml b/.github/workflows/e2e-test-cron.yml index 5902d3ee9f..3cae59cb48 100644 --- a/.github/workflows/e2e-test-cron.yml +++ b/.github/workflows/e2e-test-cron.yml @@ -45,7 +45,7 @@ jobs: ios: name: Test iOS ${{ matrix.ios }} if: (github.event_name == 'schedule' || inputs.ios) && (inputs.mock_server_branch || 'main') == 'main' - runs-on: xcode-27 + runs-on: { group: scaleway-macos } timeout-minutes: 360 strategy: fail-fast: false diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml index 0e17ce4349..d46c72f325 100644 --- a/.github/workflows/e2e-test.yml +++ b/.github/workflows/e2e-test.yml @@ -74,7 +74,7 @@ jobs: ios: needs: check if: needs.check.outputs.required == 'true' && github.event_name == 'workflow_dispatch' && inputs.ios - runs-on: macos-15 + runs-on: { group: scaleway-macos } timeout-minutes: 60 env: DETOX_IOS_DEVICE: "iPhone 17 Pro" diff --git a/.github/workflows/sample-distribution.yml b/.github/workflows/sample-distribution.yml index 1c77170fce..1320739a87 100644 --- a/.github/workflows/sample-distribution.yml +++ b/.github/workflows/sample-distribution.yml @@ -29,7 +29,7 @@ env: jobs: build_and_deploy_ios_testflight_qa: name: Build SampleApp iOS and Deploy-${{ github.ref_name == 'develop' || github.ref_name == vars.RC_BRANCH }} - runs-on: [xcode-27] + runs-on: { group: scaleway-macos } strategy: matrix: node-version: [24.x] From c34758019d12ae5808f2fd0f14cac49c8b2f784f Mon Sep 17 00:00:00 2001 From: Ivan Sekovanikj <31964049+isekovanic@users.noreply.github.com> Date: Wed, 2 Dec 2026 10:11:50 +0100 Subject: [PATCH 2/5] feat: allow overriding layout transitions through WithAnimations (#4036) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ticket: https://linear.app/stream/issue/RN-547 Fixes #4030. ## ๐ŸŽฏ Goal This PR lets integrators override or turn off the SDK's layout transitions. The composer, the suggestion list and the scroll to bottom button animate their layout with a `200ms` transition. While this works well in general, when a keyboard view moves them on every frame (like the `KeyboardAvoidingView` from `react-native-keyboard-controller`), the transition restarts on every frame and they trail behind the keyboard. Until now there was no way to turn these off. ## ๐Ÿ›  Implementation details - A new `AnimationsContext` holds the SDK's animations, starting with `transitions`. `WithAnimations` overrides them for the tree below it, the same way `WithComponents` does. Nested providers merge, the closest one wins and `overrides` is read once at mount. - Without a provider every component gets the defaults, which are the exact transitions used today. Nothing changes for existing apps. - Transitions are keyed by use case: `messageList`, `scrollToBottomButton`, `suggestionList`, `suggestionListContent`, `composer`, `composerContent`, `attachmentUploadPreviews`, `notificationList`, `pollComposer` and `pollComposerOption`. Each one has a `layout` field for now, which leaves room for `entering` and `exiting` later. - `null` turns a transition off. A missing key or `undefined` keeps the parent's value, so an override is always explicit. `noTransitions` turns everything off. - All 28 layout transitions in core read from the context. `MessageList` renders a plain `FlatList` when `messageList` is turned off, same as `animateLayout={false}`. - Unknown keys in `overrides` are a type error, also when the overrides are not an inline object. The override types are derived from the `Animations` shape, so a new field or namespace needs no extra types. - The merge lives in `utils/mergeOverrides.ts`. It only walks plain objects, so Reanimated builders are kept by reference and arrays are replaced. Providers that pass the same `overrides` object share one merged value. ```tsx const animationOverrides = { transitions: { composer: { layout: null }, messageList: { layout: null }, scrollToBottomButton: { layout: null }, suggestionList: { layout: null }, }, } satisfies AnimationOverrides; ``` Docs: https://github.com/GetStream/getstream.io/pull/1303 ## ๐Ÿงช Testing - Unit tests cover the merge, the context, the type errors for unknown keys and the `NotificationList` wiring. - On an iOS simulator the composer still animates when it grows and snaps in a single frame with `noTransitions`. --- .../AutoCompleteInput/AutoCompleteInput.tsx | 6 +- .../AutoCompleteSuggestionList.tsx | 6 +- .../components/MessageInput/CommandChip.tsx | 6 +- .../MessageInput/MessageComposer.tsx | 9 +- .../MessageComposerLeadingView.tsx | 5 +- .../MessageInput/MessageInputHeaderView.tsx | 4 +- .../MessageInput/MessageInputTrailingView.tsx | 5 +- .../ShowThreadMessageInChannelButton.tsx | 6 +- .../AttachmentUploadPreviewList.tsx | 34 ++-- .../AudioRecordingLockIndicator.tsx | 6 +- .../components/LinkPreviewList.tsx | 6 +- .../MessageList/MessageFlashList.tsx | 7 +- .../components/MessageList/MessageList.tsx | 13 +- .../Notifications/NotificationList.tsx | 4 +- .../__tests__/NotificationList.test.tsx | 33 ++++ .../src/components/Poll/CreatePollContent.tsx | 8 +- .../Poll/components/CreatePollOptions.tsx | 16 +- .../Poll/components/MultipleAnswersField.tsx | 6 +- .../Poll/components/MultipleVotesSettings.tsx | 6 +- .../Poll/components/PollInputDialog.tsx | 6 +- .../animationsContext/AnimationsContext.tsx | 141 +++++++++++++++ .../__tests__/AnimationsContext.test.tsx | 166 ++++++++++++++++++ package/src/contexts/index.ts | 1 + package/src/types/types.ts | 34 ++++ .../utils/__tests__/mergeOverrides.test.ts | 66 +++++++ package/src/utils/animations/transitions.ts | 1 + package/src/utils/mergeOverrides.ts | 37 ++++ 27 files changed, 578 insertions(+), 60 deletions(-) create mode 100644 package/src/contexts/animationsContext/AnimationsContext.tsx create mode 100644 package/src/contexts/animationsContext/__tests__/AnimationsContext.test.tsx create mode 100644 package/src/utils/__tests__/mergeOverrides.test.ts create mode 100644 package/src/utils/mergeOverrides.ts diff --git a/package/src/components/AutoCompleteInput/AutoCompleteInput.tsx b/package/src/components/AutoCompleteInput/AutoCompleteInput.tsx index 21cb099457..3922fce66e 100644 --- a/package/src/components/AutoCompleteInput/AutoCompleteInput.tsx +++ b/package/src/components/AutoCompleteInput/AutoCompleteInput.tsx @@ -8,10 +8,11 @@ import { TextInputSelectionChangeEvent, } from 'react-native'; -import Animated, { LinearTransition } from 'react-native-reanimated'; +import Animated from 'react-native-reanimated'; import { MessageComposerConfig, TextComposerState } from 'stream-chat'; +import { useAnimationsContext } from '../../contexts/animationsContext/AnimationsContext'; import { ChannelContextValue, useChannelContext, @@ -92,6 +93,7 @@ const commandPlaceHolders: Record = { }; const AutoCompleteInputWithContext = (props: AutoCompleteInputPropsWithContext) => { + const animations = useAnimationsContext(); const styles = useStyles(); const { // Unused: destructured only to keep the channel out of `...rest`, which is spread onto the @@ -238,7 +240,7 @@ const AutoCompleteInputWithContext = (props: AutoCompleteInputPropsWithContext) return ( ({ }); export const AutoCompleteSuggestionList = () => { + const animations = useAnimationsContext(); const { AutoCompleteSuggestionHeader, AutoCompleteSuggestionItem } = useComponentsContext(); const messageComposer = useMessageComposer(); @@ -96,7 +98,7 @@ export const AutoCompleteSuggestionList = () => { accessibilityRole='menu' entering={ZoomIn.duration(200)} exiting={ZoomOut.duration(200)} - layout={LinearTransition.duration(200)} + layout={animations.transitions.suggestionListContent.layout} style={styles.container} > { + const animations = useAnimationsContext(); const messageComposer = useMessageComposer(); const { textComposer, attachmentManager } = messageComposer; const { command } = useStateStore(textComposer.state, textComposerStateSelector); @@ -25,7 +27,7 @@ export const CommandChip = () => { diff --git a/package/src/components/MessageInput/MessageComposer.tsx b/package/src/components/MessageInput/MessageComposer.tsx index 2bb0ad7eac..6eab422d9f 100644 --- a/package/src/components/MessageInput/MessageComposer.tsx +++ b/package/src/components/MessageInput/MessageComposer.tsx @@ -24,6 +24,7 @@ import { audioRecorderSelector } from './utils/audioRecorderSelectors'; import { useScreenReaderMountFocus } from '../../a11y'; import { useAttachmentPickerContext, useOwnCapabilitiesContext } from '../../contexts'; +import { useAnimationsContext } from '../../contexts/animationsContext/AnimationsContext'; import { ChannelContextValue, useChannelContext, @@ -51,7 +52,6 @@ import { useStateStore } from '../../hooks/useStateStore'; import { AudioRecorderManagerState } from '../../state-store/audio-recorder-manager'; import { MessageInputHeightState } from '../../state-store/message-input-height-store'; import { primitives } from '../../theme'; -import { transitions } from '../../utils/animations/transitions'; import { type TextInputOverrideComponent } from '../AutoCompleteInput/AutoCompleteInput'; import { useSettledWSConnectionHealth } from '../Chat/hooks/useWSConnectionState'; import { PollModal } from '../Poll/components/PollModal'; @@ -185,6 +185,7 @@ const capabilitiesKnownSelector = (state: ChannelDataState) => ({ }); const MessageComposerWithContext = (props: MessageComposerPropsWithContext) => { + const animations = useAnimationsContext(); const { additionalTextInputProps, asyncMessagesLockDistance, @@ -363,7 +364,7 @@ const MessageComposerWithContext = (props: MessageComposerPropsWithContext) => { ] : null } - layout={transitions.layout200} + layout={animations.transitions.composer.layout} > { { {!isRecordingStateIdle ? ( diff --git a/package/src/components/MessageInput/MessageComposerLeadingView.tsx b/package/src/components/MessageInput/MessageComposerLeadingView.tsx index 8b2a89c899..af46508069 100644 --- a/package/src/components/MessageInput/MessageComposerLeadingView.tsx +++ b/package/src/components/MessageInput/MessageComposerLeadingView.tsx @@ -6,12 +6,13 @@ import Animated from 'react-native-reanimated'; import { InputButtons } from './components/InputButtons'; import { idleRecordingStateSelector } from './utils/audioRecorderSelectors'; +import { useAnimationsContext } from '../../contexts/animationsContext/AnimationsContext'; import { useMessageInputContext } from '../../contexts/messageInputContext/MessageInputContext'; import { useTheme } from '../../contexts/themeContext/ThemeContext'; import { useStateStore } from '../../hooks/useStateStore'; -import { transitions } from '../../utils/animations/transitions'; export const MessageComposerLeadingView = () => { + const animations = useAnimationsContext(); const { theme: { messageComposer: { inputButtonsContainer }, @@ -25,7 +26,7 @@ export const MessageComposerLeadingView = () => { return isRecordingStateIdle ? ( { + const animations = useAnimationsContext(); const { theme: { messageComposer: { contentContainer }, @@ -43,7 +45,7 @@ export const MessageInputHeaderView = () => { return isRecordingStateIdle ? ( { + const animations = useAnimationsContext(); const { theme: { messageComposer: { outputButtonsContainer }, @@ -26,7 +27,7 @@ export const MessageInputTrailingView = () => { ); return (recordingStatus === 'idle' || recordingStatus === 'recording') && !micLocked ? ( diff --git a/package/src/components/MessageInput/ShowThreadMessageInChannelButton.tsx b/package/src/components/MessageInput/ShowThreadMessageInChannelButton.tsx index ace836f58a..b8be584e7b 100644 --- a/package/src/components/MessageInput/ShowThreadMessageInChannelButton.tsx +++ b/package/src/components/MessageInput/ShowThreadMessageInChannelButton.tsx @@ -1,10 +1,11 @@ import React, { useCallback, useMemo } from 'react'; import { Pressable, StyleSheet, Text, View } from 'react-native'; -import Animated, { LinearTransition } from 'react-native-reanimated'; +import Animated from 'react-native-reanimated'; import { MessageComposerState } from 'stream-chat'; +import { useAnimationsContext } from '../../contexts/animationsContext/AnimationsContext'; import { useComponentsContext } from '../../contexts/componentsContext/ComponentsContext'; import { useMessageComposer } from '../../contexts/messageInputContext/hooks/useMessageComposer'; import { useTheme } from '../../contexts/themeContext/ThemeContext'; @@ -29,6 +30,7 @@ export type ShowThreadMessageInChannelButtonWithContextProps = Pick< export const ShowThreadMessageInChannelButtonWithContext = ( props: ShowThreadMessageInChannelButtonWithContextProps, ) => { + const animations = useAnimationsContext(); const styles = useStyles(); const { icons } = useComponentsContext(); const { allowThreadMessagesInChannel, t, thread } = props; @@ -61,7 +63,7 @@ export const ShowThreadMessageInChannelButtonWithContext = ( return ( diff --git a/package/src/components/MessageInput/components/AttachmentPreview/AttachmentUploadPreviewList.tsx b/package/src/components/MessageInput/components/AttachmentPreview/AttachmentUploadPreviewList.tsx index e18da98eca..e4668bc8db 100644 --- a/package/src/components/MessageInput/components/AttachmentPreview/AttachmentUploadPreviewList.tsx +++ b/package/src/components/MessageInput/components/AttachmentPreview/AttachmentUploadPreviewList.tsx @@ -11,7 +11,7 @@ import { ViewStyle, } from 'react-native'; -import Animated, { LinearTransition, ZoomIn, ZoomOut } from 'react-native-reanimated'; +import Animated, { ZoomIn, ZoomOut } from 'react-native-reanimated'; import { isLocalAudioAttachment, @@ -26,6 +26,7 @@ import { } from 'stream-chat'; import { useMessageComposer } from '../../../../contexts'; +import { useAnimationsContext } from '../../../../contexts/animationsContext/AnimationsContext'; import { useComponentsContext } from '../../../../contexts/componentsContext/ComponentsContext'; import { useAttachmentManagerState } from '../../../../contexts/messageInputContext/hooks/useAttachmentManagerState'; import { useMessageInputContext } from '../../../../contexts/messageInputContext/MessageInputContext'; @@ -41,7 +42,6 @@ const TRAILING_SPACER_RELEASE_DELAY = ATTACHMENT_PREVIEW_ANIMATION_DURATION + 80 const MAX_AUDIO_ATTACHMENTS_CONTAINER_WIDTH = 560; const attachmentPreviewEntering = ZoomIn.duration(ATTACHMENT_PREVIEW_ANIMATION_DURATION); const attachmentPreviewExiting = ZoomOut.duration(ATTACHMENT_PREVIEW_ANIMATION_DURATION); -const attachmentPreviewLayout = LinearTransition.duration(ATTACHMENT_PREVIEW_ANIMATION_DURATION); export type AttachmentUploadListPreviewPropsWithContext = Record; @@ -53,17 +53,20 @@ const AttachmentPreviewCell = ({ children: React.ReactNode; onLayout?: (event: LayoutChangeEvent) => void; style?: StyleProp; -}) => ( - - {children} - -); +}) => { + const animations = useAnimationsContext(); + return ( + + {children} + + ); +}; const ItemSeparatorComponent = () => { const { @@ -85,6 +88,7 @@ const getIsAudioAttachmentPreview = (soundPackageAvailable && isLocalAudioAttachment(attachment)); const UnMemoizedAttachmentUploadPreviewList = () => { + const animations = useAnimationsContext(); const { AudioAttachmentUploadPreview, FileAttachmentUploadPreview, @@ -500,7 +504,7 @@ const UnMemoizedAttachmentUploadPreviewList = () => { {audioAttachments.map((attachment) => ( @@ -519,7 +523,7 @@ const UnMemoizedAttachmentUploadPreviewList = () => { { + const animations = useAnimationsContext(); const [visible, setVisible] = useState(true); const timeoutRef = useRef(undefined); const { icons } = useComponentsContext(); @@ -53,7 +55,7 @@ export const AudioRecordingLockIndicator = ({ return ( {micLocked ? ( diff --git a/package/src/components/MessageInput/components/LinkPreviewList.tsx b/package/src/components/MessageInput/components/LinkPreviewList.tsx index 3aef1afc93..f63ac5b938 100644 --- a/package/src/components/MessageInput/components/LinkPreviewList.tsx +++ b/package/src/components/MessageInput/components/LinkPreviewList.tsx @@ -2,7 +2,7 @@ import React, { useCallback, useMemo } from 'react'; import { View, Text, StyleSheet } from 'react-native'; -import Animated, { LinearTransition } from 'react-native-reanimated'; +import Animated from 'react-native-reanimated'; import type { LinkPreview } from 'stream-chat'; import { LinkPreviewsManager } from 'stream-chat'; @@ -10,6 +10,7 @@ import { LinkPreviewsManager } from 'stream-chat'; import { AttachmentRemoveControl } from './AttachmentPreview/AttachmentRemoveControl'; import { useMessageComposer, useTheme } from '../../../contexts'; +import { useAnimationsContext } from '../../../contexts/animationsContext/AnimationsContext'; import { useComponentsContext } from '../../../contexts/componentsContext/ComponentsContext'; import { components, primitives } from '../../../theme'; import { useLinkPreviews } from '../hooks/useLinkPreviews'; @@ -37,6 +38,7 @@ type LinkPreviewProps = { }; export const LinkPreviewCard = ({ linkPreview }: LinkPreviewProps) => { + const animations = useAnimationsContext(); const styles = useStyles(); const { icons, ImageComponent } = useComponentsContext(); const { linkPreviewsManager } = useMessageComposer(); @@ -56,7 +58,7 @@ export const LinkPreviewCard = ({ linkPreview }: LinkPreviewProps) => { return ( diff --git a/package/src/components/MessageList/MessageFlashList.tsx b/package/src/components/MessageList/MessageFlashList.tsx index d8587a0256..e0984a3622 100644 --- a/package/src/components/MessageList/MessageFlashList.tsx +++ b/package/src/components/MessageList/MessageFlashList.tsx @@ -23,6 +23,7 @@ import { InlineLoadingMoreIndicator } from './InlineLoadingMoreIndicator'; import { InlineLoadingMoreRecentIndicator } from './InlineLoadingMoreRecentIndicator'; import { getMessageListItemCacheKey } from './utils/buildMessageListWithNeighbours'; +import { useAnimationsContext } from '../../contexts/animationsContext/AnimationsContext'; import { AttachmentPickerContextValue, useAttachmentPickerContext, @@ -60,7 +61,6 @@ import { MessageInputHeightState } from '../../state-store/message-input-height- import { primitives } from '../../theme'; import type { ScrollViewRef, ViewabilityConfig, ViewToken } from '../../types/react-native-compat'; import { FileTypes } from '../../types/types'; -import { transitions } from '../../utils/animations/transitions'; import { MarkReadFunctionOptions } from '../Channel/Channel'; import { MessageWrapper } from '../Message/MessageItemView/MessageWrapper'; import { excludeCanceledUploadNotifications } from '../Notifications/notificationFilters'; @@ -274,6 +274,7 @@ const MessageFlashListWithContext = (props: MessageFlashListPropsWithContext) => TypingIndicatorContainer, UnreadMessagesNotification, } = useComponentsContext(); + const animations = useAnimationsContext(); const flashListRef = useRef | null>(null); const { height: messageInputHeight } = useStateStore( @@ -770,7 +771,7 @@ const MessageFlashListWithContext = (props: MessageFlashListPropsWithContext) => ) : null} ) : null} { UnreadMessagesNotification, AutoCompleteSuggestionList, } = useComponentsContext(); + const animations = useAnimationsContext(); const { theme } = useTheme(); const styles = useStyles(); const { height: messageInputHeight } = useStateStore( @@ -707,7 +708,8 @@ const MessageListWithContext = (props: MessageListPropsWithContext) => { ], ); - const ListComponent = animateLayout ? AnimatedList : FlatList; + const ListComponent = + animateLayout && animations.transitions.messageList.layout ? AnimatedList : FlatList; const viewportHeightRef = useRef(undefined); @@ -801,8 +803,7 @@ const MessageListWithContext = (props: MessageListPropsWithContext) => { ) : ( { {scrollToBottomButtonVisible ? ( { ) : null} { + const animations = useAnimationsContext(); const { Notification: NotificationComponent } = useComponentsContext(); const styles = useStyles({ bottomOffset, topOffset, verticalAlignment }); const { t } = useTranslationContext(); @@ -92,7 +94,7 @@ export const NotificationList = ({ diff --git a/package/src/components/Notifications/__tests__/NotificationList.test.tsx b/package/src/components/Notifications/__tests__/NotificationList.test.tsx index 33ececbf50..2be46299d1 100644 --- a/package/src/components/Notifications/__tests__/NotificationList.test.tsx +++ b/package/src/components/Notifications/__tests__/NotificationList.test.tsx @@ -5,6 +5,10 @@ import { Pressable, Text } from 'react-native'; import { act, fireEvent, render, screen, waitFor } from '@testing-library/react-native'; import { NotificationManager } from 'stream-chat'; +import { + noTransitions, + WithAnimations, +} from '../../../contexts/animationsContext/AnimationsContext'; import { ChannelProvider } from '../../../contexts/channelContext/ChannelContext'; import { ChatProvider } from '../../../contexts/chatContext/ChatContext'; import { @@ -17,6 +21,7 @@ import { TranslationProvider, } from '../../../contexts/translationContext/TranslationContext'; import type { TranslationContextValue } from '../../../contexts/translationContext/TranslationContext'; +import { transitions } from '../../../utils/animations/transitions'; import { useNotificationApi } from '../hooks/useNotificationApi'; import { NotificationList } from '../NotificationList'; import { NotificationTargetProvider } from '../NotificationTargetContext'; @@ -477,4 +482,32 @@ describe('NotificationList', () => { expect(screen.getAllByText('Action-scoped notice')).toHaveLength(1); expect(notification?.tags).toEqual(['target:channel:channel:messaging:first']); }); + + it.each([ + ['the default transition', undefined, transitions.layout200], + ['no transition when turned off', noTransitions, undefined], + ])('uses %s from the animations context', async (_, overrides, expectedLayout) => { + const manager = new NotificationManager(); + jest.spyOn(manager, 'startTimeout').mockImplementation(); + const Wrapper = createWrapper(manager); + + render(, { + wrapper: ({ children }: PropsWithChildren) => ( + + {overrides ? {children} : children} + + ), + }); + + act(() => { + manager.add({ + message: 'Animated notice', + options: { tags: ['target:channel'] }, + origin: { emitter: 'test' }, + }); + }); + + await waitFor(() => expect(screen.getByText('Animated notice')).toBeTruthy()); + expect(screen.getByTestId('notification-list').props.layout).toBe(expectedLayout); + }); }); diff --git a/package/src/components/Poll/CreatePollContent.tsx b/package/src/components/Poll/CreatePollContent.tsx index 53060e49ce..f31c9dceb9 100644 --- a/package/src/components/Poll/CreatePollContent.tsx +++ b/package/src/components/Poll/CreatePollContent.tsx @@ -2,7 +2,7 @@ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react' import { StyleSheet, Switch, Text, View } from 'react-native'; import { ScrollView } from 'react-native-gesture-handler'; -import Animated, { LinearTransition, useSharedValue } from 'react-native-reanimated'; +import Animated, { useSharedValue } from 'react-native-reanimated'; import { StateStore } from '@stream-io/state-store'; import { PollComposerState } from 'stream-chat'; @@ -21,6 +21,7 @@ import { useTheme, useTranslationContext, } from '../../contexts'; +import { useAnimationsContext } from '../../contexts/animationsContext/AnimationsContext'; import { useComponentsContext } from '../../contexts/componentsContext/ComponentsContext'; import { useMessageComposer } from '../../contexts/messageInputContext/hooks/useMessageComposer'; import { useStateStore } from '../../hooks/useStateStore'; @@ -32,6 +33,7 @@ const pollComposerStateSelector = (state: PollComposerState) => ({ }); export const CreatePollContent = () => { + const animations = useAnimationsContext(); const [isAnonymousPoll, setIsAnonymousPoll] = useState(false); const [allowUserSuggestedOptions, setAllowUserSuggestedOptions] = useState(false); const [allowAnswers, setAllowAnswers] = useState(false); @@ -158,12 +160,12 @@ export const CreatePollContent = () => { diff --git a/package/src/components/Poll/components/CreatePollOptions.tsx b/package/src/components/Poll/components/CreatePollOptions.tsx index 62536d1ee9..f895d68ffa 100644 --- a/package/src/components/Poll/components/CreatePollOptions.tsx +++ b/package/src/components/Poll/components/CreatePollOptions.tsx @@ -13,7 +13,6 @@ import { import { Gesture, GestureDetector } from 'react-native-gesture-handler'; import Animated, { interpolate, - LinearTransition, runOnJS, SharedValue, useAnimatedReaction, @@ -28,6 +27,7 @@ import { POLL_COMPOSER_VALIDATION_CODE, PollComposerOption, PollComposerState } import type { PollComposerValidationCode, PollComposerValidationError } from 'stream-chat'; import { useCreatePollContentContext, useTheme, useTranslationContext } from '../../../contexts'; +import { useAnimationsContext } from '../../../contexts/animationsContext/AnimationsContext'; import { useComponentsContext } from '../../../contexts/componentsContext/ComponentsContext'; import { useMessageComposer } from '../../../contexts/messageInputContext/hooks/useMessageComposer'; import { useStateStore } from '../../../hooks/useStateStore'; @@ -286,6 +286,7 @@ export const CreatePollOption = ({ onNewOrder, onRemoveOption, }: CreatePollOptionType) => { + const animations = useAnimationsContext(); const { t } = useTranslationContext(); const { icons } = useComponentsContext(); const { createPollOptionGap = 8 } = useCreatePollContentContext(); @@ -517,7 +518,10 @@ export const CreatePollOption = ({ animatedStyles, ]} > - + @@ -562,6 +566,7 @@ export type CreatePollOptionsProps = { }; export const CreatePollOptions = ({ currentOptionPositions }: CreatePollOptionsProps) => { + const animations = useAnimationsContext(); const { t } = useTranslationContext(); const messageComposer = useMessageComposer(); const { pollComposer } = messageComposer; @@ -729,7 +734,10 @@ export const CreatePollOptions = ({ currentOptionPositions }: CreatePollOptionsP return ( {t('poll.createPoll.options.label', 'Options')} - + {options.map((option, index) => ( { }); }, [semantics]); }; - -const LayoutTransition = LinearTransition.duration(200).springify(); diff --git a/package/src/components/Poll/components/MultipleAnswersField.tsx b/package/src/components/Poll/components/MultipleAnswersField.tsx index 3a871fb607..ca05e86972 100644 --- a/package/src/components/Poll/components/MultipleAnswersField.tsx +++ b/package/src/components/Poll/components/MultipleAnswersField.tsx @@ -1,15 +1,17 @@ import React, { useCallback, useMemo, useState } from 'react'; import { StyleSheet, Switch, Text, View } from 'react-native'; -import Animated, { LinearTransition } from 'react-native-reanimated'; +import Animated from 'react-native-reanimated'; import { MultipleVotesSettings } from './MultipleVotesSettings'; import { useTheme, useTranslationContext } from '../../../contexts'; +import { useAnimationsContext } from '../../../contexts/animationsContext/AnimationsContext'; import { useMessageComposer } from '../../../contexts/messageInputContext/hooks/useMessageComposer'; import { primitives } from '../../../theme'; import { useRtlMirrorSwitchStyle } from '../../../utils/rtlMirrorSwitchStyle'; export const MultipleAnswersField = () => { + const animations = useAnimationsContext(); const [allowMultipleVotes, setAllowMultipleVotes] = useState(false); const { t } = useTranslationContext(); const messageComposer = useMessageComposer(); @@ -36,7 +38,7 @@ export const MultipleAnswersField = () => { return ( diff --git a/package/src/components/Poll/components/MultipleVotesSettings.tsx b/package/src/components/Poll/components/MultipleVotesSettings.tsx index d86851dcfc..1c77973373 100644 --- a/package/src/components/Poll/components/MultipleVotesSettings.tsx +++ b/package/src/components/Poll/components/MultipleVotesSettings.tsx @@ -1,11 +1,12 @@ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { Platform, StyleSheet, Switch, Text, TextInput, View } from 'react-native'; -import Animated, { LinearTransition, StretchInY, StretchOutY } from 'react-native-reanimated'; +import Animated, { StretchInY, StretchOutY } from 'react-native-reanimated'; import { PollComposerState } from 'stream-chat'; import { useCreatePollContentContext, useTheme, useTranslationContext } from '../../../contexts'; +import { useAnimationsContext } from '../../../contexts/animationsContext/AnimationsContext'; import { useComponentsContext } from '../../../contexts/componentsContext/ComponentsContext'; import { useMessageComposer } from '../../../contexts/messageInputContext/hooks/useMessageComposer'; import { useStableCallback } from '../../../hooks'; @@ -95,6 +96,7 @@ const MaxVotesTextInput = () => { }; export const MultipleVotesSettings = () => { + const animations = useAnimationsContext(); const [allowMaxVotesPerPerson, setAllowMaxVotesPerPerson] = useState(false); const { t } = useTranslationContext(); const { icons } = useComponentsContext(); @@ -142,7 +144,7 @@ export const MultipleVotesSettings = () => { return ( { + const animations = useAnimationsContext(); const { t } = useTranslationContext(); const [dialogInput, setDialogInput] = useState(initialValue); @@ -57,7 +59,7 @@ export const PollInputDialog = ({ > diff --git a/package/src/contexts/animationsContext/AnimationsContext.tsx b/package/src/contexts/animationsContext/AnimationsContext.tsx new file mode 100644 index 0000000000..01fdb0847a --- /dev/null +++ b/package/src/contexts/animationsContext/AnimationsContext.tsx @@ -0,0 +1,141 @@ +import React, { PropsWithChildren, useContext, useMemo } from 'react'; +import type { ViewProps } from 'react-native'; + +import type { AnimatedProps } from 'react-native-reanimated'; + +import type { DeepNull, DeepOverrides, Exact } from '../../types/types'; +import { transitions as defaultTransitions } from '../../utils/animations/transitions'; +import { mergeOverrides } from '../../utils/mergeOverrides'; + +/** A Reanimated layout transition, as accepted by an animated view's `layout` prop. */ +export type LayoutTransition = NonNullable['layout']>; + +/** + * The transitions of one part of the UI. `undefined` means the view doesn't animate. + * + * Fields are required, never optional, so every default lists them and overrides of them are merged. + */ +export type TransitionConfig = { + layout: LayoutTransition | undefined; +}; + +export type Transitions = { + /** The message list itself. */ + messageList: TransitionConfig; + /** The container of the scroll to bottom button. */ + scrollToBottomButton: TransitionConfig; + /** The container the autocomplete suggestion list is positioned in. */ + suggestionList: TransitionConfig; + /** The autocomplete suggestion list inside its container. */ + suggestionListContent: TransitionConfig; + /** The outer container of the message composer. */ + composer: TransitionConfig; + /** + * The views inside the message composer: the input box, its header, the leading and trailing + * views, the command chip, link previews and the audio recording lock indicator. + */ + composerContent: TransitionConfig; + /** The attachment previews in the message composer. */ + attachmentUploadPreviews: TransitionConfig; + /** The notification list. */ + notificationList: TransitionConfig; + /** The sections of the poll creation screen. */ + pollComposer: TransitionConfig; + /** Each option on the poll creation screen. */ + pollComposerOption: TransitionConfig; +}; + +export type Animations = { + transitions: Transitions; +}; + +/** + * Overrides for `Animations`. Every key is optional, a missing or `undefined` value keeps the + * parent's and `null` turns it off. + */ +export type AnimationOverrides = DeepOverrides; + +export const DEFAULT_ANIMATIONS: Animations = { + transitions: { + attachmentUploadPreviews: { layout: defaultTransitions.layout200 }, + composer: { layout: defaultTransitions.layout200 }, + composerContent: { layout: defaultTransitions.layout200 }, + messageList: { layout: defaultTransitions.layout200 }, + notificationList: { layout: defaultTransitions.layout200 }, + pollComposer: { layout: defaultTransitions.layout200 }, + pollComposerOption: { layout: defaultTransitions.springLayout200 }, + scrollToBottomButton: { layout: defaultTransitions.layout200 }, + suggestionList: { layout: defaultTransitions.layout200 }, + suggestionListContent: { layout: defaultTransitions.layout200 }, + }, +}; + +/** Overrides that turn every transition off. */ +export const noTransitions: { transitions: DeepNull } = { + transitions: { + attachmentUploadPreviews: { layout: null }, + composer: { layout: null }, + composerContent: { layout: null }, + messageList: { layout: null }, + notificationList: { layout: null }, + pollComposer: { layout: null }, + pollComposerOption: { layout: null }, + scrollToBottomButton: { layout: null }, + suggestionList: { layout: null }, + suggestionListContent: { layout: null }, + }, +}; + +// Keyed by parent and overrides, so providers that pass the same `overrides` object under the same +// parent (e.g. one per list item) share a single merged value. +const mergeCache = new WeakMap>(); + +const mergeAnimations = (parent: Animations, overrides: AnimationOverrides): Animations => { + let mergedByOverrides = mergeCache.get(parent); + if (!mergedByOverrides) { + mergedByOverrides = new WeakMap(); + mergeCache.set(parent, mergedByOverrides); + } + const cached = mergedByOverrides.get(overrides); + if (cached) { + return cached; + } + const merged = mergeOverrides(parent, overrides); + mergedByOverrides.set(overrides, merged); + return merged; +}; + +const AnimationsContext = React.createContext(DEFAULT_ANIMATIONS); + +/** + * Overrides animations for the tree below it. Nested providers merge, and the closest wins. + * + * `overrides` is read once at mount and must be stable. + * + * @example + * ```tsx + * const animationOverrides = { transitions: { composer: { layout: null } } }; + * + * + * + * + * + * + * + * ``` + */ +export const WithAnimations = ({ + children, + overrides, +}: PropsWithChildren<{ overrides: T & Exact }>) => { + const parent = useContext(AnimationsContext); + const merged = useMemo( + () => mergeAnimations(parent, overrides), + // eslint-disable-next-line react-hooks/exhaustive-deps -- intentionally stable: overrides are set once at mount + [], + ); + return {children}; +}; + +/** Returns the animations, with the closest `WithAnimations` overrides merged over the defaults. */ +export const useAnimationsContext = () => useContext(AnimationsContext); diff --git a/package/src/contexts/animationsContext/__tests__/AnimationsContext.test.tsx b/package/src/contexts/animationsContext/__tests__/AnimationsContext.test.tsx new file mode 100644 index 0000000000..d6bffd2293 --- /dev/null +++ b/package/src/contexts/animationsContext/__tests__/AnimationsContext.test.tsx @@ -0,0 +1,166 @@ +import React, { PropsWithChildren } from 'react'; + +import { LinearTransition } from 'react-native-reanimated'; + +import { renderHook } from '@testing-library/react-native'; + +import { transitions } from '../../../utils/animations/transitions'; +import { + AnimationOverrides, + DEFAULT_ANIMATIONS, + noTransitions, + useAnimationsContext, + WithAnimations, +} from '../AnimationsContext'; + +const withOverrides = + (...overridesChain: AnimationOverrides[]) => + ({ children }: PropsWithChildren) => + overridesChain.reduceRight( + (tree, overrides) => {tree}, + children, + ); + +describe('AnimationsContext', () => { + it('returns the defaults without a provider', () => { + const { result } = renderHook(() => useAnimationsContext()); + + expect(result.current).toBe(DEFAULT_ANIMATIONS); + expect(result.current.transitions.composer.layout).toBe(transitions.layout200); + expect(result.current.transitions.pollComposerOption.layout).toBe(transitions.springLayout200); + }); + + it('turns a transition off with null and keeps the other defaults', () => { + const { result } = renderHook(() => useAnimationsContext(), { + wrapper: withOverrides({ transitions: { composer: { layout: null } } }), + }); + + expect(result.current.transitions.composer.layout).toBeUndefined(); + expect(result.current.transitions.composerContent).toBe( + DEFAULT_ANIMATIONS.transitions.composerContent, + ); + expect(result.current.transitions.messageList).toBe(DEFAULT_ANIMATIONS.transitions.messageList); + }); + + it('keeps the parent value when an override is undefined', () => { + const { result } = renderHook(() => useAnimationsContext(), { + wrapper: withOverrides({ transitions: { composer: { layout: undefined } } }), + }); + + expect(result.current.transitions.composer.layout).toBe(transitions.layout200); + }); + + it('ignores keys that have no default', () => { + const overrides = { + transitions: { composer: { layout: null }, composr: { layout: null } }, + }; + const { result } = renderHook(() => useAnimationsContext(), { + wrapper: withOverrides(overrides), + }); + + expect(result.current.transitions.composer.layout).toBeUndefined(); + expect('composr' in result.current.transitions).toBe(false); + }); + + it('returns the parent value itself when nothing is overridden', () => { + const { result } = renderHook(() => useAnimationsContext(), { + wrapper: withOverrides({ transitions: { composer: {} } }), + }); + + expect(result.current).toBe(DEFAULT_ANIMATIONS); + }); + + it('passes a custom transition through as is', () => { + const springy = LinearTransition.springify().damping(18); + const { result } = renderHook(() => useAnimationsContext(), { + wrapper: withOverrides({ transitions: { composerContent: { layout: springy } } }), + }); + + expect(result.current.transitions.composerContent.layout).toBe(springy); + }); + + it('merges nested providers with the closest one winning', () => { + const springy = LinearTransition.springify(); + const { result } = renderHook(() => useAnimationsContext(), { + wrapper: withOverrides( + { transitions: { composer: { layout: null }, messageList: { layout: null } } }, + { transitions: { composer: { layout: springy } } }, + ), + }); + + expect(result.current.transitions.composer.layout).toBe(springy); + expect(result.current.transitions.messageList.layout).toBeUndefined(); + expect(result.current.transitions.notificationList.layout).toBe(transitions.layout200); + }); + + it('turns every transition off with noTransitions', () => { + const { result } = renderHook(() => useAnimationsContext(), { + wrapper: withOverrides(noTransitions), + }); + + for (const config of Object.values(result.current.transitions)) { + expect(config.layout).toBeUndefined(); + } + }); + + it('shares one merged value between providers with the same overrides and parent', () => { + const overrides: AnimationOverrides = { transitions: { composer: { layout: null } } }; + const first = renderHook(() => useAnimationsContext(), { wrapper: withOverrides(overrides) }); + const second = renderHook(() => useAnimationsContext(), { wrapper: withOverrides(overrides) }); + const differentObject = renderHook(() => useAnimationsContext(), { + wrapper: withOverrides({ transitions: { composer: { layout: null } } }), + }); + + expect(first.result.current).toBe(second.result.current); + expect(differentObject.result.current).not.toBe(first.result.current); + expect(differentObject.result.current).toEqual(first.result.current); + }); + + it('reads overrides only once at mount', () => { + let overrides: AnimationOverrides = { transitions: { composer: { layout: null } } }; + const { rerender, result } = renderHook(() => useAnimationsContext(), { + wrapper: ({ children }: PropsWithChildren) => ( + {children} + ), + }); + const initial = result.current; + + overrides = { transitions: { messageList: { layout: null } } }; + rerender({}); + + expect(result.current).toBe(initial); + expect(result.current.transitions.messageList.layout).toBe(transitions.layout200); + }); + + // Checked by `yarn test:typecheck`: each `@ts-expect-error` fails the build if the line compiles. + it('rejects unknown keys at the type level, also outside fresh object literals', () => { + const valid = { + transitions: { + composer: { layout: null }, + messageList: { layout: LinearTransition.duration(100) }, + }, + }; + const unknownUseCase = { + transitions: { composer: { layout: null }, composr: { layout: null } }, + }; + const unknownField = { transitions: { composer: { layout: null, layot: null } } }; + const unknownNamespace = { transitions: { composer: { layout: null } }, transitons: {} }; + + const elements = [ + , + , + , + // @ts-expect-error `composr` is not a use case. + , + // @ts-expect-error `layot` is not a transition field. + , + // @ts-expect-error `transitons` is not a namespace. + , + ]; + + expect(elements).toHaveLength(6); + }); +}); diff --git a/package/src/contexts/index.ts b/package/src/contexts/index.ts index 02ac8631ed..4bc95a3abd 100644 --- a/package/src/contexts/index.ts +++ b/package/src/contexts/index.ts @@ -1,4 +1,5 @@ export * from './accessibilityContext/AccessibilityContext'; +export * from './animationsContext/AnimationsContext'; export * from './attachmentPickerContext/AttachmentPickerContext'; export * from './componentsContext/ComponentsContext'; export * from './bottomSheetContext/BottomSheetContext'; diff --git a/package/src/types/types.ts b/package/src/types/types.ts index 63682da8de..b22e4e91fb 100644 --- a/package/src/types/types.ts +++ b/package/src/types/types.ts @@ -97,6 +97,40 @@ export type UnknownType = Record; export type ValueOf = T[keyof T]; +/* + * The helpers below walk every level of `Shape` that is a plain object type and treat anything else + * (class instances, functions, primitives) as a leaf. Declare those levels with `type`, not + * `interface`: an interface isn't assignable to `Record`, so it counts as a leaf. + */ + +/** Overrides for `Shape`: every key is optional at every level, and every leaf also accepts `null`. */ +export type DeepOverrides = { + [Key in keyof Shape]?: NonNullable extends Record + ? DeepOverrides> + : Shape[Key] | null; +}; + +/** `Shape` with every leaf set to `null` and every key required. */ +export type DeepNull = { + [Key in keyof Shape]-?: NonNullable extends Record + ? DeepNull> + : null; +}; + +/** + * `T` with every key that `Shape` doesn't declare typed as `never`, at every level. + * + * Use it as `value: T & Exact` with `T extends Shape` to reject unknown keys even on + * values that are not fresh object literals. + */ +export type Exact = { + [Key in keyof T]: Key extends keyof Shape + ? NonNullable extends Record + ? Exact> + : T[Key] + : never; +}; + export enum AndroidOutputFormat { DEFAULT = 0, THREE_GPP = 1, diff --git a/package/src/utils/__tests__/mergeOverrides.test.ts b/package/src/utils/__tests__/mergeOverrides.test.ts new file mode 100644 index 0000000000..60b628901d --- /dev/null +++ b/package/src/utils/__tests__/mergeOverrides.test.ts @@ -0,0 +1,66 @@ +import { isPlainObject, mergeOverrides } from '../mergeOverrides'; + +class Builder { + constructor(public duration: number) {} +} + +describe('isPlainObject', () => { + it('accepts object literals and null-prototype objects only', () => { + expect(isPlainObject({})).toBe(true); + expect(isPlainObject(Object.create(null))).toBe(true); + expect(isPlainObject([])).toBe(false); + expect(isPlainObject(new Builder(200))).toBe(false); + expect(isPlainObject(Builder)).toBe(false); + expect(isPlainObject(null)).toBe(false); + expect(isPlainObject(1)).toBe(false); + }); +}); + +describe('mergeOverrides', () => { + const builder = new Builder(200); + const parent = { + a: { first: builder, second: builder }, + b: { first: builder }, + list: [1, 2, 3], + }; + + it('replaces only the overridden fields and keeps their siblings', () => { + const custom = new Builder(300); + const merged = mergeOverrides(parent, { a: { first: custom } }); + + expect(merged.a.first).toBe(custom); + expect(merged.a.second).toBe(builder); + expect(merged.b).toBe(parent.b); + }); + + it('turns null into undefined and skips undefined', () => { + const merged = mergeOverrides(parent, { a: { first: null, second: undefined } }); + + expect(merged.a.first).toBeUndefined(); + expect(merged.a.second).toBe(builder); + }); + + it('replaces arrays instead of merging them', () => { + const list = [9]; + expect(mergeOverrides(parent, { list }).list).toBe(list); + }); + + it('ignores keys the parent does not have', () => { + const merged = mergeOverrides(parent, { a: { third: builder }, c: { first: builder } }); + + expect(merged).toBe(parent); + expect('c' in merged).toBe(false); + }); + + it('ignores a non-object override of an object', () => { + expect(mergeOverrides(parent, { a: null })).toBe(parent); + }); + + it('returns the parent itself when nothing changes and never mutates it', () => { + const snapshot = { ...parent, a: { ...parent.a } }; + + expect(mergeOverrides(parent, { a: { first: builder } })).toBe(parent); + mergeOverrides(parent, { a: { first: new Builder(300) } }); + expect(parent).toEqual(snapshot); + }); +}); diff --git a/package/src/utils/animations/transitions.ts b/package/src/utils/animations/transitions.ts index 8770cf8c07..33215e7198 100644 --- a/package/src/utils/animations/transitions.ts +++ b/package/src/utils/animations/transitions.ts @@ -10,6 +10,7 @@ export const transitions = { fadeIn200: FadeIn.duration(200), fadeOut200: FadeOut.duration(200), layout200: LinearTransition.duration(200), + springLayout200: LinearTransition.duration(200).springify(), zoomIn200: ZoomIn.duration(200), zoomOut200: ZoomOut.duration(200), } as const; diff --git a/package/src/utils/mergeOverrides.ts b/package/src/utils/mergeOverrides.ts new file mode 100644 index 0000000000..37c21d4324 --- /dev/null +++ b/package/src/utils/mergeOverrides.ts @@ -0,0 +1,37 @@ +/** Whether `value` is an object literal or `Object.create(null)`, not an array or a class instance. */ +export const isPlainObject = (value: unknown): value is Record => { + if (typeof value !== 'object' || value === null) { + return false; + } + const prototype = Object.getPrototypeOf(value); + return prototype === Object.prototype || prototype === null; +}; + +/** + * Merges `overrides` over `parent` through plain objects only, so class instances, functions and + * arrays are replaced by reference. Only keys present in `parent` are read, `undefined` keeps the + * parent's value and `null` turns it into `undefined`. Unchanged objects are returned as is. + */ +export const mergeOverrides = (parent: T, overrides: unknown): T => { + if (!isPlainObject(parent) || !isPlainObject(overrides)) { + return parent; + } + let merged: Record | undefined; + for (const key of Object.keys(parent)) { + const override = overrides[key]; + if (override === undefined) { + continue; + } + const parentValue = parent[key]; + const value = isPlainObject(parentValue) + ? mergeOverrides(parentValue, override) + : override === null + ? undefined + : override; + if (value !== parentValue) { + merged ??= { ...parent }; + merged[key] = value; + } + } + return (merged ?? parent) as T; +}; From c0f89afadd1d1b6ba781a70bf52bb5d58e7c789d Mon Sep 17 00:00:00 2001 From: Ivan Sekovanikj <31964049+isekovanic@users.noreply.github.com> Date: Wed, 2 Dec 2026 10:11:50 +0100 Subject: [PATCH 3/5] fix: allow theming the instant commands title in the attachment picker (#4037) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ticket: https://linear.app/stream/issue/RN-546 Fixes #4029. ## ๐ŸŽฏ Goal Let apps theme the "Instant Commands" title in the attachment picker. It was styled only by a local style, so an app that sets a custom font through the theme got the system font for this one title. ## ๐Ÿ›  Implementation details - A new theme key `attachmentPicker.commandsTitle` styles the title. - It's applied after the default style, so the app's values win and everything it doesn't set keeps the default. ## ๐Ÿงช Testing - A unit test renders the picker with a `fontFamily` on `commandsTitle` and checks that the title uses it and keeps its default weight. --- .../components/AttachmentPickerContent.tsx | 9 ++++++++- .../__tests__/AttachmentCommandPicker.test.tsx | 18 ++++++++++++++++++ .../src/contexts/themeContext/utils/theme.ts | 2 ++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/package/src/components/AttachmentPicker/components/AttachmentPickerContent.tsx b/package/src/components/AttachmentPicker/components/AttachmentPickerContent.tsx index 4af9095c37..54a73321c0 100644 --- a/package/src/components/AttachmentPicker/components/AttachmentPickerContent.tsx +++ b/package/src/components/AttachmentPicker/components/AttachmentPickerContent.tsx @@ -133,10 +133,17 @@ export const AttachmentCommandPicker = () => { ); const { commands } = useStateStore(channel.configState, commandsSelector); const styles = useCommandPickerStyle(); + const { + theme: { + attachmentPicker: { commandsTitle }, + }, + } = useTheme(); return ( <> - {t('attachmentPicker.commands.title', 'Instant Commands')} + + {t('attachmentPicker.commands.title', 'Instant Commands')} + { expect(screen.getByText('Giphy')).toBeTruthy(); }); + + it('applies the commandsTitle theme over the default title style', () => { + render( + + + + + , + ); + + const title = StyleSheet.flatten(screen.getByText('Instant Commands').props.style); + expect(title.fontFamily).toBe('Inter'); + expect(title.fontWeight).toBeDefined(); + }); }); diff --git a/package/src/contexts/themeContext/utils/theme.ts b/package/src/contexts/themeContext/utils/theme.ts index 341e27aa64..8f14b87dbb 100644 --- a/package/src/contexts/themeContext/utils/theme.ts +++ b/package/src/contexts/themeContext/utils/theme.ts @@ -103,6 +103,7 @@ export type Theme = { }; attachmentPicker: { bottomSheetContentContainer: ViewStyle; + commandsTitle: TextStyle; durationText: TextStyle; content: { actionContainer: ViewStyle; @@ -1225,6 +1226,7 @@ export const defaultTheme: Theme = { }, attachmentPicker: { bottomSheetContentContainer: {}, + commandsTitle: {}, durationText: {}, content: { actionContainer: {}, From ede2abd627d86fde654a62135f8bde8687423ce1 Mon Sep 17 00:00:00 2001 From: Ivan Sekovanikj <31964049+isekovanic@users.noreply.github.com> Date: Wed, 2 Dec 2026 10:11:51 +0100 Subject: [PATCH 4/5] fix: drop Reanimated hook dependencies that only warn on native (#4039) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ticket: https://linear.app/stream/issue/RN-551 Fixes #4031. Stacked on #4037. ## ๐ŸŽฏ Goal Stop the Reanimated warning "Dependencies should only be used on the web and are always ignored on native". `MessageBubble` was the one in the issue, but the same pattern was in 22 calls across the SDK. ## ๐Ÿ›  Implementation details - Reanimated 4 ignores the dependencies of `useAnimatedStyle`, `useDerivedValue` and `useAnimatedReaction` on native and warns once they're passed. It rebuilds the worklet from its closure instead. - All 22 calls drop the argument: the image gallery, `MessageBubble`, `LoadingDot`, the progress bars, the bottom sheet and `AIUIEntrance`. The SampleApp's `SecretMenu` had one more. - A `no-restricted-syntax` lint rule fails on new ones. `null` is still allowed, since it's needed to pass adapters. ### Reanimated 3 Reanimated 3 uses an explicit array on native. Without one, it restarts a worklet when anything in its closure changes, which is what Reanimated 4 always does. - 18 calls restart at the same moments as before. Either their arrays listed everything they capture or they only read shared values. - 4 calls captured values their arrays didn't list: the gallery's header and footer opacity, its background, the first style in `useAnimatedGalleryStyle` and the `StreamBottomSheetModalFlatList` reaction. They now also update when a screen dimension, the background colour or `scrollEnabledProp` changes, instead of keeping the old value. - Nothing captures a value that changes identity on every render, so no worklet restarts on every render. ## ๐Ÿงช Testing - Lint, typecheck and the unit tests pass. The lint rule was checked against calls with and without dependencies. - Reanimated is mocked in Jest, so the change itself is covered by reading the Reanimated 3 and 4 sources rather than by a test. --- eslint.config.mjs | 15 ++++++ .../SampleApp/src/components/SecretMenu.tsx | 15 +++--- .../generative-ui/AIUIEntrance.tsx | 2 +- .../components/ImageGallery/ImageGallery.tsx | 50 ++++++++----------- .../components/ImageGalleryFooter.tsx | 19 +++---- .../hooks/useAnimatedGalleryStyle.tsx | 4 +- .../src/components/Indicators/LoadingDot.tsx | 9 ++-- .../Message/MessageItemView/MessageBubble.tsx | 11 ++-- .../ProgressControl/ProgressControl.tsx | 37 ++++++-------- .../ProgressControl/WaveProgressBar.tsx | 32 +++++------- .../UIComponents/BottomSheetModal.tsx | 49 +++++------------- .../StreamBottomSheetModalFlatList.tsx | 1 - 12 files changed, 100 insertions(+), 144 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index d65352f459..d32471daf1 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -230,6 +230,21 @@ export default tsEslint.config( 'react-hooks/rules-of-hooks': 'error', 'react-native/no-inline-styles': 'off', 'react/no-unstable-nested-components': 'warn', + // Reanimated ignores hook dependencies on native and warns when they're passed. + 'no-restricted-syntax': [ + 'error', + { + message: + 'Reanimated ignores dependencies on native and warns about them. Drop the argument.', + selector: + 'CallExpression[callee.name=/^(useAnimatedStyle|useDerivedValue|useAnimatedProps|useAnimatedScrollHandler)$/][arguments.length>1]:not([arguments.1.value=null])', + }, + { + message: + 'Reanimated ignores dependencies on native and warns about them. Drop the argument.', + selector: "CallExpression[callee.name='useAnimatedReaction'][arguments.length>2]", + }, + ], // -- Hygiene rules previously enabled via @react-native/eslint-config that we // kept after dropping the package -- they catch real footguns. diff --git a/examples/SampleApp/src/components/SecretMenu.tsx b/examples/SampleApp/src/components/SecretMenu.tsx index 47d7fc05a1..f757652082 100644 --- a/examples/SampleApp/src/components/SecretMenu.tsx +++ b/examples/SampleApp/src/components/SecretMenu.tsx @@ -89,16 +89,13 @@ export const SlideInView = ({ animatedHeight.value = height; }; - const animatedStyle = useAnimatedStyle( - () => ({ - height: withSpring(visible ? animatedHeight.value : 0, { - damping: 20, - overshootClamping: true, - }), - opacity: withTiming(visible ? 1 : 0, { duration: 500 }), + const animatedStyle = useAnimatedStyle(() => ({ + height: withSpring(visible ? animatedHeight.value : 0, { + damping: 20, + overshootClamping: true, }), - [visible], - ); + opacity: withTiming(visible ? 1 : 0, { duration: 500 }), + })); return ( diff --git a/package/src/ai-components/generative-ui/AIUIEntrance.tsx b/package/src/ai-components/generative-ui/AIUIEntrance.tsx index b7d21282a5..04130d6fa1 100644 --- a/package/src/ai-components/generative-ui/AIUIEntrance.tsx +++ b/package/src/ai-components/generative-ui/AIUIEntrance.tsx @@ -104,7 +104,7 @@ const useEntrance = ( // Back in focus as it settles: a blur this small draws nothing. ...(CAN_BLUR ? { filter: [{ blur: Math.max(0, 1 - shown) * START_BLUR }] } : {}), }; - }, [reduceMotion]); + }); return { hasShown, style }; }; diff --git a/package/src/components/ImageGallery/ImageGallery.tsx b/package/src/components/ImageGallery/ImageGallery.tsx index 6d5ac22802..e5fadb5701 100644 --- a/package/src/components/ImageGallery/ImageGallery.tsx +++ b/package/src/components/ImageGallery/ImageGallery.tsx @@ -243,7 +243,6 @@ export const ImageGalleryWithContext = (props: ImageGalleryWithContextProps) => (index) => { translationX.value = -(fullWindowWidth + MARGIN) * index; }, - [fullWindowWidth], ); const { doubleTap, pan, pinch, singleTap } = useImageGalleryGestures({ @@ -273,41 +272,32 @@ export const ImageGalleryWithContext = (props: ImageGalleryWithContextProps) => (translateY.value - ((imageHeight / 2) * scale.value - halfScreenHeight)) / quarterScreenHeight : 1; - }, []); + }); // Offsets the pager horizontally to the current slide. - const pagerStyle = useAnimatedStyle( - () => ({ - transform: [ - { scaleX: 1 }, - { - translateX: translationX.value, - }, - ], - }), - [], - ); + const pagerStyle = useAnimatedStyle(() => ({ + transform: [ + { scaleX: 1 }, + { + translateX: translationX.value, + }, + ], + })); // Background that fades as the image is dragged down. - const containerBackground = useAnimatedStyle( - () => ({ - backgroundColor: backgroundColor || semantics.backgroundCoreApp, - opacity: headerFooterOpacity.value, - }), - [headerFooterOpacity], - ); + const containerBackground = useAnimatedStyle(() => ({ + backgroundColor: backgroundColor || semantics.backgroundCoreApp, + opacity: headerFooterOpacity.value, + })); // Slides the screen in from below the viewport. - const showScreenStyle = useAnimatedStyle( - () => ({ - transform: [ - { - translateY: screenTranslateY.value, - }, - ], - }), - [], - ); + const showScreenStyle = useAnimatedStyle(() => ({ + transform: [ + { + translateY: screenTranslateY.value, + }, + ], + })); const closeGridView = () => { setIsGridViewVisible(false); diff --git a/package/src/components/ImageGallery/components/ImageGalleryFooter.tsx b/package/src/components/ImageGallery/components/ImageGalleryFooter.tsx index 923f54f845..40322153f4 100644 --- a/package/src/components/ImageGallery/components/ImageGalleryFooter.tsx +++ b/package/src/components/ImageGallery/components/ImageGalleryFooter.tsx @@ -62,17 +62,14 @@ export const ImageGalleryFooterWithContext = (props: ImageGalleryFooterProps) => const { imageGalleryStateStore } = useImageGalleryContext(); const { asset, currentIndex } = useStateStore(imageGalleryStateStore.state, imageGallerySelector); - const footerStyle = useAnimatedStyle( - () => ({ - opacity: opacity.value, - transform: [ - { - translateY: interpolate(visible.value, [0, 1], [height, 0], Extrapolation.CLAMP), - }, - ], - }), - [height], - ); + const footerStyle = useAnimatedStyle(() => ({ + opacity: opacity.value, + transform: [ + { + translateY: interpolate(visible.value, [0, 1], [height, 0], Extrapolation.CLAMP), + }, + ], + })); const share = async () => { if (shareIsInProgressRef.current) { diff --git a/package/src/components/ImageGallery/hooks/useAnimatedGalleryStyle.tsx b/package/src/components/ImageGallery/hooks/useAnimatedGalleryStyle.tsx index bf4930c752..45b53bff17 100644 --- a/package/src/components/ImageGallery/hooks/useAnimatedGalleryStyle.tsx +++ b/package/src/components/ImageGallery/hooks/useAnimatedGalleryStyle.tsx @@ -64,7 +64,7 @@ export const useAnimatedGalleryStyle = ({ { scaleX: 1 }, ], }; - }, []); + }); const animatedStyles = useAnimatedStyle(() => { const xScaleOffset = 7 * screenWidth * (0.5 + index); @@ -79,7 +79,7 @@ export const useAnimatedGalleryStyle = ({ { scale: oneEighth }, ], }; - }, [index]); + }); return [animatedGalleryStyle, animatedStyles]; }; diff --git a/package/src/components/Indicators/LoadingDot.tsx b/package/src/components/Indicators/LoadingDot.tsx index 711d7a4fcc..fba4406bb3 100644 --- a/package/src/components/Indicators/LoadingDot.tsx +++ b/package/src/components/Indicators/LoadingDot.tsx @@ -45,12 +45,9 @@ export const LoadingDot = (props: Props) => { // eslint-disable-next-line react-hooks/exhaustive-deps }, []); - const dotStyle = useAnimatedStyle( - () => ({ - opacity: opacity.value, - }), - [], - ); + const dotStyle = useAnimatedStyle(() => ({ + opacity: opacity.value, + })); return ( ({ - opacity: interpolate(translateX.value, [0, SWIPABLE_THRESHOLD], [0, 1]), - width: translateX.value, - }), - [], - ); + const swipeContentAnimatedStyle = useAnimatedStyle(() => ({ + opacity: interpolate(translateX.value, [0, SWIPABLE_THRESHOLD], [0, 1]), + width: translateX.value, + })); return ( diff --git a/package/src/components/ProgressControl/ProgressControl.tsx b/package/src/components/ProgressControl/ProgressControl.tsx index 0bfc82247f..206a79c762 100644 --- a/package/src/components/ProgressControl/ProgressControl.tsx +++ b/package/src/components/ProgressControl/ProgressControl.tsx @@ -54,7 +54,6 @@ export const ProgressControl = (props: ProgressControlProps) => { (newProgress) => { state.value = newProgress; }, - [progress], ); const pan = useMemo(() => { @@ -84,28 +83,22 @@ export const ProgressControl = (props: ProgressControlProps) => { return gesture; }, [expandedTouchArea, isRTL, isSeekable, onEndDrag, onStartDrag, state, testID, widthInNumbers]); - const thumbStyles = useAnimatedStyle( - () => ({ - transform: [ - { - translateX: interpolate( - state.value, - [0, 1], - [0, (widthInNumbers - PROGRESS_THUMB_WIDTH / 2) * thumbDirectionMultiplier], - ), - }, - ], - position: 'absolute', - }), - [thumbDirectionMultiplier, widthInNumbers], - ); + const thumbStyles = useAnimatedStyle(() => ({ + transform: [ + { + translateX: interpolate( + state.value, + [0, 1], + [0, (widthInNumbers - PROGRESS_THUMB_WIDTH / 2) * thumbDirectionMultiplier], + ), + }, + ], + position: 'absolute', + })); - const animatedFilledStyles = useAnimatedStyle( - () => ({ - width: state.value * widthInNumbers, - }), - [widthInNumbers], - ); + const animatedFilledStyles = useAnimatedStyle(() => ({ + width: state.value * widthInNumbers, + })); const progressPercent = Math.round(progress * 100); const accessibilityValue = useMemo( diff --git a/package/src/components/ProgressControl/WaveProgressBar.tsx b/package/src/components/ProgressControl/WaveProgressBar.tsx index f1bcd7fb68..c04524b0d3 100644 --- a/package/src/components/ProgressControl/WaveProgressBar.tsx +++ b/package/src/components/ProgressControl/WaveProgressBar.tsx @@ -197,26 +197,20 @@ export const WaveProgressBar = React.memo( [resampledWaveformData], ); - const progressOverlayStyles = useAnimatedStyle( - () => ({ - width: clampProgress(visualProgress.value) * maxProgressWidth, - }), - [maxProgressWidth], - ); + const progressOverlayStyles = useAnimatedStyle(() => ({ + width: clampProgress(visualProgress.value) * maxProgressWidth, + })); - const thumbStyles = useAnimatedStyle( - () => ({ - position: 'absolute', - transform: [ - { - translateX: - Math.min(clampProgress(visualProgress.value) * fullWidth, maxThumbTranslateX) * - thumbDirectionMultiplier, - }, - ], - }), - [fullWidth, maxThumbTranslateX, thumbDirectionMultiplier], - ); + const thumbStyles = useAnimatedStyle(() => ({ + position: 'absolute', + transform: [ + { + translateX: + Math.min(clampProgress(visualProgress.value) * fullWidth, maxThumbTranslateX) * + thumbDirectionMultiplier, + }, + ], + })); return ( diff --git a/package/src/components/UIComponents/BottomSheetModal.tsx b/package/src/components/UIComponents/BottomSheetModal.tsx index aa54436d54..9edee044e4 100644 --- a/package/src/components/UIComponents/BottomSheetModal.tsx +++ b/package/src/components/UIComponents/BottomSheetModal.tsx @@ -102,23 +102,19 @@ const BottomSheetModalInner = (props: PropsWithChildren) const fixedBaseHeight = Math.min(height, maxHeight); const contentHeight = useSharedValue(undefined); - const baseHeight = useDerivedValue( - () => - getBottomSheetBaseHeight({ - contentHeight: contentHeight.value, - enableDynamicSizing, - height, - maxHeight, - }), - [contentHeight, enableDynamicSizing, height, maxHeight], + const baseHeight = useDerivedValue(() => + getBottomSheetBaseHeight({ + contentHeight: contentHeight.value, + enableDynamicSizing, + height, + maxHeight, + }), ); - const topSnapIndex = useDerivedValue( - () => - getBottomSheetTopSnapIndex({ - baseHeight: baseHeight.value, - maxHeight, - }), - [baseHeight, maxHeight], + const topSnapIndex = useDerivedValue(() => + getBottomSheetTopSnapIndex({ + baseHeight: baseHeight.value, + maxHeight, + }), ); const sheetTranslateY = useSharedValue(maxHeight); @@ -321,15 +317,6 @@ const BottomSheetModalInner = (props: PropsWithChildren) }, ); }, - [ - baseHeight, - contentHeight, - enableDynamicSizing, - isOpening, - maxHeight, - sheetTranslateY, - visible, - ], ); // Reset the animation state when the modal is hidden. @@ -391,16 +378,6 @@ const BottomSheetModalInner = (props: PropsWithChildren) easing: Easing.inOut(Easing.ease), }); }, - [ - baseHeight, - currentSnapIndex, - isOpen, - isOpening, - maxHeight, - sheetTranslateY, - topSnapIndex, - visible, - ], ); const animateKeyboardOffset = useStableCallback((offset: number) => { @@ -442,7 +419,7 @@ const BottomSheetModalInner = (props: PropsWithChildren) const threshold = Math.max(1, Math.min(baseHeight.value, maxHeight)); const progress = Math.min(1, visibleHeight / threshold); return { opacity: progress }; - }, [baseHeight, maxHeight]); + }); const panGesture = useMemo( () => diff --git a/package/src/components/UIComponents/StreamBottomSheetModalFlatList.tsx b/package/src/components/UIComponents/StreamBottomSheetModalFlatList.tsx index dc59dc0418..771e3911a6 100644 --- a/package/src/components/UIComponents/StreamBottomSheetModalFlatList.tsx +++ b/package/src/components/UIComponents/StreamBottomSheetModalFlatList.tsx @@ -38,7 +38,6 @@ export const StreamBottomSheetModalFlatList = ({ runOnJS(setNativeScrollEnabled)(value.currentSnapIndex === value.topSnapIndex); }, - [currentSnapIndex, topSnapIndex], ); return ; From ad0344c9eb1e4c7f68a0ee565e100db3f2c8c703 Mon Sep 17 00:00:00 2001 From: Oliver Lazoroski Date: Wed, 2 Dec 2026 10:50:39 +0100 Subject: [PATCH 5/5] fix(hooks): bump @stream-io/state-store to 1.3.1 and use its useStateStore binding (#4035) ## Summary Bump `@stream-io/state-store` to `^1.3.1` in React Native core and SampleApp, and replace the SDK's own `useStateStore` with the one from `@stream-io/state-store/react-bindings`. - **1.3.1** makes `subscribeWithSelector` notify when a selection shrinks: an array selection that gets shorter, or an object selection that loses a key ([js-toolkit#67](https://github.com/GetStream/js-toolkit/pull/67)). - **The SDK's own hook had the opposite gap.** Its snapshot compared only the cached selection's keys, so a selection that grew (an added key, or an array growing with the same prefix) kept returning the stale value even though the store had notified. - **`package/src/hooks/useStateStore.ts` is deleted.** All internal imports now use `@stream-io/state-store/react-bindings`, as the AI components already did. `hooks/index.ts` re-exports the binding's hook, so `useStateStore` is still exported for integrators with the same signature. - No built-in selector changes shape, so only integrators' own selectors behave differently. ## Tests New `package/src/hooks/__tests__/useStateStore.test.tsx` (9 tests): the SDK export is the binding's hook, a selection that gains or loses a key, an array that grows or shrinks, references kept when nothing changed, and no store. The two shrink tests fail with 1.3.0 and pass with 1.3.1. ## Verification - `yarn lint` passes, including the entry-isolation check. - `cd package && yarn test:typecheck` and `yarn build` pass. - `yarn test:unit`: 3339 tests pass. --- examples/SampleApp/package.json | 2 +- package/package.json | 2 +- .../AITypingIndicatorView/hooks/useAIState.ts | 3 +- .../Accessibility/OverlayA11yShield.tsx | 3 +- .../Attachment/Audio/AudioAttachment.tsx | 2 +- .../AttachmentPickerItem.tsx | 2 +- .../components/AttachmentPickerContent.tsx | 2 +- .../AutoCompleteInput/AutoCompleteInput.tsx | 2 +- .../AutoCompleteSuggestionList.tsx | 2 +- package/src/components/Channel/Channel.tsx | 3 +- .../src/components/Channel/ChannelShell.tsx | 2 +- .../hooks/useCreateOwnCapabilitiesContext.ts | 2 +- .../Channel/hooks/useSupersededChannelSwap.ts | 3 +- .../ChannelEditDetailsFormContent.tsx | 3 +- .../components/ChannelEditImageSheet.tsx | 3 +- .../components/ChannelEditName.tsx | 3 +- .../members/ChannelAddMembersFormContent.tsx | 2 +- .../components/members/ChannelMemberList.tsx | 2 +- .../navigation-section/FileAttachmentList.tsx | 2 +- .../navigation-section/MediaList.tsx | 2 +- .../navigation-section/PinnedMessageList.tsx | 2 +- .../hooks/useChannelMembersState.ts | 3 +- .../hooks/useChannelOnlineMemberCount.ts | 3 +- .../ChannelList/hooks/useMutedUsers.ts | 2 +- .../ChannelList/hooks/usePaginatedChannels.ts | 2 +- .../ChannelMessagePreviewDeliveryStatus.tsx | 2 +- .../hooks/useChannelPreviewData.ts | 3 +- .../hooks/useChannelPreviewDraftMessage.ts | 3 +- .../hooks/useChannelPreviewPollLabel.ts | 2 +- .../ChannelPreview/hooks/useIsChannelMuted.ts | 3 +- package/src/components/Chat/Chat.tsx | 2 +- .../Chat/hooks/useNetworkConnectionState.ts | 2 +- .../Chat/hooks/useWSConnectionState.ts | 2 +- .../components/ImageGallery/ImageGallery.tsx | 3 +- .../components/AnimatedGalleryImage.tsx | 3 +- .../components/AnimatedGalleryVideo.tsx | 4 +- .../components/ImageGalleryA11yProbe.tsx | 3 +- .../components/ImageGalleryFooter.tsx | 3 +- .../components/ImageGalleryHeader.tsx | 3 +- .../components/ImageGalleryVideoControl.tsx | 3 +- .../ImageGallery/components/ImageGrid.tsx | 3 +- .../Headers/MessageReminderHeader.tsx | 2 +- .../Message/MessageItemView/MessageFooter.tsx | 2 +- .../Message/MessageItemView/MessageHeader.tsx | 2 +- .../Message/MessageItemView/MessageStatus.tsx | 2 +- .../MessageItemView/MessageWrapper.tsx | 2 +- .../hooks/useIsMessageDeliveredToOthers.ts | 2 +- .../Message/hooks/useIsMessageReadByOthers.ts | 2 +- .../Message/hooks/useMessageDeliveryData.ts | 2 +- .../Message/hooks/useMessageReadData.ts | 2 +- .../Message/hooks/useUserMuteActive.ts | 2 +- .../components/MessageInput/CommandChip.tsx | 3 +- .../MessageInput/MessageComposer.tsx | 2 +- .../MessageComposerLeadingView.tsx | 3 +- .../MessageInput/MessageInputHeaderView.tsx | 3 +- .../MessageInput/MessageInputTrailingView.tsx | 3 +- .../ShowThreadMessageInChannelButton.tsx | 2 +- .../AudioRecorder/AudioRecorder.tsx | 2 +- .../AudioRecorder/AudioRecordingButton.tsx | 3 +- .../AudioRecordingInProgress.tsx | 2 +- .../AudioRecorder/AudioRecordingPreview.tsx | 2 +- .../components/OutputButtons/index.tsx | 2 +- .../hooks/useCooldownRemaining.tsx | 2 +- .../MessageInput/hooks/useIsCooldownActive.ts | 2 +- .../MessageInput/hooks/useLinkPreviews.ts | 2 +- .../MessageList/MessageFlashList.tsx | 3 +- .../components/MessageList/MessageList.tsx | 2 +- .../MessageList/TypingIndicatorContainer.tsx | 2 +- .../UnreadMessagesNotification.tsx | 2 +- .../dateSeparatorSystemMessages.test.tsx | 2 +- .../MessageList/hooks/useMessageList.ts | 3 +- .../MessageList/hooks/useMessageListFocus.ts | 3 +- .../hooks/useMessageListPagination.ts | 3 +- .../MessageList/hooks/useOwnUnreadCount.ts | 2 +- .../MessageList/hooks/useTypingUsers.ts | 2 +- .../Notifications/hooks/useNotifications.ts | 2 +- .../hooks/useSystemNotifications.ts | 2 +- .../src/components/Poll/CreatePollContent.tsx | 2 +- .../Poll/components/CreatePollOptions.tsx | 2 +- .../Poll/components/MultipleVotesSettings.tsx | 2 +- .../Poll/contexts/PollUIStateContext.tsx | 3 +- .../Poll/hooks/usePollStateStore.ts | 2 +- package/src/components/Reply/Reply.tsx | 2 +- package/src/components/Thread/Thread.tsx | 2 +- .../components/ThreadFooterComponent.tsx | 2 +- .../src/components/ThreadList/ThreadList.tsx | 2 +- .../components/ThreadList/ThreadListItem.tsx | 2 +- .../ThreadList/ThreadListUnreadBanner.tsx | 2 +- .../ThreadMessagePreviewDeliveryStatus.tsx | 2 +- package/src/components/ui/GiphyChip.tsx | 2 +- .../audioPlayerContext/AudioPlayerContext.tsx | 3 +- .../MessageComposerContext.tsx | 2 +- .../hooks/useActiveCommand.ts | 3 +- .../hooks/useAttachmentManagerState.ts | 3 +- .../hooks/useHasAttachments.ts | 3 +- .../hooks/useIsCommandDisabled.ts | 3 +- .../useMessageComposerHasSendableData.ts | 3 +- .../hooks/usePendingUploadsEnabled.ts | 3 +- .../hooks/__tests__/useStateStore.test.tsx | 109 ++++++++++++++++++ .../hooks/actions/useChannelActionItems.tsx | 2 +- .../actions/useChannelMemberActionItems.tsx | 2 +- package/src/hooks/index.ts | 2 +- .../useMessageDeliveryStatus.ts | 2 +- .../messagePreview/useMessagePreviewText.tsx | 2 +- package/src/hooks/useAttachmentPickerState.ts | 2 +- package/src/hooks/useChannelImage.ts | 3 +- package/src/hooks/useChannelMemberCount.ts | 3 +- .../src/hooks/useChannelMembershipState.ts | 3 +- package/src/hooks/useChannelName.ts | 3 +- .../src/hooks/useChannelOwnCapabilities.ts | 3 +- package/src/hooks/useClientNotifications.ts | 3 +- .../hooks/useDisplayedChannelMemberCount.ts | 3 +- .../src/hooks/useInAppNotificationsState.ts | 2 +- package/src/hooks/useIsTargetedMessage.ts | 3 +- package/src/hooks/useMessageReminder.ts | 3 +- .../src/hooks/usePendingAttachmentUpload.ts | 3 +- package/src/hooks/usePrunableMessageList.ts | 2 +- package/src/hooks/useQueryReminders.ts | 3 +- package/src/hooks/useStateStore.ts | 64 ---------- package/src/hooks/useStreami18n.ts | 2 +- .../state-store/edit-channel-details-store.ts | 2 +- .../src/state-store/message-overlay-store.ts | 3 +- package/src/state-store/selection-store.ts | 2 +- yarn.lock | 12 +- 124 files changed, 262 insertions(+), 215 deletions(-) create mode 100644 package/src/hooks/__tests__/useStateStore.test.tsx delete mode 100644 package/src/hooks/useStateStore.ts diff --git a/examples/SampleApp/package.json b/examples/SampleApp/package.json index c48a1f3327..d46ed0a572 100644 --- a/examples/SampleApp/package.json +++ b/examples/SampleApp/package.json @@ -44,7 +44,7 @@ "@react-navigation/native": "^7.5.0", "@react-navigation/native-stack": "^7.20.0", "@shopify/flash-list": "^2.3.3", - "@stream-io/state-store": "^1.2.0", + "@stream-io/state-store": "^1.3.1", "dayjs": "^1.11.23", "emoji-mart": "^5.6.0", "lodash.mergewith": "^4.6.2", diff --git a/package/package.json b/package/package.json index 5317fd7ec1..e3067b669c 100644 --- a/package/package.json +++ b/package/package.json @@ -74,7 +74,7 @@ "@gorhom/bottom-sheet": "^5.2.14", "@legendapp/list": "^3.7.1", "@stream-io/i18n": "^1.1.0", - "@stream-io/state-store": "^1.2.0", + "@stream-io/state-store": "^1.3.1", "@ungap/structured-clone": "^1.3.0", "dayjs": "^1.11.23", "emoji-regex": "^10.4.0", diff --git a/package/src/components/AITypingIndicatorView/hooks/useAIState.ts b/package/src/components/AITypingIndicatorView/hooks/useAIState.ts index 99406cb2bc..86ce980429 100644 --- a/package/src/components/AITypingIndicatorView/hooks/useAIState.ts +++ b/package/src/components/AITypingIndicatorView/hooks/useAIState.ts @@ -1,7 +1,6 @@ +import { useStateStore } from '@stream-io/state-store/react-bindings'; import { AIState, AIStates, Channel } from 'stream-chat'; -import { useStateStore } from '../../../hooks/useStateStore'; - // Re-exports `AIStates` from `stream-chat` so it can be imported from this module. export { AIStates }; diff --git a/package/src/components/Accessibility/OverlayA11yShield.tsx b/package/src/components/Accessibility/OverlayA11yShield.tsx index 0fae556fba..103d8c10ff 100644 --- a/package/src/components/Accessibility/OverlayA11yShield.tsx +++ b/package/src/components/Accessibility/OverlayA11yShield.tsx @@ -1,10 +1,11 @@ import React, { PropsWithChildren } from 'react'; import { Platform, StyleSheet, View } from 'react-native'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; + import { useAccessibilityServiceEnabled } from '../../a11y'; import { useAccessibilityContext } from '../../contexts/accessibilityContext/AccessibilityContext'; import { useOverlayContext } from '../../contexts/overlayContext/OverlayContext'; -import { useStateStore } from '../../hooks'; import { overlayStore } from '../../state-store/message-overlay-store'; const messageOverlayActiveSelector = (state: { id: string | undefined }) => ({ diff --git a/package/src/components/Attachment/Audio/AudioAttachment.tsx b/package/src/components/Attachment/Audio/AudioAttachment.tsx index 36cdef90b3..2232b3f4bc 100644 --- a/package/src/components/Attachment/Audio/AudioAttachment.tsx +++ b/package/src/components/Attachment/Audio/AudioAttachment.tsx @@ -1,6 +1,7 @@ import React, { RefObject, useEffect, useMemo } from 'react'; import { I18nManager, StyleProp, StyleSheet, Text, TextStyle, View, ViewStyle } from 'react-native'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import dayjs from 'dayjs'; import duration from 'dayjs/plugin/duration'; @@ -17,7 +18,6 @@ import { PlayPauseButton } from './PlayPauseButton'; import { useChannelContext, useChatConfigContext, useTheme } from '../../../contexts'; import { useStableCallback } from '../../../hooks'; -import { useStateStore } from '../../../hooks'; import { useAudioPlayer } from '../../../hooks/useAudioPlayer'; import { NativeHandlers, diff --git a/package/src/components/AttachmentPicker/components/AttachmentMediaPicker/AttachmentPickerItem.tsx b/package/src/components/AttachmentPicker/components/AttachmentMediaPicker/AttachmentPickerItem.tsx index bd1a1a0f14..faa760bd99 100644 --- a/package/src/components/AttachmentPicker/components/AttachmentMediaPicker/AttachmentPickerItem.tsx +++ b/package/src/components/AttachmentPicker/components/AttachmentMediaPicker/AttachmentPickerItem.tsx @@ -2,6 +2,7 @@ import React, { useCallback } from 'react'; import { Alert, Image, StyleSheet, Text, View } from 'react-native'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import { AttachmentManagerState, FileReference, @@ -19,7 +20,6 @@ import { useMessageComposer } from '../../../../contexts/messageInputContext/hoo import { useMessageInputContext } from '../../../../contexts/messageInputContext/MessageInputContext'; import { useTheme } from '../../../../contexts/themeContext/ThemeContext'; import { useTranslationContext } from '../../../../contexts/translationContext/TranslationContext'; -import { useStateStore } from '../../../../hooks/useStateStore'; import { useWindowContentWidth } from '../../../../hooks/useWindowContentWidth'; import { NativeHandlers } from '../../../../native'; import { primitives } from '../../../../theme'; diff --git a/package/src/components/AttachmentPicker/components/AttachmentPickerContent.tsx b/package/src/components/AttachmentPicker/components/AttachmentPickerContent.tsx index 54a73321c0..af08907163 100644 --- a/package/src/components/AttachmentPicker/components/AttachmentPickerContent.tsx +++ b/package/src/components/AttachmentPicker/components/AttachmentPickerContent.tsx @@ -3,6 +3,7 @@ import { Linking, Platform, Pressable, StyleSheet, Text } from 'react-native'; import { FlatList } from 'react-native-gesture-handler'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import { CommandSearchSource, CommandSuggestion, notifyCommandDisabled } from 'stream-chat'; import { AttachmentMediaPicker } from './AttachmentMediaPicker/AttachmentMediaPicker'; @@ -22,7 +23,6 @@ import { import { useComponentsContext } from '../../../contexts/componentsContext/ComponentsContext'; import { useTheme } from '../../../contexts/themeContext/ThemeContext'; import { useAttachmentPickerState, useStableCallback } from '../../../hooks'; -import { useStateStore } from '../../../hooks/useStateStore'; import { primitives } from '../../../theme'; import { CommandSuggestionItem } from '../../AutoCompleteInput/AutoCompleteSuggestionItem'; diff --git a/package/src/components/AutoCompleteInput/AutoCompleteInput.tsx b/package/src/components/AutoCompleteInput/AutoCompleteInput.tsx index 3922fce66e..1e18ea4c3b 100644 --- a/package/src/components/AutoCompleteInput/AutoCompleteInput.tsx +++ b/package/src/components/AutoCompleteInput/AutoCompleteInput.tsx @@ -10,6 +10,7 @@ import { import Animated from 'react-native-reanimated'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import { MessageComposerConfig, TextComposerState } from 'stream-chat'; import { useAnimationsContext } from '../../contexts/animationsContext/AnimationsContext'; @@ -27,7 +28,6 @@ import { } from '../../contexts/translationContext/TranslationContext'; import { useStableCallback } from '../../hooks'; -import { useStateStore } from '../../hooks/useStateStore'; import type { TextInputRef } from '../../types/react-native-compat'; import { useCooldownRemaining } from '../MessageInput/hooks/useCooldownRemaining'; diff --git a/package/src/components/AutoCompleteInput/AutoCompleteSuggestionList.tsx b/package/src/components/AutoCompleteInput/AutoCompleteSuggestionList.tsx index 55a27c86c9..17b71e0858 100644 --- a/package/src/components/AutoCompleteInput/AutoCompleteSuggestionList.tsx +++ b/package/src/components/AutoCompleteInput/AutoCompleteSuggestionList.tsx @@ -5,6 +5,7 @@ import { FlatList } from 'react-native-gesture-handler'; import Animated, { ZoomIn, ZoomOut } from 'react-native-reanimated'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import { SearchSourceState, TextComposerState, TextComposerSuggestion } from 'stream-chat'; import { useA11yLabel } from '../../a11y/hooks/useA11yLabel'; @@ -14,7 +15,6 @@ import { useComponentsContext } from '../../contexts/componentsContext/Component import { useMessageComposer } from '../../contexts/messageInputContext/hooks/useMessageComposer'; import { useTheme } from '../../contexts/themeContext/ThemeContext'; import { useStableCallback } from '../../hooks'; -import { useStateStore } from '../../hooks/useStateStore'; import { primitives } from '../../theme'; import { ClippingFadeBottom } from '../UIComponents/ClippingFadeBottom'; diff --git a/package/src/components/Channel/Channel.tsx b/package/src/components/Channel/Channel.tsx index 75c3573e6e..6de4c52592 100644 --- a/package/src/components/Channel/Channel.tsx +++ b/package/src/components/Channel/Channel.tsx @@ -1,6 +1,8 @@ import React, { PropsWithChildren, useMemo } from 'react'; import { StyleSheet, Text } from 'react-native'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; + import { ChannelConfigProps, ChannelShell } from './ChannelShell'; import { useChannelLifecycle } from './hooks/useChannelLifecycle'; @@ -14,7 +16,6 @@ import { TranslationContextValue, useTranslationContext, } from '../../contexts/translationContext/TranslationContext'; -import { useStateStore } from '../../hooks/useStateStore'; import { primitives } from '../../theme'; import { getChannelNotificationHostId } from '../Notifications/notificationTarget'; diff --git a/package/src/components/Channel/ChannelShell.tsx b/package/src/components/Channel/ChannelShell.tsx index 81962b36e6..c11d4391b4 100644 --- a/package/src/components/Channel/ChannelShell.tsx +++ b/package/src/components/Channel/ChannelShell.tsx @@ -1,6 +1,7 @@ import React, { PropsWithChildren, useCallback, useMemo, useState } from 'react'; import { View } from 'react-native'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import type { Channel, ChannelConfig, @@ -43,7 +44,6 @@ import { import { useStableCallback } from '../../hooks'; import { useAppStateListener } from '../../hooks/useAppStateListener'; import { useAttachmentPickerBottomSheet } from '../../hooks/useAttachmentPickerBottomSheet'; -import { useStateStore } from '../../hooks/useStateStore'; import { isDocumentPickerAvailable, isImageMediaLibraryAvailable, diff --git a/package/src/components/Channel/hooks/useCreateOwnCapabilitiesContext.ts b/package/src/components/Channel/hooks/useCreateOwnCapabilitiesContext.ts index 766c696b2e..5456c08b45 100644 --- a/package/src/components/Channel/hooks/useCreateOwnCapabilitiesContext.ts +++ b/package/src/components/Channel/hooks/useCreateOwnCapabilitiesContext.ts @@ -1,5 +1,6 @@ import { useMemo } from 'react'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import type { Channel, OwnCapabilitiesState } from 'stream-chat'; import { @@ -7,7 +8,6 @@ import { OwnCapabilitiesContextValue, OwnCapability, } from '../../../contexts/ownCapabilitiesContext/OwnCapabilitiesContext'; -import { useStateStore } from '../../../hooks/useStateStore'; // TODO: Move own_capabilities as part of channel state rather than having to do // stuff like this. diff --git a/package/src/components/Channel/hooks/useSupersededChannelSwap.ts b/package/src/components/Channel/hooks/useSupersededChannelSwap.ts index bf9b1c7443..bfe761a494 100644 --- a/package/src/components/Channel/hooks/useSupersededChannelSwap.ts +++ b/package/src/components/Channel/hooks/useSupersededChannelSwap.ts @@ -1,7 +1,6 @@ +import { useStateStore } from '@stream-io/state-store/react-bindings'; import type { Channel, ChannelStateData, EditingAuditState } from 'stream-chat'; -import { useStateStore } from '../../../hooks/useStateStore'; - const supersededBySelector = ({ supersededBy }: ChannelStateData) => ({ supersededBy }); const activeSelector = ({ active }: ChannelStateData) => ({ active }); const editingAuditStateSelector = (state: EditingAuditState) => state; diff --git a/package/src/components/ChannelDetails/components/ChannelEditDetailsFormContent.tsx b/package/src/components/ChannelDetails/components/ChannelEditDetailsFormContent.tsx index e0a0fab75b..9b4c7d358a 100644 --- a/package/src/components/ChannelDetails/components/ChannelEditDetailsFormContent.tsx +++ b/package/src/components/ChannelDetails/components/ChannelEditDetailsFormContent.tsx @@ -1,12 +1,13 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react'; import { StyleSheet, View } from 'react-native'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; + import { useChannelDetailsContext } from '../../../contexts/channelDetailsContext/channelDetailsContext'; import { useChannelEditDetailsContext } from '../../../contexts/channelEditDetailsContext/ChannelEditDetailsContext'; import { useComponentsContext } from '../../../contexts/componentsContext/ComponentsContext'; import { useTheme } from '../../../contexts/themeContext/ThemeContext'; import { useTranslationContext } from '../../../contexts/translationContext/TranslationContext'; -import { useStateStore } from '../../../hooks/useStateStore'; import type { EditChannelDetailsState } from '../../../state-store/edit-channel-details-store'; import { primitives } from '../../../theme'; import { ChannelAvatar } from '../../ui/Avatar/ChannelAvatar'; diff --git a/package/src/components/ChannelDetails/components/ChannelEditImageSheet.tsx b/package/src/components/ChannelDetails/components/ChannelEditImageSheet.tsx index 7618e5680b..3e26477b84 100644 --- a/package/src/components/ChannelDetails/components/ChannelEditImageSheet.tsx +++ b/package/src/components/ChannelDetails/components/ChannelEditImageSheet.tsx @@ -9,12 +9,13 @@ import { ViewStyle, } from 'react-native'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; + import { useBottomSheetContext } from '../../../contexts'; import { useChannelEditDetailsContext } from '../../../contexts/channelEditDetailsContext/ChannelEditDetailsContext'; import { useComponentsContext } from '../../../contexts/componentsContext/ComponentsContext'; import { useTheme } from '../../../contexts/themeContext/ThemeContext'; import { useTranslationContext } from '../../../contexts/translationContext/TranslationContext'; -import { useStateStore } from '../../../hooks/useStateStore'; import type { IconProps } from '../../../icons/utils/base'; import type { EditChannelDetailsState, diff --git a/package/src/components/ChannelDetails/components/ChannelEditName.tsx b/package/src/components/ChannelDetails/components/ChannelEditName.tsx index adc34c11b4..97a971271d 100644 --- a/package/src/components/ChannelDetails/components/ChannelEditName.tsx +++ b/package/src/components/ChannelDetails/components/ChannelEditName.tsx @@ -1,9 +1,10 @@ import React, { useCallback } from 'react'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; + import { useChannelEditDetailsContext } from '../../../contexts/channelEditDetailsContext/ChannelEditDetailsContext'; import { useTheme } from '../../../contexts/themeContext/ThemeContext'; import { useTranslationContext } from '../../../contexts/translationContext/TranslationContext'; -import { useStateStore } from '../../../hooks/useStateStore'; import type { EditChannelDetailsState } from '../../../state-store/edit-channel-details-store'; import { Input } from '../../ui/Input/Input'; diff --git a/package/src/components/ChannelDetails/components/members/ChannelAddMembersFormContent.tsx b/package/src/components/ChannelDetails/components/members/ChannelAddMembersFormContent.tsx index ae2be72daa..dcecb5112c 100644 --- a/package/src/components/ChannelDetails/components/members/ChannelAddMembersFormContent.tsx +++ b/package/src/components/ChannelDetails/components/members/ChannelAddMembersFormContent.tsx @@ -1,6 +1,7 @@ import React, { useCallback, useEffect, useMemo, useRef } from 'react'; import { ActivityIndicator, FlatList, type FlatListProps, StyleSheet, View } from 'react-native'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import type { SearchSourceState, UserResponse } from 'stream-chat'; import { AddMemberSearchResultItem } from './AddMemberSearchResultItem'; @@ -11,7 +12,6 @@ import { useChannelDetailsContext } from '../../../../contexts/channelDetailsCon import { useTheme } from '../../../../contexts/themeContext/ThemeContext'; import { useTranslationContext } from '../../../../contexts/translationContext/TranslationContext'; import { getNotificationErrorOptions } from '../../../../hooks/actions/useChannelActions'; -import { useStateStore } from '../../../../hooks/useStateStore'; import { primitives } from '../../../../theme'; import { useNotificationApi } from '../../../Notifications/hooks/useNotificationApi'; import { EmptySearchResult } from '../../../UIComponents/EmptySearchResult'; diff --git a/package/src/components/ChannelDetails/components/members/ChannelMemberList.tsx b/package/src/components/ChannelDetails/components/members/ChannelMemberList.tsx index 607c77ce58..a3b3723d6b 100644 --- a/package/src/components/ChannelDetails/components/members/ChannelMemberList.tsx +++ b/package/src/components/ChannelDetails/components/members/ChannelMemberList.tsx @@ -1,6 +1,7 @@ import React, { useCallback, useEffect, useState } from 'react'; import { ActivityIndicator, FlatList, type FlatListProps, StyleSheet, View } from 'react-native'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import type { ChannelMemberResponse, ChannelMemberSearchSource, @@ -19,7 +20,6 @@ import { useTheme } from '../../../../contexts/themeContext/ThemeContext'; import { useTranslationContext } from '../../../../contexts/translationContext/TranslationContext'; import { getNotificationErrorOptions } from '../../../../hooks/actions/useChannelActions'; import { useChannelMemberCount } from '../../../../hooks/useChannelMemberCount'; -import { useStateStore } from '../../../../hooks/useStateStore'; import { primitives } from '../../../../theme'; import { useNotificationApi } from '../../../Notifications/hooks/useNotificationApi'; import { NotificationList } from '../../../Notifications/NotificationList'; diff --git a/package/src/components/ChannelDetails/components/navigation-section/FileAttachmentList.tsx b/package/src/components/ChannelDetails/components/navigation-section/FileAttachmentList.tsx index 5f8c608dd8..0b52751b81 100644 --- a/package/src/components/ChannelDetails/components/navigation-section/FileAttachmentList.tsx +++ b/package/src/components/ChannelDetails/components/navigation-section/FileAttachmentList.tsx @@ -7,6 +7,7 @@ import { View, } from 'react-native'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import type { MessageResponse, MessageSearchSource, SearchSourceState } from 'stream-chat'; import { FileAttachmentListLoadingSkeleton } from './FileAttachmentListLoadingSkeleton'; @@ -21,7 +22,6 @@ import { useComponentsContext } from '../../../../contexts/componentsContext/Com import { useTheme } from '../../../../contexts/themeContext/ThemeContext'; import { useTranslationContext } from '../../../../contexts/translationContext/TranslationContext'; import { getNotificationErrorOptions } from '../../../../hooks/actions/useChannelActions'; -import { useStateStore } from '../../../../hooks/useStateStore'; import { primitives } from '../../../../theme'; import { useNotificationApi } from '../../../Notifications/hooks/useNotificationApi'; import { NotificationList } from '../../../Notifications/NotificationList'; diff --git a/package/src/components/ChannelDetails/components/navigation-section/MediaList.tsx b/package/src/components/ChannelDetails/components/navigation-section/MediaList.tsx index 70b944f229..188ac7f4e3 100644 --- a/package/src/components/ChannelDetails/components/navigation-section/MediaList.tsx +++ b/package/src/components/ChannelDetails/components/navigation-section/MediaList.tsx @@ -1,6 +1,7 @@ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { ActivityIndicator, FlatList, type FlatListProps, StyleSheet, View } from 'react-native'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import { formatMessage, type MessageResponse, @@ -22,7 +23,6 @@ import { useOverlayContext } from '../../../../contexts/overlayContext/OverlayCo import { useTheme } from '../../../../contexts/themeContext/ThemeContext'; import { useTranslationContext } from '../../../../contexts/translationContext/TranslationContext'; import { getNotificationErrorOptions } from '../../../../hooks/actions/useChannelActions'; -import { useStateStore } from '../../../../hooks/useStateStore'; import { useWindowContentWidth } from '../../../../hooks/useWindowContentWidth'; import { isVideoPlayerAvailable } from '../../../../native'; import { primitives } from '../../../../theme'; diff --git a/package/src/components/ChannelDetails/components/navigation-section/PinnedMessageList.tsx b/package/src/components/ChannelDetails/components/navigation-section/PinnedMessageList.tsx index 180fd8b896..11a11e6e78 100644 --- a/package/src/components/ChannelDetails/components/navigation-section/PinnedMessageList.tsx +++ b/package/src/components/ChannelDetails/components/navigation-section/PinnedMessageList.tsx @@ -1,6 +1,7 @@ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { ActivityIndicator, FlatList, type FlatListProps, StyleSheet, View } from 'react-native'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import type { MessageResponse, MessageSearchSource, SearchSourceState } from 'stream-chat'; import { PinnedMessageListLoadingSkeleton } from './PinnedMessageListLoadingSkeleton'; @@ -14,7 +15,6 @@ import { useComponentsContext } from '../../../../contexts/componentsContext/Com import { useTheme } from '../../../../contexts/themeContext/ThemeContext'; import { useTranslationContext } from '../../../../contexts/translationContext/TranslationContext'; import { getNotificationErrorOptions } from '../../../../hooks/actions/useChannelActions'; -import { useStateStore } from '../../../../hooks/useStateStore'; import { primitives } from '../../../../theme'; import { useNotificationApi } from '../../../Notifications/hooks/useNotificationApi'; import { NotificationList } from '../../../Notifications/NotificationList'; diff --git a/package/src/components/ChannelList/hooks/useChannelMembersState.ts b/package/src/components/ChannelList/hooks/useChannelMembersState.ts index 2d9945cd23..6cc0a4bd1f 100644 --- a/package/src/components/ChannelList/hooks/useChannelMembersState.ts +++ b/package/src/components/ChannelList/hooks/useChannelMembersState.ts @@ -1,9 +1,8 @@ import { useMemo } from 'react'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import type { Channel, ChannelMemberResponse } from 'stream-chat'; -import { useStateStore } from '../../../hooks/useStateStore'; - type MembersState = { members: Record }; /** Picks the member fields a caller reads. Define it at module scope to keep it stable. */ diff --git a/package/src/components/ChannelList/hooks/useChannelOnlineMemberCount.ts b/package/src/components/ChannelList/hooks/useChannelOnlineMemberCount.ts index 6bbbce7fc1..0726f5b744 100644 --- a/package/src/components/ChannelList/hooks/useChannelOnlineMemberCount.ts +++ b/package/src/components/ChannelList/hooks/useChannelOnlineMemberCount.ts @@ -1,7 +1,6 @@ +import { useStateStore } from '@stream-io/state-store/react-bindings'; import type { Channel } from 'stream-chat'; -import { useStateStore } from '../../../hooks/useStateStore'; - const selector = (state: { watcherCount: number }) => ({ watcherCount: state.watcherCount }); /** diff --git a/package/src/components/ChannelList/hooks/useMutedUsers.ts b/package/src/components/ChannelList/hooks/useMutedUsers.ts index 20ecfa4ffb..8e28c0695a 100644 --- a/package/src/components/ChannelList/hooks/useMutedUsers.ts +++ b/package/src/components/ChannelList/hooks/useMutedUsers.ts @@ -1,7 +1,7 @@ +import { useStateStore } from '@stream-io/state-store/react-bindings'; import type { UserMuteResponse } from 'stream-chat'; import { useChatContext } from '../../../contexts'; -import { useStateStore } from '../../../hooks/useStateStore'; const selector = (state: { mutedUsers: UserMuteResponse[] }) => ({ mutedUsers: state.mutedUsers }); diff --git a/package/src/components/ChannelList/hooks/usePaginatedChannels.ts b/package/src/components/ChannelList/hooks/usePaginatedChannels.ts index dad4468788..d947b9e8ca 100644 --- a/package/src/components/ChannelList/hooks/usePaginatedChannels.ts +++ b/package/src/components/ChannelList/hooks/usePaginatedChannels.ts @@ -1,9 +1,9 @@ import { useEffect, useRef, useState } from 'react'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import type { ChannelPaginator, ChannelPaginatorState } from 'stream-chat'; import { useChatContext } from '../../../contexts/chatContext/ChatContext'; -import { useStateStore } from '../../../hooks'; import { useStableCallback } from '../../../hooks/useStableCallback'; import { useClientUserId } from '../../Chat/hooks/useClientUserId'; diff --git a/package/src/components/ChannelPreview/ChannelMessagePreviewDeliveryStatus.tsx b/package/src/components/ChannelPreview/ChannelMessagePreviewDeliveryStatus.tsx index 430d6a2c5f..159636fa09 100644 --- a/package/src/components/ChannelPreview/ChannelMessagePreviewDeliveryStatus.tsx +++ b/package/src/components/ChannelPreview/ChannelMessagePreviewDeliveryStatus.tsx @@ -1,6 +1,7 @@ import React, { useMemo } from 'react'; import { StyleSheet, Text, View } from 'react-native'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import { ChannelConfig, LocalMessage, MessageResponse } from 'stream-chat'; import { ChannelPreviewProps } from './ChannelPreview'; @@ -11,7 +12,6 @@ import { useComponentsContext } from '../../contexts/componentsContext/Component import { useTheme } from '../../contexts/themeContext/ThemeContext'; import { useTranslationContext } from '../../contexts/translationContext/TranslationContext'; import { MessageDeliveryStatus, useMessageDeliveryStatus } from '../../hooks'; -import { useStateStore } from '../../hooks/useStateStore'; import { primitives } from '../../theme'; import { MessageStatusTypes } from '../../utils/utils'; import { CompositeAccessibilityProbe } from '../Accessibility/CompositeAccessibilityProbe'; diff --git a/package/src/components/ChannelPreview/hooks/useChannelPreviewData.ts b/package/src/components/ChannelPreview/hooks/useChannelPreviewData.ts index 5322479303..df5c0283a1 100644 --- a/package/src/components/ChannelPreview/hooks/useChannelPreviewData.ts +++ b/package/src/components/ChannelPreview/hooks/useChannelPreviewData.ts @@ -1,5 +1,6 @@ import { useCallback, useEffect } from 'react'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import type { Channel, LocalMessage, @@ -11,8 +12,6 @@ import type { StreamChat, } from 'stream-chat'; -import { useStateStore } from '../../../hooks'; - export type LastMessageType = LocalMessage | MessageResponse; // The latest message comes from the paginator's `aggregateState`, which stays current when a new diff --git a/package/src/components/ChannelPreview/hooks/useChannelPreviewDraftMessage.ts b/package/src/components/ChannelPreview/hooks/useChannelPreviewDraftMessage.ts index 3f12319a25..0dd9de529d 100644 --- a/package/src/components/ChannelPreview/hooks/useChannelPreviewDraftMessage.ts +++ b/package/src/components/ChannelPreview/hooks/useChannelPreviewDraftMessage.ts @@ -1,9 +1,8 @@ import { useMemo } from 'react'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import { AttachmentManagerState, Channel, DraftMessage, TextComposerState } from 'stream-chat'; -import { useStateStore } from '../../../hooks/useStateStore'; - const textComposerStateSelector = (state: TextComposerState) => ({ text: state.text, }); diff --git a/package/src/components/ChannelPreview/hooks/useChannelPreviewPollLabel.ts b/package/src/components/ChannelPreview/hooks/useChannelPreviewPollLabel.ts index a52a64d7a6..de2e96c339 100644 --- a/package/src/components/ChannelPreview/hooks/useChannelPreviewPollLabel.ts +++ b/package/src/components/ChannelPreview/hooks/useChannelPreviewPollLabel.ts @@ -1,10 +1,10 @@ import { useMemo } from 'react'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import { PollState } from 'stream-chat'; import { useChatContext } from '../../../contexts/chatContext/ChatContext'; import { useTranslationContext } from '../../../contexts/translationContext/TranslationContext'; -import { useStateStore } from '../../../hooks/useStateStore'; import { getTranslatedText } from '../../../utils/i18n/getTranslatedText'; export type UseChannelPreviewPollLabelProps = { diff --git a/package/src/components/ChannelPreview/hooks/useIsChannelMuted.ts b/package/src/components/ChannelPreview/hooks/useIsChannelMuted.ts index 1a584e9413..7eb9792c5a 100644 --- a/package/src/components/ChannelPreview/hooks/useIsChannelMuted.ts +++ b/package/src/components/ChannelPreview/hooks/useIsChannelMuted.ts @@ -1,7 +1,6 @@ +import { useStateStore } from '@stream-io/state-store/react-bindings'; import type { Channel, ChannelMuteStatus } from 'stream-chat'; -import { useStateStore } from '../../../hooks/useStateStore'; - const defaultMuteStatus = { createdAt: null, expiresAt: null, diff --git a/package/src/components/Chat/Chat.tsx b/package/src/components/Chat/Chat.tsx index 547ea99cbc..7b3ce6acef 100644 --- a/package/src/components/Chat/Chat.tsx +++ b/package/src/components/Chat/Chat.tsx @@ -1,6 +1,7 @@ import React, { PropsWithChildren, useEffect, useMemo, useState } from 'react'; import { Platform } from 'react-native'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import type { OfflineDBState } from 'stream-chat'; import { useAppSettingsGetter } from './hooks/useAppSettingsGetter'; @@ -17,7 +18,6 @@ import { DEFAULT_USER_LANGUAGE, TranslationProvider, } from '../../contexts/translationContext/TranslationContext'; -import { useStateStore } from '../../hooks'; import { useStreami18n } from '../../hooks/useStreami18n'; import init from '../../init'; diff --git a/package/src/components/Chat/hooks/useNetworkConnectionState.ts b/package/src/components/Chat/hooks/useNetworkConnectionState.ts index b59c0f8f73..243e5c5b69 100644 --- a/package/src/components/Chat/hooks/useNetworkConnectionState.ts +++ b/package/src/components/Chat/hooks/useNetworkConnectionState.ts @@ -1,7 +1,7 @@ +import { useStateStore } from '@stream-io/state-store/react-bindings'; import type { NetworkConnectionState } from 'stream-chat'; import { useChatContext } from '../../../contexts/chatContext/ChatContext'; -import { useStateStore } from '../../../hooks/useStateStore'; const identity = (state: NetworkConnectionState) => state; diff --git a/package/src/components/Chat/hooks/useWSConnectionState.ts b/package/src/components/Chat/hooks/useWSConnectionState.ts index bdf14222e4..607e8ac968 100644 --- a/package/src/components/Chat/hooks/useWSConnectionState.ts +++ b/package/src/components/Chat/hooks/useWSConnectionState.ts @@ -1,9 +1,9 @@ import { useEffect, useState } from 'react'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import type { NetworkConnectionState, WSConnectionConfig, WSConnectionState } from 'stream-chat'; import { useChatContext } from '../../../contexts/chatContext/ChatContext'; -import { useStateStore } from '../../../hooks/useStateStore'; const identity = (state: WSConnectionState) => state; const healthSelector = (state: WSConnectionState) => ({ diff --git a/package/src/components/ImageGallery/ImageGallery.tsx b/package/src/components/ImageGallery/ImageGallery.tsx index e5fadb5701..adcb6215ca 100644 --- a/package/src/components/ImageGallery/ImageGallery.tsx +++ b/package/src/components/ImageGallery/ImageGallery.tsx @@ -12,6 +12,8 @@ import Animated, { withTiming, } from 'react-native-reanimated'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; + import { AnimatedGalleryImage } from './components/AnimatedGalleryImage'; import { AnimatedGalleryVideo } from './components/AnimatedGalleryVideo'; import { ImageGalleryA11yProbe } from './components/ImageGalleryA11yProbe'; @@ -35,7 +37,6 @@ import { useOverlayContext, } from '../../contexts/overlayContext/OverlayContext'; import { useTheme } from '../../contexts/themeContext/ThemeContext'; -import { useStateStore } from '../../hooks'; import { useViewport } from '../../hooks/useViewport'; import { IconProps } from '../../icons/utils/base'; import { ImageGalleryState } from '../../state-store/image-gallery-state-store'; diff --git a/package/src/components/ImageGallery/components/AnimatedGalleryImage.tsx b/package/src/components/ImageGallery/components/AnimatedGalleryImage.tsx index 50c323235f..24c34bc50e 100644 --- a/package/src/components/ImageGallery/components/AnimatedGalleryImage.tsx +++ b/package/src/components/ImageGallery/components/AnimatedGalleryImage.tsx @@ -3,9 +3,10 @@ import { StyleSheet, View } from 'react-native'; import type { ImageStyle, StyleProp } from 'react-native'; import Animated, { SharedValue } from 'react-native-reanimated'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; + import { useChatConfigContext } from '../../../contexts/chatConfigContext/ChatConfigContext'; import { useImageGalleryContext } from '../../../contexts/imageGalleryContext/ImageGalleryContext'; -import { useStateStore } from '../../../hooks'; import { useIsSvg } from '../../../hooks/useIsSvg'; import { ImageGalleryAsset, diff --git a/package/src/components/ImageGallery/components/AnimatedGalleryVideo.tsx b/package/src/components/ImageGallery/components/AnimatedGalleryVideo.tsx index 48c9eea580..f68b23db75 100644 --- a/package/src/components/ImageGallery/components/AnimatedGalleryVideo.tsx +++ b/package/src/components/ImageGallery/components/AnimatedGalleryVideo.tsx @@ -3,9 +3,11 @@ import { StyleSheet, View, ViewStyle } from 'react-native'; import type { StyleProp } from 'react-native'; import Animated, { SharedValue } from 'react-native-reanimated'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; + import { useChatConfigContext } from '../../../contexts/chatConfigContext/ChatConfigContext'; import { useImageGalleryContext } from '../../../contexts/imageGalleryContext/ImageGalleryContext'; -import { useStableCallback, useStateStore } from '../../../hooks'; +import { useStableCallback } from '../../../hooks'; import { isVideoPlayerAvailable, diff --git a/package/src/components/ImageGallery/components/ImageGalleryA11yProbe.tsx b/package/src/components/ImageGallery/components/ImageGalleryA11yProbe.tsx index 63d7bb78e1..e8bdf94387 100644 --- a/package/src/components/ImageGallery/components/ImageGalleryA11yProbe.tsx +++ b/package/src/components/ImageGallery/components/ImageGalleryA11yProbe.tsx @@ -2,9 +2,10 @@ import React, { useCallback, useMemo } from 'react'; import { StyleSheet, ViewStyle } from 'react-native'; import Animated, { AnimatedStyle } from 'react-native-reanimated'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; + import { useA11yLabel } from '../../../a11y/hooks/useA11yLabel'; import { useImageGalleryContext } from '../../../contexts/imageGalleryContext/ImageGalleryContext'; -import { useStateStore } from '../../../hooks'; import { ImageGalleryState } from '../../../state-store/image-gallery-state-store'; const a11ySelector = (state: ImageGalleryState) => ({ diff --git a/package/src/components/ImageGallery/components/ImageGalleryFooter.tsx b/package/src/components/ImageGallery/components/ImageGalleryFooter.tsx index 40322153f4..ba793e0a95 100644 --- a/package/src/components/ImageGallery/components/ImageGalleryFooter.tsx +++ b/package/src/components/ImageGallery/components/ImageGalleryFooter.tsx @@ -2,13 +2,14 @@ import React, { useMemo, useRef, useState } from 'react'; import { ActivityIndicator, StyleSheet, Text, View, ViewStyle } from 'react-native'; import Animated, { Extrapolation, interpolate, useAnimatedStyle } from 'react-native-reanimated'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; + import type { ImageGalleryFooterProps, ImageGalleryVideoControlProps } from './types'; import { useComponentsContext } from '../../../contexts/componentsContext/ComponentsContext'; import { useImageGalleryContext } from '../../../contexts/imageGalleryContext/ImageGalleryContextBase'; import { useTheme } from '../../../contexts/themeContext/ThemeContext'; import { useTranslationContext } from '../../../contexts/translationContext/TranslationContext'; -import { useStateStore } from '../../../hooks/useStateStore'; import { isFileSystemAvailable, isShareImageAvailable, NativeHandlers } from '../../../native'; import { ImageGalleryState } from '../../../state-store/image-gallery-state-store'; diff --git a/package/src/components/ImageGallery/components/ImageGalleryHeader.tsx b/package/src/components/ImageGallery/components/ImageGalleryHeader.tsx index ac183cd8e7..b5faabed6d 100644 --- a/package/src/components/ImageGallery/components/ImageGalleryHeader.tsx +++ b/package/src/components/ImageGallery/components/ImageGalleryHeader.tsx @@ -5,6 +5,8 @@ import { StyleSheet, Text, View, ViewStyle } from 'react-native'; import Animated, { Extrapolation, interpolate, useAnimatedStyle } from 'react-native-reanimated'; import { SafeAreaInsetsContext } from 'react-native-safe-area-context'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; + import type { ImageGalleryHeaderProps } from './types'; import { useComponentsContext } from '../../../contexts/componentsContext/ComponentsContext'; @@ -12,7 +14,6 @@ import { useImageGalleryContext } from '../../../contexts/imageGalleryContext/Im import { useOverlayContext } from '../../../contexts/overlayContext/OverlayContext'; import { useTheme } from '../../../contexts/themeContext/ThemeContext'; import { useTranslationContext } from '../../../contexts/translationContext/TranslationContext'; -import { useStateStore } from '../../../hooks/useStateStore'; import { getDateString } from '../../../i18n/utils'; import { ImageGalleryState } from '../../../state-store/image-gallery-state-store'; diff --git a/package/src/components/ImageGallery/components/ImageGalleryVideoControl.tsx b/package/src/components/ImageGallery/components/ImageGalleryVideoControl.tsx index 22a7fc6add..8e97f2da0e 100644 --- a/package/src/components/ImageGallery/components/ImageGalleryVideoControl.tsx +++ b/package/src/components/ImageGallery/components/ImageGalleryVideoControl.tsx @@ -1,13 +1,14 @@ import React, { useCallback, useMemo, useRef } from 'react'; import { StyleSheet, Text, View } from 'react-native'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; + import type { ImageGalleryVideoControlProps } from './types'; import { useComponentsContext } from '../../../contexts/componentsContext/ComponentsContext'; import { useTheme } from '../../../contexts/themeContext/ThemeContext'; import { useStableCallback } from '../../../hooks/useStableCallback'; -import { useStateStore } from '../../../hooks/useStateStore'; import { IconProps } from '../../../icons/utils/base'; import { VideoPlayerState } from '../../../state-store/video-player'; import { primitives } from '../../../theme'; diff --git a/package/src/components/ImageGallery/components/ImageGrid.tsx b/package/src/components/ImageGallery/components/ImageGrid.tsx index ee34e6828d..a6956fbc04 100644 --- a/package/src/components/ImageGallery/components/ImageGrid.tsx +++ b/package/src/components/ImageGallery/components/ImageGrid.tsx @@ -1,11 +1,12 @@ import React, { useMemo } from 'react'; import { Image, Pressable, StyleSheet, View } from 'react-native'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; + import type { ImageGalleryGridProps } from './types'; import { useImageGalleryContext } from '../../../contexts/imageGalleryContext/ImageGalleryContextBase'; import { useTheme } from '../../../contexts/themeContext/ThemeContext'; -import { useStateStore } from '../../../hooks/useStateStore'; import { useWindowContentWidth } from '../../../hooks/useWindowContentWidth'; import type { ImageGalleryAsset, diff --git a/package/src/components/Message/MessageItemView/Headers/MessageReminderHeader.tsx b/package/src/components/Message/MessageItemView/Headers/MessageReminderHeader.tsx index 39f9da695a..525a1fa27d 100644 --- a/package/src/components/Message/MessageItemView/Headers/MessageReminderHeader.tsx +++ b/package/src/components/Message/MessageItemView/Headers/MessageReminderHeader.tsx @@ -2,6 +2,7 @@ import React, { useMemo } from 'react'; import { StyleSheet, Text, View } from 'react-native'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import { ReminderState } from 'stream-chat'; import { useComponentsContext } from '../../../../contexts/componentsContext/ComponentsContext'; @@ -9,7 +10,6 @@ import { useMessageContext } from '../../../../contexts/messageContext/MessageCo import { useTheme } from '../../../../contexts/themeContext/ThemeContext'; import { useTranslationContext } from '../../../../contexts/translationContext/TranslationContext'; import { useMessageReminder } from '../../../../hooks/useMessageReminder'; -import { useStateStore } from '../../../../hooks/useStateStore'; import { primitives } from '../../../../theme'; import { useShouldUseOverlayStyles } from '../../hooks/useShouldUseOverlayStyles'; diff --git a/package/src/components/Message/MessageItemView/MessageFooter.tsx b/package/src/components/Message/MessageItemView/MessageFooter.tsx index d49dcb2450..bdcac58e4e 100644 --- a/package/src/components/Message/MessageItemView/MessageFooter.tsx +++ b/package/src/components/Message/MessageItemView/MessageFooter.tsx @@ -1,6 +1,7 @@ import React, { useMemo } from 'react'; import { StyleSheet, Text, View } from 'react-native'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import type { Attachment, LocalMessage } from 'stream-chat'; import { useChannelContext } from '../../../contexts/channelContext/ChannelContext'; @@ -15,7 +16,6 @@ import { import { useTheme } from '../../../contexts/themeContext/ThemeContext'; import { useTranslationContext } from '../../../contexts/translationContext/TranslationContext'; -import { useStateStore } from '../../../hooks/useStateStore'; import { primitives } from '../../../theme'; import { getPlayedCount, isEditedMessage, MessageStatusTypes } from '../../../utils/utils'; import { useShouldUseOverlayStyles } from '../hooks/useShouldUseOverlayStyles'; diff --git a/package/src/components/Message/MessageItemView/MessageHeader.tsx b/package/src/components/Message/MessageItemView/MessageHeader.tsx index 4b9478831d..fc499fb590 100644 --- a/package/src/components/Message/MessageItemView/MessageHeader.tsx +++ b/package/src/components/Message/MessageItemView/MessageHeader.tsx @@ -2,6 +2,7 @@ import React, { useMemo } from 'react'; import { View, ViewStyle } from 'react-native'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import type { Reminder, ReminderState } from 'stream-chat'; import { useComponentsContext } from '../../../contexts/componentsContext/ComponentsContext'; @@ -10,7 +11,6 @@ import { useMessageContext, } from '../../../contexts/messageContext/MessageContext'; import { useMessageReminder } from '../../../hooks/useMessageReminder'; -import { useStateStore } from '../../../hooks/useStateStore'; type MessageHeaderPropsWithContext = Pick & { reminder?: Reminder; diff --git a/package/src/components/Message/MessageItemView/MessageStatus.tsx b/package/src/components/Message/MessageItemView/MessageStatus.tsx index 617fe02bed..6cbae9a92c 100644 --- a/package/src/components/Message/MessageItemView/MessageStatus.tsx +++ b/package/src/components/Message/MessageItemView/MessageStatus.tsx @@ -1,6 +1,7 @@ import React, { useMemo } from 'react'; import { StyleSheet, View } from 'react-native'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import type { ChannelConfig } from 'stream-chat'; import { useA11yLabel } from '../../../a11y/hooks/useA11yLabel'; @@ -11,7 +12,6 @@ import { useMessageContext, } from '../../../contexts/messageContext/MessageContext'; import { useTheme } from '../../../contexts/themeContext/ThemeContext'; -import { useStateStore } from '../../../hooks/useStateStore'; import { primitives } from '../../../theme'; import { MessageStatusTypes } from '../../../utils/utils'; import { HiddenA11yText } from '../../Accessibility/HiddenA11yText'; diff --git a/package/src/components/Message/MessageItemView/MessageWrapper.tsx b/package/src/components/Message/MessageItemView/MessageWrapper.tsx index f5585d280b..48a45757a3 100644 --- a/package/src/components/Message/MessageItemView/MessageWrapper.tsx +++ b/package/src/components/Message/MessageItemView/MessageWrapper.tsx @@ -2,6 +2,7 @@ import React, { useCallback, useMemo } from 'react'; import { StyleSheet, View } from 'react-native'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import { LocalMessage, UnreadSnapshotState } from 'stream-chat'; import { useMessageDateSeparator } from '../../../components/MessageList/hooks/useMessageDateSeparator'; @@ -15,7 +16,6 @@ import { ThemeProvider, useTheme } from '../../../contexts/themeContext/ThemeCon import { useIsTargetedMessage } from '../../../hooks/useIsTargetedMessage'; import { useMessagePaginator } from '../../../hooks/useMessagePaginator'; -import { useStateStore } from '../../../hooks/useStateStore'; import { primitives } from '../../../theme'; export type MessageWrapperProps = { diff --git a/package/src/components/Message/hooks/useIsMessageDeliveredToOthers.ts b/package/src/components/Message/hooks/useIsMessageDeliveredToOthers.ts index a6f8a6f40d..32dd8a22de 100644 --- a/package/src/components/Message/hooks/useIsMessageDeliveredToOthers.ts +++ b/package/src/components/Message/hooks/useIsMessageDeliveredToOthers.ts @@ -1,9 +1,9 @@ import { useCallback } from 'react'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import type { LocalMessage, MessageReceiptsSnapshot } from 'stream-chat'; import { useChannelContext } from '../../../contexts/channelContext/ChannelContext'; -import { useStateStore } from '../../../hooks/useStateStore'; /** * Whether the message has been delivered to at least one other member, read from the channel's diff --git a/package/src/components/Message/hooks/useIsMessageReadByOthers.ts b/package/src/components/Message/hooks/useIsMessageReadByOthers.ts index b63e8b56c9..646db36cd7 100644 --- a/package/src/components/Message/hooks/useIsMessageReadByOthers.ts +++ b/package/src/components/Message/hooks/useIsMessageReadByOthers.ts @@ -1,9 +1,9 @@ import { useCallback } from 'react'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import type { LocalMessage, MessageReceiptsSnapshot } from 'stream-chat'; import { useChannelContext } from '../../../contexts/channelContext/ChannelContext'; -import { useStateStore } from '../../../hooks/useStateStore'; /** * Whether at least one other member has read the message, read from the channel's diff --git a/package/src/components/Message/hooks/useMessageDeliveryData.ts b/package/src/components/Message/hooks/useMessageDeliveryData.ts index 882599fd27..3ec0c27d88 100644 --- a/package/src/components/Message/hooks/useMessageDeliveryData.ts +++ b/package/src/components/Message/hooks/useMessageDeliveryData.ts @@ -1,9 +1,9 @@ import { useCallback } from 'react'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import type { LocalMessage, UserResponse } from 'stream-chat'; import { useChannelContext } from '../../../contexts/channelContext/ChannelContext'; -import { useStateStore } from '../../../hooks/useStateStore'; const EMPTY_DELIVERED: UserResponse[] = []; diff --git a/package/src/components/Message/hooks/useMessageReadData.ts b/package/src/components/Message/hooks/useMessageReadData.ts index 311a99a1b2..2d3c075e79 100644 --- a/package/src/components/Message/hooks/useMessageReadData.ts +++ b/package/src/components/Message/hooks/useMessageReadData.ts @@ -1,9 +1,9 @@ import { useCallback } from 'react'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import type { LocalMessage, UserResponse } from 'stream-chat'; import { useChannelContext } from '../../../contexts/channelContext/ChannelContext'; -import { useStateStore } from '../../../hooks/useStateStore'; const EMPTY_READERS: UserResponse[] = []; diff --git a/package/src/components/Message/hooks/useUserMuteActive.ts b/package/src/components/Message/hooks/useUserMuteActive.ts index 8cd2f7f240..4876e743fb 100644 --- a/package/src/components/Message/hooks/useUserMuteActive.ts +++ b/package/src/components/Message/hooks/useUserMuteActive.ts @@ -1,9 +1,9 @@ import { useCallback } from 'react'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import type { UserMuteResponse, UserResponse } from 'stream-chat'; import { useChatContext } from '../../../contexts'; -import { useStateStore } from '../../../hooks/useStateStore'; /** * Whether `currentUserId` has muted `userId`, according to the given mute list. diff --git a/package/src/components/MessageInput/CommandChip.tsx b/package/src/components/MessageInput/CommandChip.tsx index 9817be154a..2dffeb8a96 100644 --- a/package/src/components/MessageInput/CommandChip.tsx +++ b/package/src/components/MessageInput/CommandChip.tsx @@ -3,11 +3,12 @@ import { StyleSheet } from 'react-native'; import Animated, { ZoomIn, ZoomOut } from 'react-native-reanimated'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; + import { textComposerStateSelector } from './utils/messageComposerSelectors'; import { useAnimationsContext } from '../../contexts/animationsContext/AnimationsContext'; import { useMessageComposer } from '../../contexts/messageInputContext/hooks/useMessageComposer'; -import { useStateStore } from '../../hooks/useStateStore'; import { primitives } from '../../theme'; import { GiphyChip } from '../ui/GiphyChip'; diff --git a/package/src/components/MessageInput/MessageComposer.tsx b/package/src/components/MessageInput/MessageComposer.tsx index 6eab422d9f..ac9bfc115e 100644 --- a/package/src/components/MessageInput/MessageComposer.tsx +++ b/package/src/components/MessageInput/MessageComposer.tsx @@ -10,6 +10,7 @@ import Animated, { import { useSafeAreaInsets } from 'react-native-safe-area-context'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import { type ChannelDataState, type ChannelWatchState, @@ -48,7 +49,6 @@ import { import { useAttachmentPickerState } from '../../hooks/useAttachmentPickerState'; import { useKeyboardVisibility } from '../../hooks/useKeyboardVisibility'; -import { useStateStore } from '../../hooks/useStateStore'; import { AudioRecorderManagerState } from '../../state-store/audio-recorder-manager'; import { MessageInputHeightState } from '../../state-store/message-input-height-store'; import { primitives } from '../../theme'; diff --git a/package/src/components/MessageInput/MessageComposerLeadingView.tsx b/package/src/components/MessageInput/MessageComposerLeadingView.tsx index af46508069..21834a6ded 100644 --- a/package/src/components/MessageInput/MessageComposerLeadingView.tsx +++ b/package/src/components/MessageInput/MessageComposerLeadingView.tsx @@ -3,13 +3,14 @@ import { StyleSheet } from 'react-native'; import Animated from 'react-native-reanimated'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; + import { InputButtons } from './components/InputButtons'; import { idleRecordingStateSelector } from './utils/audioRecorderSelectors'; import { useAnimationsContext } from '../../contexts/animationsContext/AnimationsContext'; import { useMessageInputContext } from '../../contexts/messageInputContext/MessageInputContext'; import { useTheme } from '../../contexts/themeContext/ThemeContext'; -import { useStateStore } from '../../hooks/useStateStore'; export const MessageComposerLeadingView = () => { const animations = useAnimationsContext(); diff --git a/package/src/components/MessageInput/MessageInputHeaderView.tsx b/package/src/components/MessageInput/MessageInputHeaderView.tsx index a20308db43..b7e90fe7de 100644 --- a/package/src/components/MessageInput/MessageInputHeaderView.tsx +++ b/package/src/components/MessageInput/MessageInputHeaderView.tsx @@ -3,6 +3,8 @@ import { StyleSheet } from 'react-native'; import Animated from 'react-native-reanimated'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; + import { LinkPreviewList } from './components/LinkPreviewList'; import { useHasLinkPreviews } from './hooks/useLinkPreviews'; @@ -16,7 +18,6 @@ import { useHasAttachments } from '../../contexts/messageInputContext/hooks/useH import { useMessageComposer } from '../../contexts/messageInputContext/hooks/useMessageComposer'; import { useMessageInputContext } from '../../contexts/messageInputContext/MessageInputContext'; import { useTheme } from '../../contexts/themeContext/ThemeContext'; -import { useStateStore } from '../../hooks/useStateStore'; import { primitives } from '../../theme'; import { transitions } from '../../utils/animations/transitions'; diff --git a/package/src/components/MessageInput/MessageInputTrailingView.tsx b/package/src/components/MessageInput/MessageInputTrailingView.tsx index 8570662f19..e12b196ab9 100644 --- a/package/src/components/MessageInput/MessageInputTrailingView.tsx +++ b/package/src/components/MessageInput/MessageInputTrailingView.tsx @@ -3,6 +3,8 @@ import { StyleSheet } from 'react-native'; import Animated from 'react-native-reanimated'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; + import { OutputButtons } from './components/OutputButtons'; import { audioRecorderSelector } from './utils/audioRecorderSelectors'; @@ -10,7 +12,6 @@ import { audioRecorderSelector } from './utils/audioRecorderSelectors'; import { useAnimationsContext } from '../../contexts/animationsContext/AnimationsContext'; import { useMessageInputContext } from '../../contexts/messageInputContext/MessageInputContext'; import { useTheme } from '../../contexts/themeContext/ThemeContext'; -import { useStateStore } from '../../hooks/useStateStore'; import { primitives } from '../../theme'; export const MessageInputTrailingView = () => { diff --git a/package/src/components/MessageInput/ShowThreadMessageInChannelButton.tsx b/package/src/components/MessageInput/ShowThreadMessageInChannelButton.tsx index b8be584e7b..d44d573f06 100644 --- a/package/src/components/MessageInput/ShowThreadMessageInChannelButton.tsx +++ b/package/src/components/MessageInput/ShowThreadMessageInChannelButton.tsx @@ -3,6 +3,7 @@ import { Pressable, StyleSheet, Text, View } from 'react-native'; import Animated from 'react-native-reanimated'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import { MessageComposerState } from 'stream-chat'; import { useAnimationsContext } from '../../contexts/animationsContext/AnimationsContext'; @@ -14,7 +15,6 @@ import { TranslationContextValue, useTranslationContext, } from '../../contexts/translationContext/TranslationContext'; -import { useStateStore } from '../../hooks/useStateStore'; import { primitives } from '../../theme'; const stateSelector = (state: MessageComposerState) => ({ diff --git a/package/src/components/MessageInput/components/AudioRecorder/AudioRecorder.tsx b/package/src/components/MessageInput/components/AudioRecorder/AudioRecorder.tsx index 98c359847c..f55000b163 100644 --- a/package/src/components/MessageInput/components/AudioRecorder/AudioRecorder.tsx +++ b/package/src/components/MessageInput/components/AudioRecorder/AudioRecorder.tsx @@ -3,6 +3,7 @@ import { StyleProp, StyleSheet, Text, View, ViewStyle } from 'react-native'; import Animated, { type AnimatedStyle } from 'react-native-reanimated'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import dayjs from 'dayjs'; import { Button } from '../../../../components/ui'; @@ -13,7 +14,6 @@ import { } from '../../../../contexts/messageInputContext/MessageInputContext'; import { useTheme } from '../../../../contexts/themeContext/ThemeContext'; import { useTranslationContext } from '../../../../contexts/translationContext/TranslationContext'; -import { useStateStore } from '../../../../hooks/useStateStore'; import { IconProps } from '../../../../icons/utils/base'; import { NativeHandlers } from '../../../../native'; diff --git a/package/src/components/MessageInput/components/AudioRecorder/AudioRecordingButton.tsx b/package/src/components/MessageInput/components/AudioRecorder/AudioRecordingButton.tsx index e4fda1fe0f..205d0c264e 100644 --- a/package/src/components/MessageInput/components/AudioRecorder/AudioRecordingButton.tsx +++ b/package/src/components/MessageInput/components/AudioRecorder/AudioRecordingButton.tsx @@ -10,6 +10,8 @@ import Animated, { withSpring, } from 'react-native-reanimated'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; + import { useA11yLabel } from '../../../../a11y/hooks/useA11yLabel'; import { useActiveAudioPlayer } from '../../../../contexts/audioPlayerContext/AudioPlayerContext'; import { useComponentsContext } from '../../../../contexts/componentsContext/ComponentsContext'; @@ -20,7 +22,6 @@ import { import { useTheme } from '../../../../contexts/themeContext/ThemeContext'; import { useTranslationContext } from '../../../../contexts/translationContext/TranslationContext'; import { useStableCallback } from '../../../../hooks'; -import { useStateStore } from '../../../../hooks/useStateStore'; import { NativeHandlers } from '../../../../native'; import { AudioRecorderManagerState } from '../../../../state-store/audio-recorder-manager'; import { primitives } from '../../../../theme'; diff --git a/package/src/components/MessageInput/components/AudioRecorder/AudioRecordingInProgress.tsx b/package/src/components/MessageInput/components/AudioRecorder/AudioRecordingInProgress.tsx index 961a312aa9..2151df9075 100644 --- a/package/src/components/MessageInput/components/AudioRecorder/AudioRecordingInProgress.tsx +++ b/package/src/components/MessageInput/components/AudioRecorder/AudioRecordingInProgress.tsx @@ -1,6 +1,7 @@ import React, { useMemo } from 'react'; import { StyleSheet, Text, View } from 'react-native'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import dayjs from 'dayjs'; import { useComponentsContext } from '../../../../contexts/componentsContext/ComponentsContext'; @@ -9,7 +10,6 @@ import { useMessageInputContext, } from '../../../../contexts/messageInputContext/MessageInputContext'; import { useTheme } from '../../../../contexts/themeContext/ThemeContext'; -import { useStateStore } from '../../../../hooks/useStateStore'; import { AudioRecorderManagerState } from '../../../../state-store/audio-recorder-manager'; import { primitives } from '../../../../theme'; diff --git a/package/src/components/MessageInput/components/AudioRecorder/AudioRecordingPreview.tsx b/package/src/components/MessageInput/components/AudioRecorder/AudioRecordingPreview.tsx index 137ec3c41a..37c39c917c 100644 --- a/package/src/components/MessageInput/components/AudioRecorder/AudioRecordingPreview.tsx +++ b/package/src/components/MessageInput/components/AudioRecorder/AudioRecordingPreview.tsx @@ -1,6 +1,7 @@ import React, { useEffect, useMemo } from 'react'; import { Pressable, StyleSheet, View } from 'react-native'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import dayjs from 'dayjs'; import { useComponentsContext } from '../../../../contexts/componentsContext/ComponentsContext'; @@ -8,7 +9,6 @@ import { useMessageInputContext } from '../../../../contexts/messageInputContext import { useTheme } from '../../../../contexts/themeContext/ThemeContext'; import { useStableCallback } from '../../../../hooks'; import { useAudioPlayer } from '../../../../hooks/useAudioPlayer'; -import { useStateStore } from '../../../../hooks/useStateStore'; import { AudioPlayerState } from '../../../../state-store/audio-player'; import { AudioRecorderManagerState } from '../../../../state-store/audio-recorder-manager'; diff --git a/package/src/components/MessageInput/components/OutputButtons/index.tsx b/package/src/components/MessageInput/components/OutputButtons/index.tsx index 18ca6b4bbe..240d88f11b 100644 --- a/package/src/components/MessageInput/components/OutputButtons/index.tsx +++ b/package/src/components/MessageInput/components/OutputButtons/index.tsx @@ -2,6 +2,7 @@ import React, { useCallback } from 'react'; import Animated from 'react-native-reanimated'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import { TextComposerState } from 'stream-chat'; import { EditButton } from './EditButton'; @@ -19,7 +20,6 @@ import { MessageInputContextValue, useMessageInputContext, } from '../../../../contexts/messageInputContext/MessageInputContext'; -import { useStateStore } from '../../../../hooks/useStateStore'; import { transitions } from '../../../../utils/animations/transitions'; import { AIStates, useAIState } from '../../../AITypingIndicatorView'; import { useSettledWSConnectionHealth } from '../../../Chat/hooks/useWSConnectionState'; diff --git a/package/src/components/MessageInput/hooks/useCooldownRemaining.tsx b/package/src/components/MessageInput/hooks/useCooldownRemaining.tsx index a4f6e04928..8cb235b0b7 100644 --- a/package/src/components/MessageInput/hooks/useCooldownRemaining.tsx +++ b/package/src/components/MessageInput/hooks/useCooldownRemaining.tsx @@ -1,7 +1,7 @@ +import { useStateStore } from '@stream-io/state-store/react-bindings'; import { type CooldownTimerState } from 'stream-chat'; import { useChannelContext } from '../../../contexts/channelContext/ChannelContext'; -import { useStateStore } from '../../../hooks/useStateStore'; const cooldownTimerStateSelector = (state: CooldownTimerState) => ({ cooldownRemaining: state.cooldownRemaining, diff --git a/package/src/components/MessageInput/hooks/useIsCooldownActive.ts b/package/src/components/MessageInput/hooks/useIsCooldownActive.ts index 6c6494b8fc..76736e4d38 100644 --- a/package/src/components/MessageInput/hooks/useIsCooldownActive.ts +++ b/package/src/components/MessageInput/hooks/useIsCooldownActive.ts @@ -1,7 +1,7 @@ +import { useStateStore } from '@stream-io/state-store/react-bindings'; import { CooldownTimerState } from 'stream-chat'; import { useChannelContext } from '../../../contexts/channelContext/ChannelContext'; -import { useStateStore } from '../../../hooks/useStateStore'; const cooldownTimerStateSelector = (state: CooldownTimerState) => ({ isCooldownActive: !!state.cooldownRemaining, diff --git a/package/src/components/MessageInput/hooks/useLinkPreviews.ts b/package/src/components/MessageInput/hooks/useLinkPreviews.ts index 4f4e7beb83..2c9b95392c 100644 --- a/package/src/components/MessageInput/hooks/useLinkPreviews.ts +++ b/package/src/components/MessageInput/hooks/useLinkPreviews.ts @@ -1,7 +1,7 @@ +import { useStateStore } from '@stream-io/state-store/react-bindings'; import { LinkPreviewsManager, LinkPreviewsManagerState } from 'stream-chat'; import { useMessageComposer } from '../../../contexts'; -import { useStateStore } from '../../../hooks'; const linkPreviewsManagerStateSelector = (state: LinkPreviewsManagerState) => ({ linkPreviews: Array.from(state.previews.values()).filter((preview) => diff --git a/package/src/components/MessageList/MessageFlashList.tsx b/package/src/components/MessageList/MessageFlashList.tsx index e0984a3622..16345aa729 100644 --- a/package/src/components/MessageList/MessageFlashList.tsx +++ b/package/src/components/MessageList/MessageFlashList.tsx @@ -4,6 +4,7 @@ import { LayoutChangeEvent, ScrollViewProps, StyleSheet, View, useColorScheme } import Animated from 'react-native-reanimated'; import type { FlashListProps, FlashListRef } from '@shopify/flash-list'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import type { LocalMessage, Thread } from 'stream-chat'; import { getAttachmentPreviewUrl } from 'stream-chat'; @@ -54,7 +55,7 @@ import { import { mergeThemes, useTheme } from '../../contexts/themeContext/ThemeContext'; import { ThreadContextValue, useThreadContext } from '../../contexts/threadContext/ThreadContext'; -import { useStableCallback, useStateStore } from '../../hooks'; +import { useStableCallback } from '../../hooks'; import { isVideoPlayerAvailable } from '../../native'; import { bumpOverlayLayoutRevision, useHasActiveId } from '../../state-store'; import { MessageInputHeightState } from '../../state-store/message-input-height-store'; diff --git a/package/src/components/MessageList/MessageList.tsx b/package/src/components/MessageList/MessageList.tsx index a0cba8082d..e6628cd0ee 100644 --- a/package/src/components/MessageList/MessageList.tsx +++ b/package/src/components/MessageList/MessageList.tsx @@ -12,6 +12,7 @@ import { import Animated from 'react-native-reanimated'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import debounce from 'lodash/debounce'; import type { LocalMessage, Thread } from 'stream-chat'; @@ -70,7 +71,6 @@ import { mergeThemes, useTheme } from '../../contexts/themeContext/ThemeContext' import { ThreadContextValue, useThreadContext } from '../../contexts/threadContext/ThreadContext'; import { useStableCallback } from '../../hooks'; -import { useStateStore } from '../../hooks/useStateStore'; import { bumpOverlayLayoutRevision, useHasActiveId } from '../../state-store'; import { MessageInputHeightState } from '../../state-store/message-input-height-store'; import { primitives } from '../../theme'; diff --git a/package/src/components/MessageList/TypingIndicatorContainer.tsx b/package/src/components/MessageList/TypingIndicatorContainer.tsx index 680562d9ba..da4e257c96 100644 --- a/package/src/components/MessageList/TypingIndicatorContainer.tsx +++ b/package/src/components/MessageList/TypingIndicatorContainer.tsx @@ -1,6 +1,7 @@ import React, { PropsWithChildren } from 'react'; import { StyleSheet, View } from 'react-native'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import { TypingUsersState } from 'stream-chat'; import { filterTypingUsers } from './utils/filterTypingUsers'; @@ -9,7 +10,6 @@ import { useChannelContext } from '../../contexts/channelContext/ChannelContext' import { ChatContextValue, useChatContext } from '../../contexts/chatContext/ChatContext'; import { useTheme } from '../../contexts/themeContext/ThemeContext'; import { useThreadContext } from '../../contexts/threadContext/ThreadContext'; -import { useStateStore } from '../../hooks/useStateStore'; import { primitives } from '../../theme'; const styles = StyleSheet.create({ diff --git a/package/src/components/MessageList/UnreadMessagesNotification.tsx b/package/src/components/MessageList/UnreadMessagesNotification.tsx index dcd538c5af..0cd4e26bd6 100644 --- a/package/src/components/MessageList/UnreadMessagesNotification.tsx +++ b/package/src/components/MessageList/UnreadMessagesNotification.tsx @@ -1,6 +1,7 @@ import React, { useMemo } from 'react'; import { StyleSheet, View } from 'react-native'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import type { UnreadSnapshotState } from 'stream-chat'; import { DEFAULT_HIGHLIGHT_DURATION } from './hooks/useMessageListFocus'; @@ -9,7 +10,6 @@ import { useChannelContext } from '../../contexts/channelContext/ChannelContext' import { useComponentsContext } from '../../contexts/componentsContext/ComponentsContext'; import { useTheme } from '../../contexts/themeContext/ThemeContext'; import { useTranslationContext } from '../../contexts/translationContext/TranslationContext'; -import { useStateStore } from '../../hooks/useStateStore'; import { primitives } from '../../theme'; import { MarkReadFunctionOptions } from '../Channel/Channel'; import { useNotificationApi } from '../Notifications'; diff --git a/package/src/components/MessageList/__tests__/dateSeparatorSystemMessages.test.tsx b/package/src/components/MessageList/__tests__/dateSeparatorSystemMessages.test.tsx index 2909888532..d2062b6d69 100644 --- a/package/src/components/MessageList/__tests__/dateSeparatorSystemMessages.test.tsx +++ b/package/src/components/MessageList/__tests__/dateSeparatorSystemMessages.test.tsx @@ -1,6 +1,7 @@ import React from 'react'; import { View } from 'react-native'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import { cleanup, render, waitFor } from '@testing-library/react-native'; import type { Channel as ChannelType, LocalMessage, TimestampNS } from 'stream-chat'; @@ -9,7 +10,6 @@ import { nsToMs } from 'stream-chat'; import { useChannelContext } from '../../../contexts/channelContext/ChannelContext'; import { WithComponents } from '../../../contexts/componentsContext/ComponentsContext'; import { OverlayProvider } from '../../../contexts/overlayContext/OverlayProvider'; -import { useStateStore } from '../../../hooks/useStateStore'; import { getOrCreateChannelApi } from '../../../mock-builders/api/getOrCreateChannel'; import { useMockedApis } from '../../../mock-builders/api/useMockedApis'; import { generateChannelResponse } from '../../../mock-builders/generator/channel'; diff --git a/package/src/components/MessageList/hooks/useMessageList.ts b/package/src/components/MessageList/hooks/useMessageList.ts index a6c45079c4..b3f0f097c2 100644 --- a/package/src/components/MessageList/hooks/useMessageList.ts +++ b/package/src/components/MessageList/hooks/useMessageList.ts @@ -1,8 +1,9 @@ import { useMemo } from 'react'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import type { LocalMessage, MessagePaginator } from 'stream-chat'; -import { useRAFCoalescedValue, useStateStore } from '../../../hooks'; +import { useRAFCoalescedValue } from '../../../hooks'; import { usePrunableMessageList } from '../../../hooks/usePrunableMessageList'; export type UseMessageListParams = { diff --git a/package/src/components/MessageList/hooks/useMessageListFocus.ts b/package/src/components/MessageList/hooks/useMessageListFocus.ts index f62941b6df..81ace044ec 100644 --- a/package/src/components/MessageList/hooks/useMessageListFocus.ts +++ b/package/src/components/MessageList/hooks/useMessageListFocus.ts @@ -1,11 +1,12 @@ import { useEffect } from 'react'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import type { MessagePaginator } from 'stream-chat'; import type { GoToMessage } from '../../../contexts/messageListItemContext/MessageListItemContext'; import { useMessagesContext } from '../../../contexts/messagesContext/MessagesContext'; import { useThreadContext } from '../../../contexts/threadContext/ThreadContext'; -import { useStableCallback, useStateStore } from '../../../hooks'; +import { useStableCallback } from '../../../hooks'; import { useOpenThreadAtMessage } from '../../Message/hooks/useOpenThreadAtMessage'; /** How long, in milliseconds, a message the list jumped to stays highlighted. */ diff --git a/package/src/components/MessageList/hooks/useMessageListPagination.ts b/package/src/components/MessageList/hooks/useMessageListPagination.ts index 4a58d504d1..20da94a614 100644 --- a/package/src/components/MessageList/hooks/useMessageListPagination.ts +++ b/package/src/components/MessageList/hooks/useMessageListPagination.ts @@ -1,8 +1,9 @@ import { useRef, useState } from 'react'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import type { MessagePaginator } from 'stream-chat'; -import { useStableCallback, useStateStore } from '../../../hooks'; +import { useStableCallback } from '../../../hooks'; const loadingSelector = (state: { isLoading: boolean; items?: unknown[] }) => ({ hasMessages: (state.items?.length ?? 0) > 0, diff --git a/package/src/components/MessageList/hooks/useOwnUnreadCount.ts b/package/src/components/MessageList/hooks/useOwnUnreadCount.ts index 36c6c39719..31fbe3b3b7 100644 --- a/package/src/components/MessageList/hooks/useOwnUnreadCount.ts +++ b/package/src/components/MessageList/hooks/useOwnUnreadCount.ts @@ -1,9 +1,9 @@ import { useMemo } from 'react'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import type { Channel, ReadState } from 'stream-chat'; import { useChatContext } from '../../../contexts/chatContext/ChatContext'; -import { useStateStore } from '../../../hooks/useStateStore'; /** * The current user's unread message count in `channel`, kept current as reads arrive. `undefined` diff --git a/package/src/components/MessageList/hooks/useTypingUsers.ts b/package/src/components/MessageList/hooks/useTypingUsers.ts index 3dc8e2e45f..0fab676636 100644 --- a/package/src/components/MessageList/hooks/useTypingUsers.ts +++ b/package/src/components/MessageList/hooks/useTypingUsers.ts @@ -1,9 +1,9 @@ import { useMemo } from 'react'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import { Channel, TypingUsersState } from 'stream-chat'; import { useChannelContext, useChatContext, useThreadContext } from '../../../contexts'; -import { useStateStore } from '../../../hooks'; import { filterTypingUsers } from '../utils/filterTypingUsers'; const selector = (state: TypingUsersState) => ({ typing: state.typing }); diff --git a/package/src/components/Notifications/hooks/useNotifications.ts b/package/src/components/Notifications/hooks/useNotifications.ts index cee7f83d16..bfbd153738 100644 --- a/package/src/components/Notifications/hooks/useNotifications.ts +++ b/package/src/components/Notifications/hooks/useNotifications.ts @@ -1,9 +1,9 @@ import { useCallback } from 'react'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import type { Notification, NotificationManagerState } from 'stream-chat'; import { useChatContext } from '../../../contexts/chatContext/ChatContext'; -import { useStateStore } from '../../../hooks/useStateStore'; import { isNotificationForTarget, type NotificationTarget } from '../notificationTarget'; export type UseNotificationsFilter = (notification: Notification) => boolean; diff --git a/package/src/components/Notifications/hooks/useSystemNotifications.ts b/package/src/components/Notifications/hooks/useSystemNotifications.ts index 9224cf70df..7672c6fd6d 100644 --- a/package/src/components/Notifications/hooks/useSystemNotifications.ts +++ b/package/src/components/Notifications/hooks/useSystemNotifications.ts @@ -1,11 +1,11 @@ import { useCallback } from 'react'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import type { Notification, NotificationManagerState } from 'stream-chat'; import { hasSystemNotificationTag } from './useNotificationApi'; import { useChatContext } from '../../../contexts/chatContext/ChatContext'; -import { useStateStore } from '../../../hooks/useStateStore'; export type UseSystemNotificationsFilter = (notification: Notification) => boolean; diff --git a/package/src/components/Poll/CreatePollContent.tsx b/package/src/components/Poll/CreatePollContent.tsx index f31c9dceb9..a13c024aa3 100644 --- a/package/src/components/Poll/CreatePollContent.tsx +++ b/package/src/components/Poll/CreatePollContent.tsx @@ -5,6 +5,7 @@ import { ScrollView } from 'react-native-gesture-handler'; import Animated, { useSharedValue } from 'react-native-reanimated'; import { StateStore } from '@stream-io/state-store'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import { PollComposerState } from 'stream-chat'; import { CreatePollOptions, CurrentOptionPositionsCache } from './components'; @@ -24,7 +25,6 @@ import { import { useAnimationsContext } from '../../contexts/animationsContext/AnimationsContext'; import { useComponentsContext } from '../../contexts/componentsContext/ComponentsContext'; import { useMessageComposer } from '../../contexts/messageInputContext/hooks/useMessageComposer'; -import { useStateStore } from '../../hooks/useStateStore'; import { primitives } from '../../theme'; import { useRtlMirrorSwitchStyle } from '../../utils/rtlMirrorSwitchStyle'; diff --git a/package/src/components/Poll/components/CreatePollOptions.tsx b/package/src/components/Poll/components/CreatePollOptions.tsx index f895d68ffa..c772fe6e51 100644 --- a/package/src/components/Poll/components/CreatePollOptions.tsx +++ b/package/src/components/Poll/components/CreatePollOptions.tsx @@ -23,6 +23,7 @@ import Animated, { withSpring, } from 'react-native-reanimated'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import { POLL_COMPOSER_VALIDATION_CODE, PollComposerOption, PollComposerState } from 'stream-chat'; import type { PollComposerValidationCode, PollComposerValidationError } from 'stream-chat'; @@ -30,7 +31,6 @@ import { useCreatePollContentContext, useTheme, useTranslationContext } from '.. import { useAnimationsContext } from '../../../contexts/animationsContext/AnimationsContext'; import { useComponentsContext } from '../../../contexts/componentsContext/ComponentsContext'; import { useMessageComposer } from '../../../contexts/messageInputContext/hooks/useMessageComposer'; -import { useStateStore } from '../../../hooks/useStateStore'; import { primitives } from '../../../theme'; import type { ViewRef } from '../../../types/react-native-compat'; diff --git a/package/src/components/Poll/components/MultipleVotesSettings.tsx b/package/src/components/Poll/components/MultipleVotesSettings.tsx index 1c77973373..e6fca631b5 100644 --- a/package/src/components/Poll/components/MultipleVotesSettings.tsx +++ b/package/src/components/Poll/components/MultipleVotesSettings.tsx @@ -3,6 +3,7 @@ import { Platform, StyleSheet, Switch, Text, TextInput, View } from 'react-nativ import Animated, { StretchInY, StretchOutY } from 'react-native-reanimated'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import { PollComposerState } from 'stream-chat'; import { useCreatePollContentContext, useTheme, useTranslationContext } from '../../../contexts'; @@ -10,7 +11,6 @@ import { useAnimationsContext } from '../../../contexts/animationsContext/Animat import { useComponentsContext } from '../../../contexts/componentsContext/ComponentsContext'; import { useMessageComposer } from '../../../contexts/messageInputContext/hooks/useMessageComposer'; import { useStableCallback } from '../../../hooks'; -import { useStateStore } from '../../../hooks/useStateStore'; import { primitives } from '../../../theme'; import type { TextInputRef } from '../../../types/react-native-compat'; import { useRtlMirrorSwitchStyle } from '../../../utils/rtlMirrorSwitchStyle'; diff --git a/package/src/components/Poll/contexts/PollUIStateContext.tsx b/package/src/components/Poll/contexts/PollUIStateContext.tsx index 831d937b25..89aed19d41 100644 --- a/package/src/components/Poll/contexts/PollUIStateContext.tsx +++ b/package/src/components/Poll/contexts/PollUIStateContext.tsx @@ -2,9 +2,10 @@ import React, { PropsWithChildren, useContext, useState } from 'react'; import { StateStore } from '@stream-io/state-store'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; + import { DEFAULT_BASE_CONTEXT_VALUE } from '../../../contexts/utils/defaultBaseContextValue'; import { isTestEnvironment } from '../../../contexts/utils/isTestEnvironment'; -import { useStateStore } from '../../../hooks/useStateStore'; export type PollUIState = { addCommentOpen: boolean; diff --git a/package/src/components/Poll/hooks/usePollStateStore.ts b/package/src/components/Poll/hooks/usePollStateStore.ts index bbfc6e7e9e..520546a23d 100644 --- a/package/src/components/Poll/hooks/usePollStateStore.ts +++ b/package/src/components/Poll/hooks/usePollStateStore.ts @@ -1,7 +1,7 @@ +import { useStateStore } from '@stream-io/state-store/react-bindings'; import { PollState } from 'stream-chat'; import { usePollContext } from '../../../contexts'; -import { useStateStore } from '../../../hooks'; export const usePollStateStore = < T extends Readonly | Readonly>, diff --git a/package/src/components/Reply/Reply.tsx b/package/src/components/Reply/Reply.tsx index f56b12184b..bfa18cb416 100644 --- a/package/src/components/Reply/Reply.tsx +++ b/package/src/components/Reply/Reply.tsx @@ -11,6 +11,7 @@ import { ViewStyle, } from 'react-native'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import { getAttachmentPreviewUrl, isFileAttachment, @@ -32,7 +33,6 @@ import { import { useMessageComposer } from '../../contexts/messageInputContext/hooks/useMessageComposer'; import { useTheme } from '../../contexts/themeContext/ThemeContext'; import { useTranslationContext } from '../../contexts/translationContext/TranslationContext'; -import { useStateStore } from '../../hooks'; import { primitives } from '../../theme'; import { FileTypes } from '../../types/types'; import { checkQuotedMessageEquality } from '../../utils/utils'; diff --git a/package/src/components/Thread/Thread.tsx b/package/src/components/Thread/Thread.tsx index 2cfc099ae4..03e9a1b4d8 100644 --- a/package/src/components/Thread/Thread.tsx +++ b/package/src/components/Thread/Thread.tsx @@ -1,11 +1,11 @@ import React, { PropsWithChildren, useEffect } from 'react'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import type { LocalMessage, Thread as ThreadInstance } from 'stream-chat'; import { useComponentsContext } from '../../contexts/componentsContext/ComponentsContext'; import { ThreadContextValue, ThreadProvider } from '../../contexts/threadContext/ThreadContext'; import { useStableCallback } from '../../hooks'; -import { useStateStore } from '../../hooks/useStateStore'; import { ChannelConfigProps, ChannelShell } from '../Channel/ChannelShell'; import { useCreateThreadContext } from '../Channel/hooks/useCreateThreadContext'; import { getThreadNotificationHostId } from '../Notifications/notificationTarget'; diff --git a/package/src/components/Thread/components/ThreadFooterComponent.tsx b/package/src/components/Thread/components/ThreadFooterComponent.tsx index 712107fbbc..3b794dfdd8 100644 --- a/package/src/components/Thread/components/ThreadFooterComponent.tsx +++ b/package/src/components/Thread/components/ThreadFooterComponent.tsx @@ -1,6 +1,7 @@ import React, { useMemo } from 'react'; import { ActivityIndicator, StyleSheet, Text, View } from 'react-native'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import type { ThreadState } from 'stream-chat'; import { useComponentsContext } from '../../../contexts/componentsContext/ComponentsContext'; @@ -10,7 +11,6 @@ import { useThreadContext, } from '../../../contexts/threadContext/ThreadContext'; import { useTranslationContext } from '../../../contexts/translationContext/TranslationContext'; -import { useStateStore } from '../../../hooks'; import { primitives } from '../../../theme'; type ThreadFooterComponentPropsWithContext = Pick & { diff --git a/package/src/components/ThreadList/ThreadList.tsx b/package/src/components/ThreadList/ThreadList.tsx index 0c56af7315..b25fc5ced5 100644 --- a/package/src/components/ThreadList/ThreadList.tsx +++ b/package/src/components/ThreadList/ThreadList.tsx @@ -1,6 +1,7 @@ import React, { useCallback, useEffect } from 'react'; import { FlatList, StyleSheet, View } from 'react-native'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import type { PaginatorState, Thread } from 'stream-chat'; import { ThreadListItem } from './ThreadListItem'; @@ -13,7 +14,6 @@ import { ThreadsProvider, useThreadsContext, } from '../../contexts/threadsContext/ThreadsContext'; -import { useStateStore } from '../../hooks'; import { useLazyRef } from '../../hooks/useLazyRef'; import { generateRandomId } from '../../utils/utils'; diff --git a/package/src/components/ThreadList/ThreadListItem.tsx b/package/src/components/ThreadList/ThreadListItem.tsx index 49f0434e69..4638b18ebe 100644 --- a/package/src/components/ThreadList/ThreadListItem.tsx +++ b/package/src/components/ThreadList/ThreadListItem.tsx @@ -1,6 +1,7 @@ import React, { useCallback, useEffect, useMemo } from 'react'; import { Pressable, StyleSheet, Text, View } from 'react-native'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import { AttachmentManagerState, convertTimestampToDate, @@ -19,7 +20,6 @@ import { useThreadListItemContext, } from '../../contexts/threadsContext/ThreadListItemContext'; import { useThreadsContext } from '../../contexts/threadsContext/ThreadsContext'; -import { useStateStore } from '../../hooks'; import { getDateString } from '../../i18n/utils'; import { primitives } from '../../theme'; import { useChannelPreviewDisplayPresence } from '../ChannelPreview/hooks'; diff --git a/package/src/components/ThreadList/ThreadListUnreadBanner.tsx b/package/src/components/ThreadList/ThreadListUnreadBanner.tsx index ae5e8fbdae..288de9f3ab 100644 --- a/package/src/components/ThreadList/ThreadListUnreadBanner.tsx +++ b/package/src/components/ThreadList/ThreadListUnreadBanner.tsx @@ -1,11 +1,11 @@ import React, { useCallback, useMemo, useState } from 'react'; import { Pressable, StyleSheet, Text, View } from 'react-native'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import { ThreadManagerState } from 'stream-chat'; import { useChatContext, useTheme, useTranslationContext } from '../../contexts'; import { useComponentsContext } from '../../contexts/componentsContext/ComponentsContext'; -import { useStateStore } from '../../hooks'; import { primitives } from '../../theme'; const selector = (nextValue: ThreadManagerState) => diff --git a/package/src/components/ThreadList/ThreadMessagePreviewDeliveryStatus.tsx b/package/src/components/ThreadList/ThreadMessagePreviewDeliveryStatus.tsx index 749a579258..c35a753f6c 100644 --- a/package/src/components/ThreadList/ThreadMessagePreviewDeliveryStatus.tsx +++ b/package/src/components/ThreadList/ThreadMessagePreviewDeliveryStatus.tsx @@ -1,6 +1,7 @@ import React, { useMemo } from 'react'; import { StyleSheet, Text, View } from 'react-native'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import { Channel, ChannelConfig, LocalMessage } from 'stream-chat'; import { useChatContext } from '../../contexts/chatContext/ChatContext'; @@ -8,7 +9,6 @@ import { useComponentsContext } from '../../contexts/componentsContext/Component import { useTheme } from '../../contexts/themeContext/ThemeContext'; import { useTranslationContext } from '../../contexts/translationContext/TranslationContext'; import { MessageDeliveryStatus, useMessageDeliveryStatus } from '../../hooks'; -import { useStateStore } from '../../hooks/useStateStore'; import { primitives } from '../../theme'; import { MessageStatusTypes } from '../../utils/utils'; diff --git a/package/src/components/ui/GiphyChip.tsx b/package/src/components/ui/GiphyChip.tsx index 3f410a5173..06d1457598 100644 --- a/package/src/components/ui/GiphyChip.tsx +++ b/package/src/components/ui/GiphyChip.tsx @@ -1,12 +1,12 @@ import React, { useMemo } from 'react'; import { StyleSheet, View, Text, Pressable } from 'react-native'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import { TextComposerState } from 'stream-chat'; import { useComponentsContext } from '../../contexts/componentsContext/ComponentsContext'; import { useMessageComposer } from '../../contexts/messageInputContext/hooks/useMessageComposer'; import { useTheme } from '../../contexts/themeContext/ThemeContext'; -import { useStateStore } from '../../hooks/useStateStore'; import { primitives } from '../../theme'; const textComposerStateSelector = (state: TextComposerState) => ({ diff --git a/package/src/contexts/audioPlayerContext/AudioPlayerContext.tsx b/package/src/contexts/audioPlayerContext/AudioPlayerContext.tsx index af30ad7839..0273d2049b 100644 --- a/package/src/contexts/audioPlayerContext/AudioPlayerContext.tsx +++ b/package/src/contexts/audioPlayerContext/AudioPlayerContext.tsx @@ -1,6 +1,7 @@ import React, { createContext, PropsWithChildren, useContext, useEffect, useMemo } from 'react'; -import { useStateStore } from '../../hooks/useStateStore'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; + import { AudioPlayerPool, AudioPlayerPoolState } from '../../state-store/audio-player-pool'; import { DEFAULT_BASE_CONTEXT_VALUE } from '../utils/defaultBaseContextValue'; diff --git a/package/src/contexts/messageComposerContext/MessageComposerContext.tsx b/package/src/contexts/messageComposerContext/MessageComposerContext.tsx index 6ba9777d50..5848d46a8e 100644 --- a/package/src/contexts/messageComposerContext/MessageComposerContext.tsx +++ b/package/src/contexts/messageComposerContext/MessageComposerContext.tsx @@ -1,5 +1,6 @@ import React, { useContext, useEffect, useMemo, useState } from 'react'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import { LocalMessage, MessageComposer, MessageComposerState } from 'stream-chat'; import { @@ -9,7 +10,6 @@ import { import { ChannelProps } from '../../components'; import { useStableCallback } from '../../hooks/useStableCallback'; -import { useStateStore } from '../../hooks/useStateStore'; import { useChatContext } from '../chatContext/ChatContext'; import { ThreadContextValue } from '../threadContext/ThreadContext'; import { DEFAULT_BASE_CONTEXT_VALUE } from '../utils/defaultBaseContextValue'; diff --git a/package/src/contexts/messageInputContext/hooks/useActiveCommand.ts b/package/src/contexts/messageInputContext/hooks/useActiveCommand.ts index bdcbbcacce..adad7bb965 100644 --- a/package/src/contexts/messageInputContext/hooks/useActiveCommand.ts +++ b/package/src/contexts/messageInputContext/hooks/useActiveCommand.ts @@ -1,9 +1,8 @@ +import { useStateStore } from '@stream-io/state-store/react-bindings'; import { TextComposerState } from 'stream-chat'; import { useMessageComposer } from './useMessageComposer'; -import { useStateStore } from '../../../hooks/useStateStore'; - const activeCommandSelector = (state: TextComposerState) => ({ command: state.command, }); diff --git a/package/src/contexts/messageInputContext/hooks/useAttachmentManagerState.ts b/package/src/contexts/messageInputContext/hooks/useAttachmentManagerState.ts index dfb3185fe7..ce50f24d67 100644 --- a/package/src/contexts/messageInputContext/hooks/useAttachmentManagerState.ts +++ b/package/src/contexts/messageInputContext/hooks/useAttachmentManagerState.ts @@ -1,9 +1,8 @@ +import { useStateStore } from '@stream-io/state-store/react-bindings'; import type { AttachmentManagerState } from 'stream-chat'; import { useMessageComposer } from './useMessageComposer'; -import { useStateStore } from '../../../hooks/useStateStore'; - const stateSelector = (state: AttachmentManagerState) => ({ attachments: state.attachments, }); diff --git a/package/src/contexts/messageInputContext/hooks/useHasAttachments.ts b/package/src/contexts/messageInputContext/hooks/useHasAttachments.ts index 33e6d9c91b..3af3b57364 100644 --- a/package/src/contexts/messageInputContext/hooks/useHasAttachments.ts +++ b/package/src/contexts/messageInputContext/hooks/useHasAttachments.ts @@ -1,9 +1,8 @@ +import { useStateStore } from '@stream-io/state-store/react-bindings'; import type { AttachmentManagerState } from 'stream-chat'; import { useMessageComposer } from './useMessageComposer'; -import { useStateStore } from '../../../hooks/useStateStore'; - const stateSelector = (state: AttachmentManagerState) => ({ hasAttachments: state.attachments.length > 0, }); diff --git a/package/src/contexts/messageInputContext/hooks/useIsCommandDisabled.ts b/package/src/contexts/messageInputContext/hooks/useIsCommandDisabled.ts index 4cc02ee951..b4f6f49590 100644 --- a/package/src/contexts/messageInputContext/hooks/useIsCommandDisabled.ts +++ b/package/src/contexts/messageInputContext/hooks/useIsCommandDisabled.ts @@ -1,11 +1,10 @@ import { useMemo } from 'react'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import type { CommandSuggestion, MessageComposerState } from 'stream-chat'; import { useMessageComposer } from './useMessageComposer'; -import { useStateStore } from '../../../hooks/useStateStore'; - const hasQuotedMessageSelector = (state: MessageComposerState) => ({ hasQuotedMessage: !!state.quotedMessage, }); diff --git a/package/src/contexts/messageInputContext/hooks/useMessageComposerHasSendableData.ts b/package/src/contexts/messageInputContext/hooks/useMessageComposerHasSendableData.ts index fca2ac33c8..48874e6765 100644 --- a/package/src/contexts/messageInputContext/hooks/useMessageComposerHasSendableData.ts +++ b/package/src/contexts/messageInputContext/hooks/useMessageComposerHasSendableData.ts @@ -1,10 +1,9 @@ +import { useStateStore } from '@stream-io/state-store/react-bindings'; import type { EditingAuditState } from 'stream-chat'; import { useMessageComposer } from './useMessageComposer'; import { pendingUploadsEnabledSelector } from './usePendingUploadsEnabled'; -import { useStateStore } from '../../../hooks/useStateStore'; - const editingAuditStateStateSelector = (state: EditingAuditState) => state; export const useMessageComposerHasSendableData = () => { diff --git a/package/src/contexts/messageInputContext/hooks/usePendingUploadsEnabled.ts b/package/src/contexts/messageInputContext/hooks/usePendingUploadsEnabled.ts index 95de069ce3..a0a4ce6494 100644 --- a/package/src/contexts/messageInputContext/hooks/usePendingUploadsEnabled.ts +++ b/package/src/contexts/messageInputContext/hooks/usePendingUploadsEnabled.ts @@ -1,9 +1,8 @@ +import { useStateStore } from '@stream-io/state-store/react-bindings'; import type { MessageComposerConfig } from 'stream-chat'; import { useMessageComposer } from './useMessageComposer'; -import { useStateStore } from '../../../hooks/useStateStore'; - export const pendingUploadsEnabledSelector = (config: MessageComposerConfig) => ({ pendingUploadsEnabled: config.attachments.pendingUploadsEnabled, }); diff --git a/package/src/hooks/__tests__/useStateStore.test.tsx b/package/src/hooks/__tests__/useStateStore.test.tsx new file mode 100644 index 0000000000..50fd5f0cf6 --- /dev/null +++ b/package/src/hooks/__tests__/useStateStore.test.tsx @@ -0,0 +1,109 @@ +import { StateStore } from '@stream-io/state-store'; +import { useStateStore as useBindingStateStore } from '@stream-io/state-store/react-bindings'; +import { act, renderHook } from '@testing-library/react-native'; + +import { useStateStore } from '..'; + +type State = { + count: number; + items: string[]; + label?: string; + unrelated: number; +}; + +const initialState: State = { count: 0, items: ['a'], unrelated: 0 }; + +const countSelector = (state: State) => ({ count: state.count }); +const itemsSelector = (state: State) => state.items; +// Includes `label` only when it is set, so the selection gains or loses a key. +const optionalKeySelector = (state: State) => + state.label === undefined ? { count: state.count } : { count: state.count, label: state.label }; + +describe('useStateStore', () => { + it('is the hook from the state-store React bindings', () => { + expect(useStateStore).toBe(useBindingStateStore); + }); + + it('returns the current selection and follows store changes', () => { + const store = new StateStore(initialState); + const { result } = renderHook(() => useStateStore(store, countSelector)); + + expect(result.current).toEqual({ count: 0 }); + + act(() => store.partialNext({ count: 1 })); + + expect(result.current).toEqual({ count: 1 }); + }); + + it('keeps the selection reference while the selected values are unchanged', () => { + const store = new StateStore(initialState); + const { rerender, result } = renderHook(() => useStateStore(store, countSelector)); + const first = result.current; + + act(() => store.partialNext({ unrelated: 1 })); + rerender({}); + + expect(result.current).toBe(first); + }); + + it('returns a new selection when it gains a key', () => { + const store = new StateStore(initialState); + const { result } = renderHook(() => useStateStore(store, optionalKeySelector)); + + expect(result.current).toEqual({ count: 0 }); + + act(() => store.partialNext({ label: 'new' })); + + expect(result.current).toEqual({ count: 0, label: 'new' }); + }); + + it('returns a new selection when it loses a key', () => { + const store = new StateStore({ ...initialState, label: 'old' }); + const { result } = renderHook(() => useStateStore(store, optionalKeySelector)); + + expect(result.current).toEqual({ count: 0, label: 'old' }); + + act(() => store.partialNext({ label: undefined })); + + expect(result.current).toEqual({ count: 0 }); + }); + + it('returns a new array selection when the array grows with the same prefix', () => { + const store = new StateStore(initialState); + const { result } = renderHook(() => useStateStore(store, itemsSelector)); + + expect(result.current).toEqual(['a']); + + act(() => store.partialNext({ items: ['a', 'b'] })); + + expect(result.current).toEqual(['a', 'b']); + }); + + it('returns a new array selection when the array shrinks', () => { + const store = new StateStore({ ...initialState, items: ['a', 'b'] }); + const { result } = renderHook(() => useStateStore(store, itemsSelector)); + + expect(result.current).toEqual(['a', 'b']); + + act(() => store.partialNext({ items: ['a'] })); + + expect(result.current).toEqual(['a']); + }); + + it('keeps the array reference when a new array holds the same items', () => { + const store = new StateStore(initialState); + const { rerender, result } = renderHook(() => useStateStore(store, itemsSelector)); + const first = result.current; + + act(() => store.partialNext({ items: ['a'] })); + rerender({}); + + expect(result.current).toBe(first); + }); + + it('returns undefined without a store', () => { + const { result } = renderHook(() => useStateStore(undefined, countSelector)); + + expect(result.current).toBeUndefined(); + }); +}); diff --git a/package/src/hooks/actions/useChannelActionItems.tsx b/package/src/hooks/actions/useChannelActionItems.tsx index 8708bf34f1..80412c5873 100644 --- a/package/src/hooks/actions/useChannelActionItems.tsx +++ b/package/src/hooks/actions/useChannelActionItems.tsx @@ -1,6 +1,7 @@ import React, { useMemo } from 'react'; import { Alert } from 'react-native'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import type { BlockedUsersState, Channel } from 'stream-chat'; import type { ActionItem } from './types'; @@ -20,7 +21,6 @@ import type { TranslationContextValue } from '../../contexts/translationContext/ import { IconProps } from '../../icons'; import { useChannelMembershipState } from '../useChannelMembershipState'; import { useIsDirectChat } from '../useIsDirectChat'; -import { useStateStore } from '../useStateStore'; // Required lazily: a static import of defaultComponents.ts would form a cycle // (defaultComponents -> ChannelDetails*/ChannelPreview* -> this file) and corrupt init order. diff --git a/package/src/hooks/actions/useChannelMemberActionItems.tsx b/package/src/hooks/actions/useChannelMemberActionItems.tsx index 16b9ae81e8..86b125d96f 100644 --- a/package/src/hooks/actions/useChannelMemberActionItems.tsx +++ b/package/src/hooks/actions/useChannelMemberActionItems.tsx @@ -1,6 +1,7 @@ import React, { useMemo } from 'react'; import { Alert } from 'react-native'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import type { BlockedUsersState, Channel, ChannelMemberResponse } from 'stream-chat'; import type { ActionItem } from './types'; @@ -14,7 +15,6 @@ import type { IconsMap } from '../../contexts/componentsContext/defaultComponent import type { TranslationContextValue } from '../../contexts/translationContext/TranslationContext'; import { IconProps } from '../../icons'; import { useChannelOwnCapabilities } from '../useChannelOwnCapabilities'; -import { useStateStore } from '../useStateStore'; // Required lazily: a static import of defaultComponents.ts would form a cycle // (defaultComponents -> ChannelDetails*/ChannelPreview* -> this file) and corrupt init order. diff --git a/package/src/hooks/index.ts b/package/src/hooks/index.ts index 375a0d4bf8..9d674504dd 100644 --- a/package/src/hooks/index.ts +++ b/package/src/hooks/index.ts @@ -18,7 +18,7 @@ export * from './useTranslatedMessage'; export * from './useViewport'; export * from './useScreenDimensions'; export * from './useScreenOrientation'; -export * from './useStateStore'; +export { useStateStore } from '@stream-io/state-store/react-bindings'; export * from './useChannel'; export * from './useMessagePaginator'; export * from './usePendingAttachmentUpload'; diff --git a/package/src/hooks/messagePreview/useMessageDeliveryStatus.ts b/package/src/hooks/messagePreview/useMessageDeliveryStatus.ts index 99a3bf4438..75269b91c9 100644 --- a/package/src/hooks/messagePreview/useMessageDeliveryStatus.ts +++ b/package/src/hooks/messagePreview/useMessageDeliveryStatus.ts @@ -1,5 +1,6 @@ import { useCallback, useMemo } from 'react'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import { Channel, LocalMessage, @@ -9,7 +10,6 @@ import { } from 'stream-chat'; import { useChatContext } from '../../contexts/chatContext/ChatContext'; -import { useStateStore } from '../useStateStore'; export enum MessageDeliveryStatus { NOT_SENT_BY_CURRENT_USER = 'not_sent_by_current_user', diff --git a/package/src/hooks/messagePreview/useMessagePreviewText.tsx b/package/src/hooks/messagePreview/useMessagePreviewText.tsx index 15bf425b22..dd30bb7df8 100644 --- a/package/src/hooks/messagePreview/useMessagePreviewText.tsx +++ b/package/src/hooks/messagePreview/useMessagePreviewText.tsx @@ -1,3 +1,4 @@ +import { useStateStore } from '@stream-io/state-store/react-bindings'; import dayjs from 'dayjs'; import { DraftMessage, @@ -13,7 +14,6 @@ import { useGroupedAttachments } from './useGroupedAttachments'; import { useChatContext } from '../../contexts/chatContext/ChatContext'; import { useTranslationContext } from '../../contexts/translationContext/TranslationContext'; -import { useStateStore } from '../../hooks/useStateStore'; import { getTranslatedText } from '../../utils/i18n/getTranslatedText'; const selector = (nextValue: PollState) => ({ diff --git a/package/src/hooks/useAttachmentPickerState.ts b/package/src/hooks/useAttachmentPickerState.ts index 14591f856c..bf11d665cc 100644 --- a/package/src/hooks/useAttachmentPickerState.ts +++ b/package/src/hooks/useAttachmentPickerState.ts @@ -1,4 +1,4 @@ -import { useStateStore } from './useStateStore'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import { useAttachmentPickerContext } from '../contexts/attachmentPickerContext/AttachmentPickerContext'; import { AttachmentPickerState } from '../state-store/attachment-picker-store'; diff --git a/package/src/hooks/useChannelImage.ts b/package/src/hooks/useChannelImage.ts index 203d6d8b1b..68f5195e80 100644 --- a/package/src/hooks/useChannelImage.ts +++ b/package/src/hooks/useChannelImage.ts @@ -1,7 +1,6 @@ +import { useStateStore } from '@stream-io/state-store/react-bindings'; import { Channel } from 'stream-chat'; -import { useStateStore } from './useStateStore'; - const selector = (state: { data: Channel['data'] }) => ({ image: state.data?.custom?.image, }); diff --git a/package/src/hooks/useChannelMemberCount.ts b/package/src/hooks/useChannelMemberCount.ts index 86241c0963..3670d8213c 100644 --- a/package/src/hooks/useChannelMemberCount.ts +++ b/package/src/hooks/useChannelMemberCount.ts @@ -1,7 +1,6 @@ +import { useStateStore } from '@stream-io/state-store/react-bindings'; import { Channel } from 'stream-chat'; -import { useStateStore } from './useStateStore'; - const selector = (state: { memberCount: number }) => ({ memberCount: state.memberCount, }); diff --git a/package/src/hooks/useChannelMembershipState.ts b/package/src/hooks/useChannelMembershipState.ts index b4083fb7f5..06c0111d40 100644 --- a/package/src/hooks/useChannelMembershipState.ts +++ b/package/src/hooks/useChannelMembershipState.ts @@ -1,7 +1,6 @@ +import { useStateStore } from '@stream-io/state-store/react-bindings'; import { Channel, ChannelMemberResponse } from 'stream-chat'; -import { useStateStore } from './useStateStore'; - const selector = (state: { membership: ChannelMemberResponse }) => ({ membership: state.membership, }); diff --git a/package/src/hooks/useChannelName.ts b/package/src/hooks/useChannelName.ts index 1e1440ef26..761fe5d6db 100644 --- a/package/src/hooks/useChannelName.ts +++ b/package/src/hooks/useChannelName.ts @@ -1,7 +1,6 @@ +import { useStateStore } from '@stream-io/state-store/react-bindings'; import { Channel } from 'stream-chat'; -import { useStateStore } from './useStateStore'; - const selector = (state: { data: Channel['data'] }) => ({ name: state.data?.custom?.name, }); diff --git a/package/src/hooks/useChannelOwnCapabilities.ts b/package/src/hooks/useChannelOwnCapabilities.ts index 16cd1b6a5e..ec1481c38f 100644 --- a/package/src/hooks/useChannelOwnCapabilities.ts +++ b/package/src/hooks/useChannelOwnCapabilities.ts @@ -1,7 +1,6 @@ +import { useStateStore } from '@stream-io/state-store/react-bindings'; import type { Channel } from 'stream-chat'; -import { useStateStore } from './useStateStore'; - const selector = (state: { ownCapabilities: string[] }) => ({ ownCapabilities: state.ownCapabilities, }); diff --git a/package/src/hooks/useClientNotifications.ts b/package/src/hooks/useClientNotifications.ts index 50dd98030c..d29194fe46 100644 --- a/package/src/hooks/useClientNotifications.ts +++ b/package/src/hooks/useClientNotifications.ts @@ -1,7 +1,6 @@ +import { useStateStore } from '@stream-io/state-store/react-bindings'; import type { NotificationManagerState } from 'stream-chat'; -import { useStateStore } from './useStateStore'; - import { useChatContext } from '../contexts/chatContext/ChatContext'; const selector = (state: NotificationManagerState) => ({ diff --git a/package/src/hooks/useDisplayedChannelMemberCount.ts b/package/src/hooks/useDisplayedChannelMemberCount.ts index 5875a37dab..d7b51ce971 100644 --- a/package/src/hooks/useDisplayedChannelMemberCount.ts +++ b/package/src/hooks/useDisplayedChannelMemberCount.ts @@ -1,7 +1,6 @@ +import { useStateStore } from '@stream-io/state-store/react-bindings'; import { Channel } from 'stream-chat'; -import { useStateStore } from './useStateStore'; - const selector = (state: { activeMemberCount?: number; memberCount: number }) => ({ activeMemberCount: state.activeMemberCount, memberCount: state.memberCount, diff --git a/package/src/hooks/useInAppNotificationsState.ts b/package/src/hooks/useInAppNotificationsState.ts index e4c8b0f636..e1d8b0a825 100644 --- a/package/src/hooks/useInAppNotificationsState.ts +++ b/package/src/hooks/useInAppNotificationsState.ts @@ -1,7 +1,7 @@ +import { useStateStore } from '@stream-io/state-store/react-bindings'; import { Notification } from 'stream-chat'; import { useStableCallback } from './useStableCallback'; -import { useStateStore } from './useStateStore'; import type { InAppNotificationsState } from '../state-store/in-app-notifications-store'; import { diff --git a/package/src/hooks/useIsTargetedMessage.ts b/package/src/hooks/useIsTargetedMessage.ts index 58066e596b..799474a8cb 100644 --- a/package/src/hooks/useIsTargetedMessage.ts +++ b/package/src/hooks/useIsTargetedMessage.ts @@ -1,7 +1,8 @@ import { useCallback } from 'react'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; + import { useMessagePaginator } from './useMessagePaginator'; -import { useStateStore } from './useStateStore'; type MessageFocusSignalState = { signal: { messageId?: string } | null }; diff --git a/package/src/hooks/useMessageReminder.ts b/package/src/hooks/useMessageReminder.ts index 00d4372c26..5f2c7749d8 100644 --- a/package/src/hooks/useMessageReminder.ts +++ b/package/src/hooks/useMessageReminder.ts @@ -1,9 +1,8 @@ import { useCallback } from 'react'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import type { ReminderManagerState } from 'stream-chat'; -import { useStateStore } from './useStateStore'; - import { useChatContext } from '../contexts/chatContext/ChatContext'; export const useMessageReminder = (messageId: string) => { diff --git a/package/src/hooks/usePendingAttachmentUpload.ts b/package/src/hooks/usePendingAttachmentUpload.ts index fa6bbed030..18b49aa4ac 100644 --- a/package/src/hooks/usePendingAttachmentUpload.ts +++ b/package/src/hooks/usePendingAttachmentUpload.ts @@ -1,9 +1,8 @@ import { useCallback, useEffect, useRef, useState } from 'react'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import type { UploadManagerState } from 'stream-chat'; -import { useStateStore } from './useStateStore'; - import { useChatContext } from '../contexts/chatContext/ChatContext'; export type PendingAttachmentUpload = { diff --git a/package/src/hooks/usePrunableMessageList.ts b/package/src/hooks/usePrunableMessageList.ts index ef5ae99a61..583c69de57 100644 --- a/package/src/hooks/usePrunableMessageList.ts +++ b/package/src/hooks/usePrunableMessageList.ts @@ -1,9 +1,9 @@ import { useEffect, useRef } from 'react'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import type { MessagePaginator } from 'stream-chat'; import { useStableCallback } from './useStableCallback'; -import { useStateStore } from './useStateStore'; import type { ViewToken } from '../types/react-native-compat'; diff --git a/package/src/hooks/useQueryReminders.ts b/package/src/hooks/useQueryReminders.ts index 5864f77ca9..31548adbb7 100644 --- a/package/src/hooks/useQueryReminders.ts +++ b/package/src/hooks/useQueryReminders.ts @@ -1,11 +1,10 @@ import { useCallback, useEffect, useRef, useState } from 'react'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import { EventPayload, PaginatorState, ReminderFilters, ReminderResponseData } from 'stream-chat'; import { nowNs } from 'stream-chat'; -import { useStateStore } from './useStateStore'; - import { useChatContext } from '../contexts/chatContext/ChatContext'; const selector = (nextValue: PaginatorState) => diff --git a/package/src/hooks/useStateStore.ts b/package/src/hooks/useStateStore.ts deleted file mode 100644 index 320ae6e688..0000000000 --- a/package/src/hooks/useStateStore.ts +++ /dev/null @@ -1,64 +0,0 @@ -import { useCallback, useMemo } from 'react'; - -import type { StateStore } from '@stream-io/state-store'; -import { useSyncExternalStore } from 'use-sync-external-store/shim'; - -const noop = () => {}; - -export function useStateStore< - T extends Record, - O extends Readonly | Readonly>, ->(store: StateStore, selector: (v: T) => O): O; -export function useStateStore< - T extends Record, - O extends Readonly | Readonly>, ->(store: StateStore | undefined, selector: (v: T) => O): O | undefined; -export function useStateStore< - T extends Record, - O extends Readonly | Readonly>, ->(store: StateStore | undefined, selector: (v: T) => O) { - const wrappedSubscription = useCallback( - (onStoreChange: () => void) => { - const unsubscribe = store?.subscribeWithSelector(selector, onStoreChange); - return unsubscribe ?? noop; - }, - [store, selector], - ); - - const wrappedSnapshot = useMemo(() => { - let cachedTuple: [T, O]; - - return () => { - const currentValue = store?.getLatestValue(); - - if (!currentValue) return undefined; - - // store value hasn't changed, no need to compare individual values - if (cachedTuple && cachedTuple[0] === currentValue) { - return cachedTuple[1]; - } - - const newlySelected = selector(currentValue); - - // store value changed but selected values wouldn't have to, double-check selected - if (cachedTuple) { - let selectededAreEqualToCached = true; - - for (const key in cachedTuple[1]) { - if (cachedTuple[1][key] === newlySelected[key]) continue; - selectededAreEqualToCached = false; - break; - } - - if (selectededAreEqualToCached) return cachedTuple[1]; - } - - cachedTuple = [currentValue, newlySelected]; - return cachedTuple[1]; - }; - }, [store, selector]); - - const state = useSyncExternalStore(wrappedSubscription, wrappedSnapshot); - - return state; -} diff --git a/package/src/hooks/useStreami18n.ts b/package/src/hooks/useStreami18n.ts index 00422897db..9caf4b48b5 100644 --- a/package/src/hooks/useStreami18n.ts +++ b/package/src/hooks/useStreami18n.ts @@ -2,7 +2,7 @@ import { useEffect, useMemo } from 'react'; import type { Streami18nState } from '@stream-io/i18n'; -import { useStateStore } from './useStateStore'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import type { TranslatorFunctions } from '../contexts/translationContext/types'; import type { BundledTranslationKey } from '../i18n/keys'; diff --git a/package/src/state-store/edit-channel-details-store.ts b/package/src/state-store/edit-channel-details-store.ts index 473143cc3c..f742020fe8 100644 --- a/package/src/state-store/edit-channel-details-store.ts +++ b/package/src/state-store/edit-channel-details-store.ts @@ -1,7 +1,7 @@ import { StateStore } from '@stream-io/state-store'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import { Channel } from 'stream-chat'; -import { useStateStore } from '../hooks/useStateStore'; import type { File } from '../types/types'; export type EditChannelImagePendingAction = 'camera' | 'library' | 'reset'; diff --git a/package/src/state-store/message-overlay-store.ts b/package/src/state-store/message-overlay-store.ts index f3bdcb7fe7..953e295f80 100644 --- a/package/src/state-store/message-overlay-store.ts +++ b/package/src/state-store/message-overlay-store.ts @@ -3,10 +3,9 @@ import { useCallback, useEffect, useRef } from 'react'; import { makeMutable, type SharedValue } from 'react-native-reanimated'; import { StateStore } from '@stream-io/state-store'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; import { useSyncExternalStore } from 'use-sync-external-store/shim'; -import { useStateStore } from '../hooks'; - type OverlayState = { closingPortalHostBlacklist: string[]; id: string | undefined; diff --git a/package/src/state-store/selection-store.ts b/package/src/state-store/selection-store.ts index c1c4a7e432..df45bb15cc 100644 --- a/package/src/state-store/selection-store.ts +++ b/package/src/state-store/selection-store.ts @@ -2,7 +2,7 @@ import { useCallback } from 'react'; import { StateStore } from '@stream-io/state-store'; -import { useStateStore } from '../hooks/useStateStore'; +import { useStateStore } from '@stream-io/state-store/react-bindings'; export type SelectionState = { /** IDs of the currently selected items. */ diff --git a/yarn.lock b/yarn.lock index 2760258c9f..e3965734e6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6757,9 +6757,9 @@ __metadata: languageName: node linkType: hard -"@stream-io/state-store@npm:^1.2.0": - version: 1.2.0 - resolution: "@stream-io/state-store@npm:1.2.0" +"@stream-io/state-store@npm:^1.2.0, @stream-io/state-store@npm:^1.3.1": + version: 1.3.1 + resolution: "@stream-io/state-store@npm:1.3.1" peerDependencies: react: ^17 || ^18 || ^19 use-sync-external-store: ^1.5.0 @@ -6768,7 +6768,7 @@ __metadata: optional: true use-sync-external-store: optional: true - checksum: 10c0/27179805cb9a042416c741e1759c3324eefae0b27612c50f5fa0e0e13675d71bbe0a324978fcb5fdceaa4df5a99d11c6746eae319761216861b338e8cb7f1928 + checksum: 10c0/20d58fb89e1bca05ecd4a7d74bcdf01290053d3ddafb4ce4716279bbf68272f393e25ece4e7152adfe031ad582d3e8bce080901b6b66694663212dd8c55cf46f languageName: node linkType: hard @@ -19631,7 +19631,7 @@ __metadata: "@react-navigation/native-stack": "npm:^7.20.0" "@rnx-kit/metro-config": "npm:^2.2.6" "@shopify/flash-list": "npm:^2.3.3" - "@stream-io/state-store": "npm:^1.2.0" + "@stream-io/state-store": "npm:^1.3.1" "@stream-io/typescript-config": "workspace:^" "@types/lodash.mergewith": "npm:^4.6.9" "@types/react": "npm:^19.3.0" @@ -20464,7 +20464,7 @@ __metadata: "@shopify/flash-list": "npm:^2.3.3" "@shopify/react-native-skia": "npm:^2.13.0" "@stream-io/i18n": "npm:^1.1.0" - "@stream-io/state-store": "npm:^1.2.0" + "@stream-io/state-store": "npm:^1.3.1" "@stream-io/typescript-config": "workspace:^" "@testing-library/jest-native": "npm:^5.4.3" "@testing-library/react-native": "npm:13.2.0"