stream-chat-react-native-core 9.2.0-beta.2 → 9.2.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/commonjs/components/AttachmentPicker/components/AttachmentPickerContent.js +2 -2
- package/lib/commonjs/components/AttachmentPicker/components/AttachmentPickerContent.js.map +1 -1
- package/lib/commonjs/components/Channel/Channel.js +10 -1
- package/lib/commonjs/components/Channel/Channel.js.map +1 -1
- package/lib/commonjs/components/Channel/hooks/useMessageListPagination.js +26 -3
- package/lib/commonjs/components/Channel/hooks/useMessageListPagination.js.map +1 -1
- package/lib/commonjs/components/ChannelList/ChannelList.js +29 -4
- package/lib/commonjs/components/ChannelList/ChannelList.js.map +1 -1
- package/lib/commonjs/components/ChannelList/hooks/useChannelActions.js +314 -11
- package/lib/commonjs/components/ChannelList/hooks/useChannelActions.js.map +1 -1
- package/lib/commonjs/components/Message/hooks/useMessageActionHandlers.js +202 -15
- package/lib/commonjs/components/Message/hooks/useMessageActionHandlers.js.map +1 -1
- package/lib/commonjs/components/MessageInput/MessageComposer.js +1 -1
- package/lib/commonjs/components/MessageInput/MessageComposerLeadingView.js +1 -1
- package/lib/commonjs/components/MessageInput/MessageComposerLeadingView.js.map +1 -1
- package/lib/commonjs/components/MessageInput/MessageInputHeaderView.js +1 -1
- package/lib/commonjs/components/MessageInput/MessageInputHeaderView.js.map +1 -1
- package/lib/commonjs/components/MessageInput/MessageInputTrailingView.js +1 -1
- package/lib/commonjs/components/MessageInput/MessageInputTrailingView.js.map +1 -1
- package/lib/commonjs/components/MessageInput/components/AttachmentPreview/AttachmentUploadPreviewList.js +7 -13
- package/lib/commonjs/components/MessageInput/components/AttachmentPreview/AttachmentUploadPreviewList.js.map +1 -1
- package/lib/commonjs/components/MessageInput/components/AudioRecorder/AudioRecorder.js +27 -6
- package/lib/commonjs/components/MessageInput/components/AudioRecorder/AudioRecorder.js.map +1 -1
- package/lib/commonjs/components/MessageInput/components/AudioRecorder/AudioRecordingButton.js +29 -9
- package/lib/commonjs/components/MessageInput/components/AudioRecorder/AudioRecordingButton.js.map +1 -1
- package/lib/commonjs/components/MessageInput/components/OutputButtons/index.js +1 -1
- package/lib/commonjs/components/MessageList/MessageFlashList.js +5 -2
- package/lib/commonjs/components/MessageList/MessageFlashList.js.map +1 -1
- package/lib/commonjs/components/MessageList/MessageList.js +5 -2
- package/lib/commonjs/components/MessageList/MessageList.js.map +1 -1
- package/lib/commonjs/components/MessageMenu/hooks/useFetchReactions.js +23 -2
- package/lib/commonjs/components/MessageMenu/hooks/useFetchReactions.js.map +1 -1
- package/lib/commonjs/components/Notifications/Notification.js +230 -0
- package/lib/commonjs/components/Notifications/Notification.js.map +1 -0
- package/lib/commonjs/components/Notifications/NotificationList.js +120 -0
- package/lib/commonjs/components/Notifications/NotificationList.js.map +1 -0
- package/lib/commonjs/components/Notifications/NotificationTargetContext.js +45 -0
- package/lib/commonjs/components/Notifications/NotificationTargetContext.js.map +1 -0
- package/lib/commonjs/components/Notifications/hooks/index.js +59 -0
- package/lib/commonjs/components/Notifications/hooks/index.js.map +1 -0
- package/lib/commonjs/components/Notifications/hooks/useNotificationApi.js +133 -0
- package/lib/commonjs/components/Notifications/hooks/useNotificationApi.js.map +1 -0
- package/lib/commonjs/components/Notifications/hooks/useNotificationListController.js +133 -0
- package/lib/commonjs/components/Notifications/hooks/useNotificationListController.js.map +1 -0
- package/lib/commonjs/components/Notifications/hooks/useNotificationTarget.js +26 -0
- package/lib/commonjs/components/Notifications/hooks/useNotificationTarget.js.map +1 -0
- package/lib/commonjs/components/Notifications/hooks/useNotifications.js +26 -0
- package/lib/commonjs/components/Notifications/hooks/useNotifications.js.map +1 -0
- package/lib/commonjs/components/Notifications/hooks/useSystemNotifications.js +22 -0
- package/lib/commonjs/components/Notifications/hooks/useSystemNotifications.js.map +1 -0
- package/lib/commonjs/components/Notifications/index.js +59 -0
- package/lib/commonjs/components/Notifications/index.js.map +1 -0
- package/lib/commonjs/components/Notifications/notificationTarget.js +220 -0
- package/lib/commonjs/components/Notifications/notificationTarget.js.map +1 -0
- package/lib/commonjs/components/Notifications/notificationTranslations.js +137 -0
- package/lib/commonjs/components/Notifications/notificationTranslations.js.map +1 -0
- package/lib/commonjs/components/Poll/components/PollOption.js +14 -9
- package/lib/commonjs/components/Poll/components/PollOption.js.map +1 -1
- package/lib/commonjs/components/Poll/hooks/usePollState.js +35 -3
- package/lib/commonjs/components/Poll/hooks/usePollState.js.map +1 -1
- package/lib/commonjs/components/Thread/Thread.js +19 -11
- package/lib/commonjs/components/Thread/Thread.js.map +1 -1
- package/lib/commonjs/components/ThreadList/ThreadList.js +30 -9
- package/lib/commonjs/components/ThreadList/ThreadList.js.map +1 -1
- package/lib/commonjs/components/index.js +11 -0
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/contexts/componentsContext/defaultComponents.js +4 -0
- package/lib/commonjs/contexts/componentsContext/defaultComponents.js.map +1 -1
- package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js +37 -0
- package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js.map +1 -1
- package/lib/commonjs/contexts/themeContext/utils/theme.js +13 -0
- package/lib/commonjs/contexts/themeContext/utils/theme.js.map +1 -1
- package/lib/commonjs/hooks/index.js +11 -0
- package/lib/commonjs/hooks/index.js.map +1 -1
- package/lib/commonjs/hooks/useAudioPlayer.js +34 -1
- package/lib/commonjs/hooks/useAudioPlayer.js.map +1 -1
- package/lib/commonjs/hooks/useInAppNotificationsState.js.map +1 -1
- package/lib/commonjs/hooks/useLazyRef.js +13 -0
- package/lib/commonjs/hooks/useLazyRef.js.map +1 -0
- package/lib/commonjs/i18n/en.json +60 -1
- package/lib/commonjs/i18n/es.json +62 -3
- package/lib/commonjs/i18n/fr.json +60 -1
- package/lib/commonjs/i18n/he.json +60 -1
- package/lib/commonjs/i18n/hi.json +60 -1
- package/lib/commonjs/i18n/it.json +60 -1
- package/lib/commonjs/i18n/ja.json +60 -1
- package/lib/commonjs/i18n/ko.json +60 -1
- package/lib/commonjs/i18n/nl.json +60 -1
- package/lib/commonjs/i18n/pt-br.json +60 -1
- package/lib/commonjs/i18n/ru.json +60 -1
- package/lib/commonjs/i18n/tr.json +60 -1
- package/lib/commonjs/state-store/audio-player-pool.js +1 -0
- package/lib/commonjs/state-store/audio-player-pool.js.map +1 -1
- package/lib/commonjs/state-store/audio-player.js +92 -13
- package/lib/commonjs/state-store/audio-player.js.map +1 -1
- package/lib/commonjs/theme/generated/dark/StreamTokens.android.js +16 -16
- package/lib/commonjs/theme/generated/dark/StreamTokens.android.js.map +1 -1
- package/lib/commonjs/theme/generated/dark/StreamTokens.ios.js +8 -8
- package/lib/commonjs/theme/generated/dark/StreamTokens.ios.js.map +1 -1
- package/lib/commonjs/theme/generated/dark/StreamTokens.web.js +8 -8
- package/lib/commonjs/theme/generated/dark/StreamTokens.web.js.map +1 -1
- package/lib/commonjs/theme/generated/light/StreamTokens.android.js +16 -16
- package/lib/commonjs/theme/generated/light/StreamTokens.android.js.map +1 -1
- package/lib/commonjs/theme/generated/light/StreamTokens.ios.js +8 -8
- package/lib/commonjs/theme/generated/light/StreamTokens.ios.js.map +1 -1
- package/lib/commonjs/theme/generated/light/StreamTokens.web.js +8 -8
- package/lib/commonjs/theme/generated/light/StreamTokens.web.js.map +1 -1
- package/lib/commonjs/utils/animations/createBoundedZoomTransition.js +151 -0
- package/lib/commonjs/utils/animations/createBoundedZoomTransition.js.map +1 -0
- package/lib/commonjs/utils/{transitions.js → animations/transitions.js} +6 -0
- package/lib/commonjs/utils/animations/transitions.js.map +1 -0
- package/lib/commonjs/version.json +1 -1
- package/lib/module/components/AttachmentPicker/components/AttachmentPickerContent.js +2 -2
- package/lib/module/components/AttachmentPicker/components/AttachmentPickerContent.js.map +1 -1
- package/lib/module/components/Channel/Channel.js +10 -1
- package/lib/module/components/Channel/Channel.js.map +1 -1
- package/lib/module/components/Channel/hooks/useMessageListPagination.js +26 -3
- package/lib/module/components/Channel/hooks/useMessageListPagination.js.map +1 -1
- package/lib/module/components/ChannelList/ChannelList.js +29 -4
- package/lib/module/components/ChannelList/ChannelList.js.map +1 -1
- package/lib/module/components/ChannelList/hooks/useChannelActions.js +314 -11
- package/lib/module/components/ChannelList/hooks/useChannelActions.js.map +1 -1
- package/lib/module/components/Message/hooks/useMessageActionHandlers.js +202 -15
- package/lib/module/components/Message/hooks/useMessageActionHandlers.js.map +1 -1
- package/lib/module/components/MessageInput/MessageComposer.js +1 -1
- package/lib/module/components/MessageInput/MessageComposerLeadingView.js +1 -1
- package/lib/module/components/MessageInput/MessageComposerLeadingView.js.map +1 -1
- package/lib/module/components/MessageInput/MessageInputHeaderView.js +1 -1
- package/lib/module/components/MessageInput/MessageInputHeaderView.js.map +1 -1
- package/lib/module/components/MessageInput/MessageInputTrailingView.js +1 -1
- package/lib/module/components/MessageInput/MessageInputTrailingView.js.map +1 -1
- package/lib/module/components/MessageInput/components/AttachmentPreview/AttachmentUploadPreviewList.js +7 -13
- package/lib/module/components/MessageInput/components/AttachmentPreview/AttachmentUploadPreviewList.js.map +1 -1
- package/lib/module/components/MessageInput/components/AudioRecorder/AudioRecorder.js +27 -6
- package/lib/module/components/MessageInput/components/AudioRecorder/AudioRecorder.js.map +1 -1
- package/lib/module/components/MessageInput/components/AudioRecorder/AudioRecordingButton.js +29 -9
- package/lib/module/components/MessageInput/components/AudioRecorder/AudioRecordingButton.js.map +1 -1
- package/lib/module/components/MessageInput/components/OutputButtons/index.js +1 -1
- package/lib/module/components/MessageList/MessageFlashList.js +5 -2
- package/lib/module/components/MessageList/MessageFlashList.js.map +1 -1
- package/lib/module/components/MessageList/MessageList.js +5 -2
- package/lib/module/components/MessageList/MessageList.js.map +1 -1
- package/lib/module/components/MessageMenu/hooks/useFetchReactions.js +23 -2
- package/lib/module/components/MessageMenu/hooks/useFetchReactions.js.map +1 -1
- package/lib/module/components/Notifications/Notification.js +230 -0
- package/lib/module/components/Notifications/Notification.js.map +1 -0
- package/lib/module/components/Notifications/NotificationList.js +120 -0
- package/lib/module/components/Notifications/NotificationList.js.map +1 -0
- package/lib/module/components/Notifications/NotificationTargetContext.js +45 -0
- package/lib/module/components/Notifications/NotificationTargetContext.js.map +1 -0
- package/lib/module/components/Notifications/hooks/index.js +59 -0
- package/lib/module/components/Notifications/hooks/index.js.map +1 -0
- package/lib/module/components/Notifications/hooks/useNotificationApi.js +133 -0
- package/lib/module/components/Notifications/hooks/useNotificationApi.js.map +1 -0
- package/lib/module/components/Notifications/hooks/useNotificationListController.js +133 -0
- package/lib/module/components/Notifications/hooks/useNotificationListController.js.map +1 -0
- package/lib/module/components/Notifications/hooks/useNotificationTarget.js +26 -0
- package/lib/module/components/Notifications/hooks/useNotificationTarget.js.map +1 -0
- package/lib/module/components/Notifications/hooks/useNotifications.js +26 -0
- package/lib/module/components/Notifications/hooks/useNotifications.js.map +1 -0
- package/lib/module/components/Notifications/hooks/useSystemNotifications.js +22 -0
- package/lib/module/components/Notifications/hooks/useSystemNotifications.js.map +1 -0
- package/lib/module/components/Notifications/index.js +59 -0
- package/lib/module/components/Notifications/index.js.map +1 -0
- package/lib/module/components/Notifications/notificationTarget.js +220 -0
- package/lib/module/components/Notifications/notificationTarget.js.map +1 -0
- package/lib/module/components/Notifications/notificationTranslations.js +137 -0
- package/lib/module/components/Notifications/notificationTranslations.js.map +1 -0
- package/lib/module/components/Poll/components/PollOption.js +14 -9
- package/lib/module/components/Poll/components/PollOption.js.map +1 -1
- package/lib/module/components/Poll/hooks/usePollState.js +35 -3
- package/lib/module/components/Poll/hooks/usePollState.js.map +1 -1
- package/lib/module/components/Thread/Thread.js +19 -11
- package/lib/module/components/Thread/Thread.js.map +1 -1
- package/lib/module/components/ThreadList/ThreadList.js +30 -9
- package/lib/module/components/ThreadList/ThreadList.js.map +1 -1
- package/lib/module/components/index.js +11 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/contexts/componentsContext/defaultComponents.js +4 -0
- package/lib/module/contexts/componentsContext/defaultComponents.js.map +1 -1
- package/lib/module/contexts/messageInputContext/MessageInputContext.js +37 -0
- package/lib/module/contexts/messageInputContext/MessageInputContext.js.map +1 -1
- package/lib/module/contexts/themeContext/utils/theme.js +13 -0
- package/lib/module/contexts/themeContext/utils/theme.js.map +1 -1
- package/lib/module/hooks/index.js +11 -0
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/hooks/useAudioPlayer.js +34 -1
- package/lib/module/hooks/useAudioPlayer.js.map +1 -1
- package/lib/module/hooks/useInAppNotificationsState.js.map +1 -1
- package/lib/module/hooks/useLazyRef.js +13 -0
- package/lib/module/hooks/useLazyRef.js.map +1 -0
- package/lib/module/i18n/en.json +60 -1
- package/lib/module/i18n/es.json +62 -3
- package/lib/module/i18n/fr.json +60 -1
- package/lib/module/i18n/he.json +60 -1
- package/lib/module/i18n/hi.json +60 -1
- package/lib/module/i18n/it.json +60 -1
- package/lib/module/i18n/ja.json +60 -1
- package/lib/module/i18n/ko.json +60 -1
- package/lib/module/i18n/nl.json +60 -1
- package/lib/module/i18n/pt-br.json +60 -1
- package/lib/module/i18n/ru.json +60 -1
- package/lib/module/i18n/tr.json +60 -1
- package/lib/module/state-store/audio-player-pool.js +1 -0
- package/lib/module/state-store/audio-player-pool.js.map +1 -1
- package/lib/module/state-store/audio-player.js +92 -13
- package/lib/module/state-store/audio-player.js.map +1 -1
- package/lib/module/theme/generated/dark/StreamTokens.android.js +16 -16
- package/lib/module/theme/generated/dark/StreamTokens.android.js.map +1 -1
- package/lib/module/theme/generated/dark/StreamTokens.ios.js +8 -8
- package/lib/module/theme/generated/dark/StreamTokens.ios.js.map +1 -1
- package/lib/module/theme/generated/dark/StreamTokens.web.js +8 -8
- package/lib/module/theme/generated/dark/StreamTokens.web.js.map +1 -1
- package/lib/module/theme/generated/light/StreamTokens.android.js +16 -16
- package/lib/module/theme/generated/light/StreamTokens.android.js.map +1 -1
- package/lib/module/theme/generated/light/StreamTokens.ios.js +8 -8
- package/lib/module/theme/generated/light/StreamTokens.ios.js.map +1 -1
- package/lib/module/theme/generated/light/StreamTokens.web.js +8 -8
- package/lib/module/theme/generated/light/StreamTokens.web.js.map +1 -1
- package/lib/module/utils/animations/createBoundedZoomTransition.js +151 -0
- package/lib/module/utils/animations/createBoundedZoomTransition.js.map +1 -0
- package/lib/module/utils/{transitions.js → animations/transitions.js} +6 -0
- package/lib/module/utils/animations/transitions.js.map +1 -0
- package/lib/module/version.json +1 -1
- package/lib/typescript/components/AttachmentPicker/components/AttachmentPickerContent.d.ts.map +1 -1
- package/lib/typescript/components/Channel/Channel.d.ts +1 -0
- package/lib/typescript/components/Channel/Channel.d.ts.map +1 -1
- package/lib/typescript/components/Channel/hooks/useMessageListPagination.d.ts.map +1 -1
- package/lib/typescript/components/ChannelList/ChannelList.d.ts +1 -0
- package/lib/typescript/components/ChannelList/ChannelList.d.ts.map +1 -1
- package/lib/typescript/components/ChannelList/hooks/useChannelActions.d.ts.map +1 -1
- package/lib/typescript/components/Message/hooks/useMessageActionHandlers.d.ts.map +1 -1
- package/lib/typescript/components/MessageInput/components/AttachmentPreview/AttachmentUploadPreviewList.d.ts.map +1 -1
- package/lib/typescript/components/MessageInput/components/AudioRecorder/AudioRecorder.d.ts.map +1 -1
- package/lib/typescript/components/MessageInput/components/AudioRecorder/AudioRecordingButton.d.ts.map +1 -1
- package/lib/typescript/components/MessageList/MessageFlashList.d.ts.map +1 -1
- package/lib/typescript/components/MessageList/MessageList.d.ts.map +1 -1
- package/lib/typescript/components/MessageMenu/hooks/useFetchReactions.d.ts.map +1 -1
- package/lib/typescript/components/Notifications/Notification.d.ts +31 -0
- package/lib/typescript/components/Notifications/Notification.d.ts.map +1 -0
- package/lib/typescript/components/Notifications/NotificationList.d.ts +28 -0
- package/lib/typescript/components/Notifications/NotificationList.d.ts.map +1 -0
- package/lib/typescript/components/Notifications/NotificationTargetContext.d.ts +14 -0
- package/lib/typescript/components/Notifications/NotificationTargetContext.d.ts.map +1 -0
- package/lib/typescript/components/Notifications/hooks/index.d.ts +6 -0
- package/lib/typescript/components/Notifications/hooks/index.d.ts.map +1 -0
- package/lib/typescript/components/Notifications/hooks/useNotificationApi.d.ts +48 -0
- package/lib/typescript/components/Notifications/hooks/useNotificationApi.d.ts.map +1 -0
- package/lib/typescript/components/Notifications/hooks/useNotificationListController.d.ts +14 -0
- package/lib/typescript/components/Notifications/hooks/useNotificationListController.d.ts.map +1 -0
- package/lib/typescript/components/Notifications/hooks/useNotificationTarget.d.ts +3 -0
- package/lib/typescript/components/Notifications/hooks/useNotificationTarget.d.ts.map +1 -0
- package/lib/typescript/components/Notifications/hooks/useNotifications.d.ts +14 -0
- package/lib/typescript/components/Notifications/hooks/useNotifications.d.ts.map +1 -0
- package/lib/typescript/components/Notifications/hooks/useSystemNotifications.d.ts +9 -0
- package/lib/typescript/components/Notifications/hooks/useSystemNotifications.d.ts.map +1 -0
- package/lib/typescript/components/Notifications/index.d.ts +6 -0
- package/lib/typescript/components/Notifications/index.d.ts.map +1 -0
- package/lib/typescript/components/Notifications/notificationTarget.d.ts +55 -0
- package/lib/typescript/components/Notifications/notificationTarget.d.ts.map +1 -0
- package/lib/typescript/components/Notifications/notificationTranslations.d.ts +7 -0
- package/lib/typescript/components/Notifications/notificationTranslations.d.ts.map +1 -0
- package/lib/typescript/components/Poll/components/PollOption.d.ts.map +1 -1
- package/lib/typescript/components/Poll/hooks/usePollState.d.ts.map +1 -1
- package/lib/typescript/components/Thread/Thread.d.ts +1 -0
- package/lib/typescript/components/Thread/Thread.d.ts.map +1 -1
- package/lib/typescript/components/ThreadList/ThreadList.d.ts +3 -1
- package/lib/typescript/components/ThreadList/ThreadList.d.ts.map +1 -1
- package/lib/typescript/components/index.d.ts +1 -0
- package/lib/typescript/components/index.d.ts.map +1 -1
- package/lib/typescript/contexts/componentsContext/defaultComponents.d.ts +3 -0
- package/lib/typescript/contexts/componentsContext/defaultComponents.d.ts.map +1 -1
- package/lib/typescript/contexts/messageInputContext/MessageInputContext.d.ts.map +1 -1
- package/lib/typescript/contexts/themeContext/ThemeContext.d.ts +13 -0
- package/lib/typescript/contexts/themeContext/ThemeContext.d.ts.map +1 -1
- package/lib/typescript/contexts/themeContext/utils/theme.d.ts +13 -0
- package/lib/typescript/contexts/themeContext/utils/theme.d.ts.map +1 -1
- package/lib/typescript/hooks/index.d.ts +1 -0
- package/lib/typescript/hooks/index.d.ts.map +1 -1
- package/lib/typescript/hooks/useAudioPlayer.d.ts.map +1 -1
- package/lib/typescript/hooks/useInAppNotificationsState.d.ts +6 -0
- package/lib/typescript/hooks/useInAppNotificationsState.d.ts.map +1 -1
- package/lib/typescript/hooks/useLazyRef.d.ts +7 -0
- package/lib/typescript/hooks/useLazyRef.d.ts.map +1 -0
- package/lib/typescript/i18n/en.json +60 -1
- package/lib/typescript/i18n/es.json +62 -3
- package/lib/typescript/i18n/fr.json +60 -1
- package/lib/typescript/i18n/he.json +60 -1
- package/lib/typescript/i18n/hi.json +60 -1
- package/lib/typescript/i18n/it.json +60 -1
- package/lib/typescript/i18n/ja.json +60 -1
- package/lib/typescript/i18n/ko.json +60 -1
- package/lib/typescript/i18n/nl.json +60 -1
- package/lib/typescript/i18n/pt-br.json +60 -1
- package/lib/typescript/i18n/ru.json +60 -1
- package/lib/typescript/i18n/tr.json +60 -1
- package/lib/typescript/state-store/audio-player-pool.d.ts.map +1 -1
- package/lib/typescript/state-store/audio-player.d.ts +13 -0
- package/lib/typescript/state-store/audio-player.d.ts.map +1 -1
- package/lib/typescript/utils/animations/createBoundedZoomTransition.d.ts +21 -0
- package/lib/typescript/utils/animations/createBoundedZoomTransition.d.ts.map +1 -0
- package/lib/typescript/utils/animations/transitions.d.ts +21 -0
- package/lib/typescript/utils/animations/transitions.d.ts.map +1 -0
- package/lib/typescript/utils/i18n/Streami18n.d.ts +59 -0
- package/lib/typescript/utils/i18n/Streami18n.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/components/AttachmentPicker/components/AttachmentPickerContent.tsx +3 -3
- package/src/components/AttachmentPicker/components/__tests__/AttachmentPickerContent.test.tsx +19 -18
- package/src/components/Channel/Channel.tsx +15 -1
- package/src/components/Channel/__tests__/useMessageListPagination.test.tsx +34 -2
- package/src/components/Channel/hooks/useMessageListPagination.tsx +19 -3
- package/src/components/ChannelList/ChannelList.tsx +27 -5
- package/src/components/ChannelList/hooks/__tests__/useChannelActions.test.tsx +123 -0
- package/src/components/ChannelList/hooks/useChannelActions.ts +181 -12
- package/src/components/Message/hooks/__tests__/useMessageActionHandlers.test.tsx +131 -0
- package/src/components/Message/hooks/useMessageActionHandlers.ts +133 -23
- package/src/components/MessageInput/MessageComposer.tsx +1 -1
- package/src/components/MessageInput/MessageComposerLeadingView.tsx +1 -1
- package/src/components/MessageInput/MessageInputHeaderView.tsx +1 -1
- package/src/components/MessageInput/MessageInputTrailingView.tsx +1 -1
- package/src/components/MessageInput/components/AttachmentPreview/AttachmentUploadPreviewList.tsx +1 -10
- package/src/components/MessageInput/components/AudioRecorder/AudioRecorder.tsx +10 -2
- package/src/components/MessageInput/components/AudioRecorder/AudioRecordingButton.tsx +27 -13
- package/src/components/MessageInput/components/OutputButtons/index.tsx +1 -1
- package/src/components/MessageList/MessageFlashList.tsx +3 -1
- package/src/components/MessageList/MessageList.tsx +3 -1
- package/src/components/MessageList/__tests__/MessageList.test.tsx +35 -0
- package/src/components/MessageList/__tests__/__snapshots__/ScrollToBottomButton.test.tsx.snap +1 -1
- package/src/components/MessageMenu/hooks/useFetchReactions.ts +17 -2
- package/src/components/Notifications/Notification.tsx +253 -0
- package/src/components/Notifications/NotificationList.tsx +160 -0
- package/src/components/Notifications/NotificationTargetContext.tsx +45 -0
- package/src/components/Notifications/__tests__/NotificationList.test.tsx +480 -0
- package/src/components/Notifications/__tests__/notificationTarget.test.ts +157 -0
- package/src/components/Notifications/hooks/__tests__/useNotificationApi.test.tsx +172 -0
- package/src/components/Notifications/hooks/__tests__/useNotificationTarget.test.tsx +85 -0
- package/src/components/Notifications/hooks/index.ts +5 -0
- package/src/components/Notifications/hooks/useNotificationApi.ts +248 -0
- package/src/components/Notifications/hooks/useNotificationListController.ts +160 -0
- package/src/components/Notifications/hooks/useNotificationTarget.ts +37 -0
- package/src/components/Notifications/hooks/useNotifications.ts +43 -0
- package/src/components/Notifications/hooks/useSystemNotifications.ts +33 -0
- package/src/components/Notifications/index.ts +5 -0
- package/src/components/Notifications/notificationTarget.ts +305 -0
- package/src/components/Notifications/notificationTranslations.ts +142 -0
- package/src/components/Poll/components/PollOption.tsx +10 -6
- package/src/components/Poll/hooks/usePollState.ts +26 -2
- package/src/components/Thread/Thread.tsx +24 -16
- package/src/components/ThreadList/ThreadList.tsx +33 -9
- package/src/components/index.ts +2 -0
- package/src/contexts/componentsContext/defaultComponents.ts +4 -0
- package/src/contexts/messageInputContext/MessageInputContext.tsx +36 -0
- package/src/contexts/themeContext/utils/theme.ts +26 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useAudioPlayer.ts +44 -3
- package/src/hooks/useInAppNotificationsState.ts +6 -0
- package/src/hooks/useLazyRef.ts +15 -0
- package/src/i18n/en.json +60 -1
- package/src/i18n/es.json +62 -3
- package/src/i18n/fr.json +60 -1
- package/src/i18n/he.json +60 -1
- package/src/i18n/hi.json +60 -1
- package/src/i18n/it.json +60 -1
- package/src/i18n/ja.json +60 -1
- package/src/i18n/ko.json +60 -1
- package/src/i18n/nl.json +60 -1
- package/src/i18n/pt-br.json +60 -1
- package/src/i18n/ru.json +60 -1
- package/src/i18n/tr.json +60 -1
- package/src/state-store/__tests__/audio-player.test.ts +45 -0
- package/src/state-store/audio-player-pool.ts +1 -0
- package/src/state-store/audio-player.ts +108 -16
- package/src/theme/generated/dark/StreamTokens.android.ts +16 -16
- package/src/theme/generated/dark/StreamTokens.ios.ts +8 -8
- package/src/theme/generated/dark/StreamTokens.web.ts +8 -8
- package/src/theme/generated/light/StreamTokens.android.ts +16 -16
- package/src/theme/generated/light/StreamTokens.ios.ts +8 -8
- package/src/theme/generated/light/StreamTokens.web.ts +8 -8
- package/src/utils/animations/createBoundedZoomTransition.ts +117 -0
- package/src/utils/{transitions.ts → animations/transitions.ts} +6 -0
- package/src/version.json +1 -1
- package/lib/commonjs/utils/transitions.js.map +0 -1
- package/lib/module/utils/transitions.js.map +0 -1
- package/lib/typescript/utils/transitions.d.ts +0 -9
- package/lib/typescript/utils/transitions.d.ts.map +0 -1
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import type { Notification } from 'stream-chat';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
addNotificationTargetTag,
|
|
5
|
+
getChannelNotificationHostId,
|
|
6
|
+
getNotificationTarget,
|
|
7
|
+
getNotificationTargetPanel,
|
|
8
|
+
getNotificationTargetPanels,
|
|
9
|
+
getNotificationTargetTag,
|
|
10
|
+
getThreadNotificationHostId,
|
|
11
|
+
isNotificationForPanel,
|
|
12
|
+
isNotificationForTarget,
|
|
13
|
+
registerActiveNotificationTarget,
|
|
14
|
+
registerNotificationActionTarget,
|
|
15
|
+
resolveNotificationTargetTagIfNeeded,
|
|
16
|
+
} from '../notificationTarget';
|
|
17
|
+
|
|
18
|
+
const notification = (overrides: Partial<Notification>): Notification =>
|
|
19
|
+
({
|
|
20
|
+
createdAt: Date.now(),
|
|
21
|
+
id: 'notification-id',
|
|
22
|
+
message: 'Notification',
|
|
23
|
+
origin: { emitter: 'test' },
|
|
24
|
+
...overrides,
|
|
25
|
+
}) as Notification;
|
|
26
|
+
|
|
27
|
+
describe('notificationTarget', () => {
|
|
28
|
+
it('adds a target tag without duplicating existing tags', () => {
|
|
29
|
+
expect(addNotificationTargetTag('channel', ['target:channel', 'custom'])).toEqual([
|
|
30
|
+
'target:channel',
|
|
31
|
+
'custom',
|
|
32
|
+
]);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('reads exact host targets from tags', () => {
|
|
36
|
+
const result = notification({
|
|
37
|
+
tags: [getNotificationTargetTag('channel', 'channel:messaging:general')],
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
expect(getNotificationTarget(result)).toEqual({
|
|
41
|
+
hostId: 'channel:messaging:general',
|
|
42
|
+
panel: 'channel',
|
|
43
|
+
});
|
|
44
|
+
expect(
|
|
45
|
+
isNotificationForTarget(result, { hostId: 'channel:messaging:general', panel: 'channel' }),
|
|
46
|
+
).toBe(true);
|
|
47
|
+
expect(
|
|
48
|
+
isNotificationForTarget(result, { hostId: 'channel:messaging:random', panel: 'channel' }),
|
|
49
|
+
).toBe(false);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('supports custom target panels', () => {
|
|
53
|
+
const result = notification({
|
|
54
|
+
tags: [getNotificationTargetTag('custom-panel', 'custom-host')],
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
expect(getNotificationTarget(result)).toEqual({
|
|
58
|
+
hostId: 'custom-host',
|
|
59
|
+
panel: 'custom-panel',
|
|
60
|
+
});
|
|
61
|
+
expect(isNotificationForTarget(result, { hostId: 'custom-host', panel: 'custom-panel' })).toBe(
|
|
62
|
+
true,
|
|
63
|
+
);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('reads target panels from tags before origin context', () => {
|
|
67
|
+
const result = notification({
|
|
68
|
+
origin: { context: { panel: 'thread' }, emitter: 'test' },
|
|
69
|
+
tags: ['target:channel', 'target:thread-list'],
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
expect(getNotificationTargetPanel(result)).toBe('channel');
|
|
73
|
+
expect(getNotificationTargetPanels(result)).toEqual(['channel', 'thread-list']);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('falls back to origin context panel', () => {
|
|
77
|
+
const result = notification({
|
|
78
|
+
origin: { context: { panel: 'thread' }, emitter: 'test' },
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
expect(getNotificationTargetPanel(result)).toBe('thread');
|
|
82
|
+
expect(getNotificationTargetPanels(result)).toEqual(['thread']);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('infers exact targets from composer context', () => {
|
|
86
|
+
const channelResult = notification({
|
|
87
|
+
origin: {
|
|
88
|
+
context: { composer: { channel: { cid: 'messaging:general' }, threadId: null } },
|
|
89
|
+
emitter: 'MessageComposer',
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
const threadResult = notification({
|
|
93
|
+
origin: {
|
|
94
|
+
context: { composer: { channel: { cid: 'messaging:general' }, threadId: 'thread-id' } },
|
|
95
|
+
emitter: 'MessageComposer',
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
expect(getNotificationTarget(channelResult)).toEqual({
|
|
100
|
+
hostId: getChannelNotificationHostId('messaging:general'),
|
|
101
|
+
panel: 'channel',
|
|
102
|
+
});
|
|
103
|
+
expect(getNotificationTarget(threadResult)).toEqual({
|
|
104
|
+
hostId: getThreadNotificationHostId('thread-id'),
|
|
105
|
+
panel: 'thread',
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('does not fall back untagged notifications to the channel panel', () => {
|
|
110
|
+
const result = notification({});
|
|
111
|
+
|
|
112
|
+
expect(isNotificationForPanel(result, 'channel')).toBe(false);
|
|
113
|
+
expect(isNotificationForPanel(result, 'thread')).toBe(false);
|
|
114
|
+
expect(getNotificationTargetPanels(result)).toEqual([]);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('adds an exact target tag to untagged notifications from the active target', () => {
|
|
118
|
+
const owner = {};
|
|
119
|
+
const target = { hostId: 'channel:messaging:general', panel: 'channel' } as const;
|
|
120
|
+
const unregister = registerActiveNotificationTarget(owner, target);
|
|
121
|
+
const result = notification({});
|
|
122
|
+
|
|
123
|
+
expect(resolveNotificationTargetTagIfNeeded(owner, result)).toBe(true);
|
|
124
|
+
expect(result.tags).toEqual(['target:channel:channel:messaging:general']);
|
|
125
|
+
expect(isNotificationForTarget(result, target)).toBe(true);
|
|
126
|
+
|
|
127
|
+
unregister();
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it('prefers action target over active target when adding exact target tags', () => {
|
|
131
|
+
const owner = {};
|
|
132
|
+
const actionTarget = { hostId: 'channel:messaging:action', panel: 'channel' } as const;
|
|
133
|
+
const activeTarget = { hostId: 'channel:messaging:active', panel: 'channel' } as const;
|
|
134
|
+
const unregisterActive = registerActiveNotificationTarget(owner, activeTarget);
|
|
135
|
+
const unregisterAction = registerNotificationActionTarget(owner, actionTarget);
|
|
136
|
+
const result = notification({});
|
|
137
|
+
|
|
138
|
+
expect(resolveNotificationTargetTagIfNeeded(owner, result)).toBe(true);
|
|
139
|
+
expect(result.tags).toEqual(['target:channel:channel:messaging:action']);
|
|
140
|
+
|
|
141
|
+
unregisterAction();
|
|
142
|
+
unregisterActive();
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it('does not exactify broad target tags', () => {
|
|
146
|
+
const owner = {};
|
|
147
|
+
const target = { hostId: 'channel:messaging:general', panel: 'channel' } as const;
|
|
148
|
+
const unregister = registerActiveNotificationTarget(owner, target);
|
|
149
|
+
const result = notification({ tags: ['target:channel'] });
|
|
150
|
+
|
|
151
|
+
expect(resolveNotificationTargetTagIfNeeded(owner, result)).toBe(false);
|
|
152
|
+
expect(result.tags).toEqual(['target:channel']);
|
|
153
|
+
expect(isNotificationForTarget(result, target)).toBe(true);
|
|
154
|
+
|
|
155
|
+
unregister();
|
|
156
|
+
});
|
|
157
|
+
});
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import React, { PropsWithChildren } from 'react';
|
|
2
|
+
|
|
3
|
+
import { act, renderHook } from '@testing-library/react-native';
|
|
4
|
+
|
|
5
|
+
import { ChannelProvider } from '../../../../contexts/channelContext/ChannelContext';
|
|
6
|
+
import { ChatProvider } from '../../../../contexts/chatContext/ChatContext';
|
|
7
|
+
import { NotificationTargetProvider } from '../../NotificationTargetContext';
|
|
8
|
+
import { useNotificationApi } from '../useNotificationApi';
|
|
9
|
+
|
|
10
|
+
const createWrapper =
|
|
11
|
+
(client: unknown, channelContext: Record<string, unknown> = {}) =>
|
|
12
|
+
({ children }: PropsWithChildren) => (
|
|
13
|
+
<ChatProvider value={{ client } as never}>
|
|
14
|
+
<ChannelProvider
|
|
15
|
+
value={
|
|
16
|
+
{
|
|
17
|
+
channel: { cid: 'messaging:general' },
|
|
18
|
+
...channelContext,
|
|
19
|
+
} as never
|
|
20
|
+
}
|
|
21
|
+
>
|
|
22
|
+
<NotificationTargetProvider hostId='channel:messaging:general' panel='channel'>
|
|
23
|
+
{children}
|
|
24
|
+
</NotificationTargetProvider>
|
|
25
|
+
</ChannelProvider>
|
|
26
|
+
</ChatProvider>
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
describe('useNotificationApi', () => {
|
|
30
|
+
it('adds inferred exact target tags and incident-derived types', () => {
|
|
31
|
+
const add = jest.fn(() => 'notification-id');
|
|
32
|
+
const client = {
|
|
33
|
+
notifications: {
|
|
34
|
+
add,
|
|
35
|
+
remove: jest.fn(),
|
|
36
|
+
startTimeout: jest.fn(),
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
const { result } = renderHook(() => useNotificationApi(), {
|
|
40
|
+
wrapper: createWrapper(client),
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
act(() => {
|
|
44
|
+
result.current.addNotification(
|
|
45
|
+
{
|
|
46
|
+
message: 'Could not send message',
|
|
47
|
+
options: { severity: 'error' },
|
|
48
|
+
origin: { emitter: 'MessageComposer' },
|
|
49
|
+
},
|
|
50
|
+
{ incident: { domain: 'api', entity: 'message', operation: 'send' } },
|
|
51
|
+
);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
expect(add).toHaveBeenCalledWith({
|
|
55
|
+
message: 'Could not send message',
|
|
56
|
+
options: {
|
|
57
|
+
severity: 'error',
|
|
58
|
+
tags: ['target:channel:channel:messaging:general'],
|
|
59
|
+
type: 'api:message:send:failed',
|
|
60
|
+
},
|
|
61
|
+
origin: { emitter: 'MessageComposer' },
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('uses explicit target panels instead of inferred panel', () => {
|
|
66
|
+
const add = jest.fn();
|
|
67
|
+
const client = {
|
|
68
|
+
notifications: {
|
|
69
|
+
add,
|
|
70
|
+
remove: jest.fn(),
|
|
71
|
+
startTimeout: jest.fn(),
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
const { result } = renderHook(() => useNotificationApi(), {
|
|
75
|
+
wrapper: createWrapper(client),
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
act(() => {
|
|
79
|
+
result.current.addNotification(
|
|
80
|
+
{
|
|
81
|
+
message: 'Poll ended',
|
|
82
|
+
options: { severity: 'success' },
|
|
83
|
+
origin: { emitter: 'Poll' },
|
|
84
|
+
},
|
|
85
|
+
{ targetPanels: ['channel', 'thread'] },
|
|
86
|
+
);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
expect(add).toHaveBeenCalledWith({
|
|
90
|
+
message: 'Poll ended',
|
|
91
|
+
options: {
|
|
92
|
+
severity: 'success',
|
|
93
|
+
tags: ['target:channel', 'target:thread'],
|
|
94
|
+
},
|
|
95
|
+
origin: { emitter: 'Poll' },
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('adds system notifications with the system tag', () => {
|
|
100
|
+
const add = jest.fn(() => 'notification-id');
|
|
101
|
+
const client = {
|
|
102
|
+
notifications: {
|
|
103
|
+
add,
|
|
104
|
+
remove: jest.fn(),
|
|
105
|
+
startTimeout: jest.fn(),
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
const { result } = renderHook(() => useNotificationApi(), {
|
|
109
|
+
wrapper: createWrapper(client, { threadList: true }),
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
const id = result.current.addSystemNotification({
|
|
113
|
+
message: 'Reconnecting',
|
|
114
|
+
options: {
|
|
115
|
+
severity: 'warning',
|
|
116
|
+
tags: ['network'],
|
|
117
|
+
},
|
|
118
|
+
origin: { emitter: 'Connection' },
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
expect(id).toBe('notification-id');
|
|
122
|
+
expect(add).toHaveBeenCalledWith({
|
|
123
|
+
message: 'Reconnecting',
|
|
124
|
+
options: {
|
|
125
|
+
severity: 'warning',
|
|
126
|
+
tags: ['system', 'network'],
|
|
127
|
+
},
|
|
128
|
+
origin: { emitter: 'Connection' },
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it('removes non-system notifications for a panel', () => {
|
|
133
|
+
const remove = jest.fn();
|
|
134
|
+
const client = {
|
|
135
|
+
notifications: {
|
|
136
|
+
add: jest.fn(),
|
|
137
|
+
notifications: [
|
|
138
|
+
{
|
|
139
|
+
id: 'channel-id',
|
|
140
|
+
origin: { emitter: 'test' },
|
|
141
|
+
tags: ['target:channel'],
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
id: 'fallback-channel-id',
|
|
145
|
+
origin: { emitter: 'test' },
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
id: 'thread-id',
|
|
149
|
+
origin: { emitter: 'test' },
|
|
150
|
+
tags: ['target:thread'],
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
id: 'system-id',
|
|
154
|
+
origin: { emitter: 'test' },
|
|
155
|
+
tags: ['system', 'target:channel'],
|
|
156
|
+
},
|
|
157
|
+
],
|
|
158
|
+
remove,
|
|
159
|
+
startTimeout: jest.fn(),
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
const { result } = renderHook(() => useNotificationApi(), {
|
|
163
|
+
wrapper: createWrapper(client),
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
act(() => {
|
|
167
|
+
result.current.removeNotificationsForCurrentPanel();
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
expect(remove.mock.calls.map(([id]) => id)).toEqual(['channel-id']);
|
|
171
|
+
});
|
|
172
|
+
});
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import React, { PropsWithChildren } from 'react';
|
|
2
|
+
|
|
3
|
+
import { renderHook } from '@testing-library/react-native';
|
|
4
|
+
|
|
5
|
+
import { ChannelProvider } from '../../../../contexts/channelContext/ChannelContext';
|
|
6
|
+
import { ChannelsProvider } from '../../../../contexts/channelsContext/ChannelsContext';
|
|
7
|
+
import { ThreadProvider } from '../../../../contexts/threadContext/ThreadContext';
|
|
8
|
+
import { ThreadsProvider } from '../../../../contexts/threadsContext/ThreadsContext';
|
|
9
|
+
import { useNotificationTarget } from '../useNotificationTarget';
|
|
10
|
+
|
|
11
|
+
const channelContext = { channel: { cid: 'messaging:channel' } } as never;
|
|
12
|
+
const channelsContext = { channels: [] } as never;
|
|
13
|
+
const threadsContext = { threads: [] } as never;
|
|
14
|
+
|
|
15
|
+
describe('useNotificationTarget', () => {
|
|
16
|
+
it('returns undefined outside notification target providers', () => {
|
|
17
|
+
const { result } = renderHook(() => useNotificationTarget());
|
|
18
|
+
|
|
19
|
+
expect(result.current).toBeUndefined();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('targets the channel when rendered inside Channel', () => {
|
|
23
|
+
const wrapper = ({ children }: PropsWithChildren) => (
|
|
24
|
+
<ChannelProvider value={channelContext}>{children}</ChannelProvider>
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
const { result } = renderHook(() => useNotificationTarget(), { wrapper });
|
|
28
|
+
|
|
29
|
+
expect(result.current).toBe('channel');
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('prioritizes channel over surrounding list providers', () => {
|
|
33
|
+
const wrapper = ({ children }: PropsWithChildren) => (
|
|
34
|
+
<ChannelsProvider value={channelsContext}>
|
|
35
|
+
<ThreadsProvider value={threadsContext}>
|
|
36
|
+
<ChannelProvider value={channelContext}>{children}</ChannelProvider>
|
|
37
|
+
</ThreadsProvider>
|
|
38
|
+
</ChannelsProvider>
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const { result } = renderHook(() => useNotificationTarget(), { wrapper });
|
|
42
|
+
|
|
43
|
+
expect(result.current).toBe('channel');
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('targets thread when Channel is in thread-list mode', () => {
|
|
47
|
+
const wrapper = ({ children }: PropsWithChildren) => (
|
|
48
|
+
<ChannelProvider value={{ ...(channelContext as object), threadList: true } as never}>
|
|
49
|
+
{children}
|
|
50
|
+
</ChannelProvider>
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
const { result } = renderHook(() => useNotificationTarget(), { wrapper });
|
|
54
|
+
|
|
55
|
+
expect(result.current).toBe('thread');
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('prioritizes thread over channel', () => {
|
|
59
|
+
const wrapper = ({ children }: PropsWithChildren) => (
|
|
60
|
+
<ChannelProvider value={channelContext}>
|
|
61
|
+
<ThreadProvider value={{ threadInstance: {} } as never}>{children}</ThreadProvider>
|
|
62
|
+
</ChannelProvider>
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
const { result } = renderHook(() => useNotificationTarget(), { wrapper });
|
|
66
|
+
|
|
67
|
+
expect(result.current).toBe('thread');
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('targets list providers when no Channel provider is present', () => {
|
|
71
|
+
const channelListWrapper = ({ children }: PropsWithChildren) => (
|
|
72
|
+
<ChannelsProvider value={channelsContext}>{children}</ChannelsProvider>
|
|
73
|
+
);
|
|
74
|
+
const threadListWrapper = ({ children }: PropsWithChildren) => (
|
|
75
|
+
<ThreadsProvider value={threadsContext}>{children}</ThreadsProvider>
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
expect(
|
|
79
|
+
renderHook(() => useNotificationTarget(), { wrapper: channelListWrapper }).result.current,
|
|
80
|
+
).toBe('channel-list');
|
|
81
|
+
expect(
|
|
82
|
+
renderHook(() => useNotificationTarget(), { wrapper: threadListWrapper }).result.current,
|
|
83
|
+
).toBe('thread-list');
|
|
84
|
+
});
|
|
85
|
+
});
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
|
|
3
|
+
import type { AddNotificationPayload, Notification } from 'stream-chat';
|
|
4
|
+
|
|
5
|
+
import { useChatContext } from '../../../contexts/chatContext/ChatContext';
|
|
6
|
+
import {
|
|
7
|
+
addExactNotificationTargetTag,
|
|
8
|
+
getNotificationTargetTag,
|
|
9
|
+
hasNotificationTargetTag,
|
|
10
|
+
isNotificationForTarget,
|
|
11
|
+
registerNotificationActionTarget,
|
|
12
|
+
type NotificationTarget,
|
|
13
|
+
type NotificationTargetPanel,
|
|
14
|
+
} from '../notificationTarget';
|
|
15
|
+
import { useNotificationTargetContext } from '../NotificationTargetContext';
|
|
16
|
+
|
|
17
|
+
export const SYSTEM_NOTIFICATION_TAG = 'system' as const;
|
|
18
|
+
|
|
19
|
+
/** Returns whether a notification is reserved for system-level consumers instead of snackbars. */
|
|
20
|
+
export const hasSystemNotificationTag = (notification: Notification) =>
|
|
21
|
+
notification.tags?.includes(SYSTEM_NOTIFICATION_TAG) ?? false;
|
|
22
|
+
|
|
23
|
+
/** Structured descriptor used to derive stable notification `type` values. */
|
|
24
|
+
export type NotificationIncidentDescriptor = {
|
|
25
|
+
/** Product or SDK area where the notification originated, for example `message` or `poll`. */
|
|
26
|
+
domain: string;
|
|
27
|
+
/** Entity affected by the incident, for example `attachment` or `vote`. */
|
|
28
|
+
entity: string;
|
|
29
|
+
/** Operation being reported, for example `upload` or `create`. */
|
|
30
|
+
operation: string;
|
|
31
|
+
/** Optional explicit status. Falls back to severity-derived status when omitted. */
|
|
32
|
+
status?: string;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export type AddNotificationOptions = {
|
|
36
|
+
/** Incident metadata used to derive `options.type` when the payload does not provide one. */
|
|
37
|
+
incident?: NotificationIncidentDescriptor;
|
|
38
|
+
/** Exact host target for this notification. Defaults to the nearest notification target provider. */
|
|
39
|
+
target?: NotificationTarget;
|
|
40
|
+
/** Broad panel targets. Use for notifications that should appear in every host of a panel. */
|
|
41
|
+
targetPanels?: NotificationTargetPanel[];
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export type AddSystemNotificationOptions = Omit<AddNotificationOptions, 'target' | 'targetPanels'>;
|
|
45
|
+
|
|
46
|
+
/** Adds a snackbar notification scoped to a target host or panel. */
|
|
47
|
+
export type AddNotification = (
|
|
48
|
+
payload: AddNotificationPayload,
|
|
49
|
+
options?: AddNotificationOptions,
|
|
50
|
+
) => void;
|
|
51
|
+
/** Adds a system notification that is excluded from the default snackbar list. */
|
|
52
|
+
export type AddSystemNotification = (
|
|
53
|
+
payload: AddNotificationPayload,
|
|
54
|
+
options?: AddSystemNotificationOptions,
|
|
55
|
+
) => string;
|
|
56
|
+
/** Removes a notification by id. */
|
|
57
|
+
export type RemoveNotification = (id: string) => void;
|
|
58
|
+
/** Removes non-system notifications that belong to the current target provider. */
|
|
59
|
+
export type RemoveNotificationsForCurrentPanel = () => void;
|
|
60
|
+
/** Starts the manager timeout for a notification, optionally overriding the stored duration. */
|
|
61
|
+
export type StartNotificationTimeout = (id: string, durationOverride?: number) => void;
|
|
62
|
+
/** Runs an action while temporarily making its target available to untagged notifications. */
|
|
63
|
+
export type RunWithNotificationTarget = <T>(
|
|
64
|
+
callback: () => T | Promise<T>,
|
|
65
|
+
target?: NotificationTarget,
|
|
66
|
+
) => Promise<T>;
|
|
67
|
+
|
|
68
|
+
export type NotificationApi = {
|
|
69
|
+
addNotification: AddNotification;
|
|
70
|
+
addSystemNotification: AddSystemNotification;
|
|
71
|
+
removeNotification: RemoveNotification;
|
|
72
|
+
removeNotificationsForCurrentPanel: RemoveNotificationsForCurrentPanel;
|
|
73
|
+
runWithNotificationTarget: RunWithNotificationTarget;
|
|
74
|
+
startNotificationTimeout: StartNotificationTimeout;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const getTargetTags = (
|
|
78
|
+
target: NotificationTarget | undefined,
|
|
79
|
+
targetPanels: NotificationTargetPanel[] | undefined,
|
|
80
|
+
tags: string[] | undefined,
|
|
81
|
+
) => {
|
|
82
|
+
if (targetPanels) {
|
|
83
|
+
return Array.from(
|
|
84
|
+
new Set([...targetPanels.map((panel) => getNotificationTargetTag(panel)), ...(tags ?? [])]),
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (target) {
|
|
89
|
+
return addExactNotificationTargetTag(target, tags);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return tags ?? [];
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const getTypeFromIncident = ({
|
|
96
|
+
incident,
|
|
97
|
+
severity,
|
|
98
|
+
type,
|
|
99
|
+
}: {
|
|
100
|
+
incident?: NotificationIncidentDescriptor;
|
|
101
|
+
severity?: NonNullable<AddNotificationPayload['options']>['severity'];
|
|
102
|
+
type?: NonNullable<AddNotificationPayload['options']>['type'];
|
|
103
|
+
}) => {
|
|
104
|
+
if (type) return type;
|
|
105
|
+
if (!incident) return undefined;
|
|
106
|
+
|
|
107
|
+
const status =
|
|
108
|
+
incident.status ??
|
|
109
|
+
(severity === 'error' ? 'failed' : severity === 'success' ? 'success' : severity);
|
|
110
|
+
|
|
111
|
+
return [incident.domain, incident.entity, incident.operation, status]
|
|
112
|
+
.filter((segment): segment is string => !!segment)
|
|
113
|
+
.join(':');
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
const mergeNotificationOptions = (
|
|
117
|
+
payload: AddNotificationPayload,
|
|
118
|
+
options: NonNullable<AddNotificationPayload['options']>,
|
|
119
|
+
): AddNotificationPayload => {
|
|
120
|
+
const mergedOptions = { ...payload.options, ...options };
|
|
121
|
+
|
|
122
|
+
if (!payload.options && Object.keys(mergedOptions).length === 0) {
|
|
123
|
+
return payload;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return {
|
|
127
|
+
...payload,
|
|
128
|
+
options: mergedOptions,
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
/** Returns imperative helpers for dispatching, targeting and dismissing client notifications. */
|
|
133
|
+
export const useNotificationApi = (): NotificationApi => {
|
|
134
|
+
const { client } = useChatContext();
|
|
135
|
+
const contextTarget = useNotificationTargetContext();
|
|
136
|
+
const notificationManager = client?.notifications;
|
|
137
|
+
|
|
138
|
+
const addNotification: AddNotification = useCallback(
|
|
139
|
+
(payload, options) => {
|
|
140
|
+
if (!notificationManager) return;
|
|
141
|
+
|
|
142
|
+
const target =
|
|
143
|
+
options?.target ??
|
|
144
|
+
(options?.targetPanels || hasNotificationTargetTag(payload.options?.tags)
|
|
145
|
+
? undefined
|
|
146
|
+
: contextTarget);
|
|
147
|
+
const notificationTags = getTargetTags(target, options?.targetPanels, payload.options?.tags);
|
|
148
|
+
const resolvedType = getTypeFromIncident({
|
|
149
|
+
incident: options?.incident,
|
|
150
|
+
severity: payload.options?.severity,
|
|
151
|
+
type: payload.options?.type,
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
notificationManager.add(
|
|
155
|
+
mergeNotificationOptions(payload, {
|
|
156
|
+
...(notificationTags.length > 0 ? { tags: notificationTags } : {}),
|
|
157
|
+
...(resolvedType ? { type: resolvedType } : {}),
|
|
158
|
+
}),
|
|
159
|
+
);
|
|
160
|
+
},
|
|
161
|
+
[contextTarget, notificationManager],
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
const addSystemNotification: AddSystemNotification = useCallback(
|
|
165
|
+
(payload, options) => {
|
|
166
|
+
if (!notificationManager) return '';
|
|
167
|
+
|
|
168
|
+
const notificationTags = Array.from(
|
|
169
|
+
new Set([SYSTEM_NOTIFICATION_TAG, ...(payload.options?.tags ?? [])]),
|
|
170
|
+
);
|
|
171
|
+
const resolvedType = getTypeFromIncident({
|
|
172
|
+
incident: options?.incident,
|
|
173
|
+
severity: payload.options?.severity,
|
|
174
|
+
type: payload.options?.type,
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
return notificationManager.add(
|
|
178
|
+
mergeNotificationOptions(payload, {
|
|
179
|
+
...(notificationTags.length > 0 ? { tags: notificationTags } : {}),
|
|
180
|
+
...(resolvedType ? { type: resolvedType } : {}),
|
|
181
|
+
}),
|
|
182
|
+
);
|
|
183
|
+
},
|
|
184
|
+
[notificationManager],
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
const removeNotification: RemoveNotification = useCallback(
|
|
188
|
+
(id) => {
|
|
189
|
+
if (!notificationManager) return;
|
|
190
|
+
|
|
191
|
+
notificationManager.remove(id);
|
|
192
|
+
},
|
|
193
|
+
[notificationManager],
|
|
194
|
+
);
|
|
195
|
+
|
|
196
|
+
const removeNotificationsForCurrentPanel: RemoveNotificationsForCurrentPanel = useCallback(() => {
|
|
197
|
+
if (!contextTarget || !notificationManager) return;
|
|
198
|
+
|
|
199
|
+
const notificationIds = notificationManager.notifications
|
|
200
|
+
.filter(
|
|
201
|
+
(notification) =>
|
|
202
|
+
!hasSystemNotificationTag(notification) &&
|
|
203
|
+
isNotificationForTarget(notification, contextTarget),
|
|
204
|
+
)
|
|
205
|
+
.map(({ id }) => id);
|
|
206
|
+
|
|
207
|
+
notificationIds.forEach(removeNotification);
|
|
208
|
+
}, [contextTarget, notificationManager, removeNotification]);
|
|
209
|
+
|
|
210
|
+
const runWithNotificationTarget: RunWithNotificationTarget = useCallback(
|
|
211
|
+
async (callback, target = contextTarget) => {
|
|
212
|
+
if (!target || !notificationManager) {
|
|
213
|
+
return await callback();
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
const unregisterActionTarget = registerNotificationActionTarget(notificationManager, target);
|
|
217
|
+
try {
|
|
218
|
+
return await callback();
|
|
219
|
+
} finally {
|
|
220
|
+
unregisterActionTarget();
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
[contextTarget, notificationManager],
|
|
224
|
+
);
|
|
225
|
+
|
|
226
|
+
const startNotificationTimeout: StartNotificationTimeout = useCallback(
|
|
227
|
+
(id, durationOverride) => {
|
|
228
|
+
if (!notificationManager) return;
|
|
229
|
+
|
|
230
|
+
if (typeof durationOverride === 'number') {
|
|
231
|
+
notificationManager.startTimeout(id, durationOverride);
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
notificationManager.startTimeout(id);
|
|
236
|
+
},
|
|
237
|
+
[notificationManager],
|
|
238
|
+
);
|
|
239
|
+
|
|
240
|
+
return {
|
|
241
|
+
addNotification,
|
|
242
|
+
addSystemNotification,
|
|
243
|
+
removeNotification,
|
|
244
|
+
removeNotificationsForCurrentPanel,
|
|
245
|
+
runWithNotificationTarget,
|
|
246
|
+
startNotificationTimeout,
|
|
247
|
+
};
|
|
248
|
+
};
|