stream-chat-react-native-core 9.2.0-beta.1 → 9.2.0-beta.3
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/a11y/hooks/useA11yLabel.js +4 -3
- package/lib/commonjs/a11y/hooks/useA11yLabel.js.map +1 -1
- package/lib/commonjs/a11y/hooks/useAccessibilityActivateAction.js +25 -0
- package/lib/commonjs/a11y/hooks/useAccessibilityActivateAction.js.map +1 -0
- package/lib/commonjs/a11y/index.js +11 -0
- package/lib/commonjs/a11y/index.js.map +1 -1
- package/lib/commonjs/components/AttachmentPicker/AttachmentPicker.js +20 -0
- package/lib/commonjs/components/AttachmentPicker/AttachmentPicker.js.map +1 -1
- package/lib/commonjs/components/AttachmentPicker/components/AttachmentMediaPicker/AttachmentMediaPicker.js +1 -0
- package/lib/commonjs/components/AttachmentPicker/components/AttachmentMediaPicker/AttachmentMediaPicker.js.map +1 -1
- package/lib/commonjs/components/AttachmentPicker/components/AttachmentMediaPicker/AttachmentPickerItem.js +19 -2
- package/lib/commonjs/components/AttachmentPicker/components/AttachmentMediaPicker/AttachmentPickerItem.js.map +1 -1
- package/lib/commonjs/components/AttachmentPicker/components/AttachmentPickerContent.js +4 -3
- package/lib/commonjs/components/AttachmentPicker/components/AttachmentPickerContent.js.map +1 -1
- package/lib/commonjs/components/AttachmentPicker/components/AttachmentTypePickerButton.js +9 -1
- package/lib/commonjs/components/AttachmentPicker/components/AttachmentTypePickerButton.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/ImageGallery/components/ImageGalleryFooter.js +2 -2
- package/lib/commonjs/components/ImageGallery/components/ImageGalleryFooter.js.map +1 -1
- package/lib/commonjs/components/ImageGallery/components/ImageGalleryHeader.js +1 -1
- package/lib/commonjs/components/ImageGallery/components/ImageGalleryHeader.js.map +1 -1
- package/lib/commonjs/components/ImageGallery/components/ImageGalleryVideoControl.js +1 -1
- package/lib/commonjs/components/ImageGallery/components/ImageGalleryVideoControl.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/AttachmentRemoveControl.js +16 -4
- package/lib/commonjs/components/MessageInput/components/AttachmentPreview/AttachmentRemoveControl.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 +30 -6
- package/lib/commonjs/components/MessageInput/components/AudioRecorder/AudioRecorder.js.map +1 -1
- package/lib/commonjs/components/MessageInput/components/AudioRecorder/AudioRecordingButton.js +34 -9
- package/lib/commonjs/components/MessageInput/components/AudioRecorder/AudioRecordingButton.js.map +1 -1
- package/lib/commonjs/components/MessageInput/components/InputButtons/AttachButton.js +12 -3
- package/lib/commonjs/components/MessageInput/components/InputButtons/AttachButton.js.map +1 -1
- package/lib/commonjs/components/MessageInput/components/OutputButtons/EditButton.js +1 -0
- package/lib/commonjs/components/MessageInput/components/OutputButtons/EditButton.js.map +1 -1
- package/lib/commonjs/components/MessageInput/components/OutputButtons/SendButton.js +1 -0
- package/lib/commonjs/components/MessageInput/components/OutputButtons/SendButton.js.map +1 -1
- package/lib/commonjs/components/MessageInput/components/OutputButtons/index.js +1 -1
- package/lib/commonjs/components/MessageList/MessageFlashList.js +24 -4
- package/lib/commonjs/components/MessageList/MessageFlashList.js.map +1 -1
- package/lib/commonjs/components/MessageList/MessageList.js +24 -4
- package/lib/commonjs/components/MessageList/MessageList.js.map +1 -1
- package/lib/commonjs/components/MessageList/ScrollToBottomButton.js +12 -6
- package/lib/commonjs/components/MessageList/ScrollToBottomButton.js.map +1 -1
- package/lib/commonjs/components/MessageList/UnreadMessagesNotification.js +1 -0
- package/lib/commonjs/components/MessageList/UnreadMessagesNotification.js.map +1 -1
- package/lib/commonjs/components/MessageList/hooks/useScrollToBottomAccessibilityAction.js +47 -0
- package/lib/commonjs/components/MessageList/hooks/useScrollToBottomAccessibilityAction.js.map +1 -0
- package/lib/commonjs/components/MessageMenu/MessageActionListItem.js +12 -4
- package/lib/commonjs/components/MessageMenu/MessageActionListItem.js.map +1 -1
- package/lib/commonjs/components/MessageMenu/MessageReactionPicker.js +1 -0
- package/lib/commonjs/components/MessageMenu/MessageReactionPicker.js.map +1 -1
- package/lib/commonjs/components/MessageMenu/ReactionButton.js +9 -6
- package/lib/commonjs/components/MessageMenu/ReactionButton.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 +232 -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/CreatePollHeader.js +2 -0
- package/lib/commonjs/components/Poll/components/CreatePollHeader.js.map +1 -1
- package/lib/commonjs/components/Poll/components/MultipleVotesSettings.js +2 -0
- package/lib/commonjs/components/Poll/components/MultipleVotesSettings.js.map +1 -1
- package/lib/commonjs/components/Poll/components/PollModalHeader.js +1 -0
- package/lib/commonjs/components/Poll/components/PollModalHeader.js.map +1 -1
- 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/Reply/Reply.js +1 -0
- package/lib/commonjs/components/Reply/Reply.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/components/ui/Avatar/Avatar.js +6 -3
- package/lib/commonjs/components/ui/Avatar/Avatar.js.map +1 -1
- package/lib/commonjs/components/ui/Button/Button.js +16 -3
- package/lib/commonjs/components/ui/Button/Button.js.map +1 -1
- package/lib/commonjs/contexts/accessibilityContext/AccessibilityContext.js +21 -1
- package/lib/commonjs/contexts/accessibilityContext/AccessibilityContext.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 +94 -1
- package/lib/commonjs/i18n/es.json +96 -3
- package/lib/commonjs/i18n/fr.json +94 -1
- package/lib/commonjs/i18n/he.json +94 -1
- package/lib/commonjs/i18n/hi.json +94 -1
- package/lib/commonjs/i18n/it.json +94 -1
- package/lib/commonjs/i18n/ja.json +94 -1
- package/lib/commonjs/i18n/ko.json +94 -1
- package/lib/commonjs/i18n/nl.json +94 -1
- package/lib/commonjs/i18n/pt-br.json +94 -1
- package/lib/commonjs/i18n/ru.json +94 -1
- package/lib/commonjs/i18n/tr.json +94 -1
- package/lib/commonjs/mock-builders/DB/mock.js +3 -1
- package/lib/commonjs/mock-builders/DB/mock.js.map +1 -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/test-utils/BetterSqlite.js +3 -2
- package/lib/commonjs/test-utils/BetterSqlite.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/a11y/hooks/useA11yLabel.js +4 -3
- package/lib/module/a11y/hooks/useA11yLabel.js.map +1 -1
- package/lib/module/a11y/hooks/useAccessibilityActivateAction.js +25 -0
- package/lib/module/a11y/hooks/useAccessibilityActivateAction.js.map +1 -0
- package/lib/module/a11y/index.js +11 -0
- package/lib/module/a11y/index.js.map +1 -1
- package/lib/module/components/AttachmentPicker/AttachmentPicker.js +20 -0
- package/lib/module/components/AttachmentPicker/AttachmentPicker.js.map +1 -1
- package/lib/module/components/AttachmentPicker/components/AttachmentMediaPicker/AttachmentMediaPicker.js +1 -0
- package/lib/module/components/AttachmentPicker/components/AttachmentMediaPicker/AttachmentMediaPicker.js.map +1 -1
- package/lib/module/components/AttachmentPicker/components/AttachmentMediaPicker/AttachmentPickerItem.js +19 -2
- package/lib/module/components/AttachmentPicker/components/AttachmentMediaPicker/AttachmentPickerItem.js.map +1 -1
- package/lib/module/components/AttachmentPicker/components/AttachmentPickerContent.js +4 -3
- package/lib/module/components/AttachmentPicker/components/AttachmentPickerContent.js.map +1 -1
- package/lib/module/components/AttachmentPicker/components/AttachmentTypePickerButton.js +9 -1
- package/lib/module/components/AttachmentPicker/components/AttachmentTypePickerButton.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/ImageGallery/components/ImageGalleryFooter.js +2 -2
- package/lib/module/components/ImageGallery/components/ImageGalleryFooter.js.map +1 -1
- package/lib/module/components/ImageGallery/components/ImageGalleryHeader.js +1 -1
- package/lib/module/components/ImageGallery/components/ImageGalleryHeader.js.map +1 -1
- package/lib/module/components/ImageGallery/components/ImageGalleryVideoControl.js +1 -1
- package/lib/module/components/ImageGallery/components/ImageGalleryVideoControl.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/AttachmentRemoveControl.js +16 -4
- package/lib/module/components/MessageInput/components/AttachmentPreview/AttachmentRemoveControl.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 +30 -6
- package/lib/module/components/MessageInput/components/AudioRecorder/AudioRecorder.js.map +1 -1
- package/lib/module/components/MessageInput/components/AudioRecorder/AudioRecordingButton.js +34 -9
- package/lib/module/components/MessageInput/components/AudioRecorder/AudioRecordingButton.js.map +1 -1
- package/lib/module/components/MessageInput/components/InputButtons/AttachButton.js +12 -3
- package/lib/module/components/MessageInput/components/InputButtons/AttachButton.js.map +1 -1
- package/lib/module/components/MessageInput/components/OutputButtons/EditButton.js +1 -0
- package/lib/module/components/MessageInput/components/OutputButtons/EditButton.js.map +1 -1
- package/lib/module/components/MessageInput/components/OutputButtons/SendButton.js +1 -0
- package/lib/module/components/MessageInput/components/OutputButtons/SendButton.js.map +1 -1
- package/lib/module/components/MessageInput/components/OutputButtons/index.js +1 -1
- package/lib/module/components/MessageList/MessageFlashList.js +24 -4
- package/lib/module/components/MessageList/MessageFlashList.js.map +1 -1
- package/lib/module/components/MessageList/MessageList.js +24 -4
- package/lib/module/components/MessageList/MessageList.js.map +1 -1
- package/lib/module/components/MessageList/ScrollToBottomButton.js +12 -6
- package/lib/module/components/MessageList/ScrollToBottomButton.js.map +1 -1
- package/lib/module/components/MessageList/UnreadMessagesNotification.js +1 -0
- package/lib/module/components/MessageList/UnreadMessagesNotification.js.map +1 -1
- package/lib/module/components/MessageList/hooks/useScrollToBottomAccessibilityAction.js +47 -0
- package/lib/module/components/MessageList/hooks/useScrollToBottomAccessibilityAction.js.map +1 -0
- package/lib/module/components/MessageMenu/MessageActionListItem.js +12 -4
- package/lib/module/components/MessageMenu/MessageActionListItem.js.map +1 -1
- package/lib/module/components/MessageMenu/MessageReactionPicker.js +1 -0
- package/lib/module/components/MessageMenu/MessageReactionPicker.js.map +1 -1
- package/lib/module/components/MessageMenu/ReactionButton.js +9 -6
- package/lib/module/components/MessageMenu/ReactionButton.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 +232 -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/CreatePollHeader.js +2 -0
- package/lib/module/components/Poll/components/CreatePollHeader.js.map +1 -1
- package/lib/module/components/Poll/components/MultipleVotesSettings.js +2 -0
- package/lib/module/components/Poll/components/MultipleVotesSettings.js.map +1 -1
- package/lib/module/components/Poll/components/PollModalHeader.js +1 -0
- package/lib/module/components/Poll/components/PollModalHeader.js.map +1 -1
- 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/Reply/Reply.js +1 -0
- package/lib/module/components/Reply/Reply.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/components/ui/Avatar/Avatar.js +6 -3
- package/lib/module/components/ui/Avatar/Avatar.js.map +1 -1
- package/lib/module/components/ui/Button/Button.js +16 -3
- package/lib/module/components/ui/Button/Button.js.map +1 -1
- package/lib/module/contexts/accessibilityContext/AccessibilityContext.js +21 -1
- package/lib/module/contexts/accessibilityContext/AccessibilityContext.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 +94 -1
- package/lib/module/i18n/es.json +96 -3
- package/lib/module/i18n/fr.json +94 -1
- package/lib/module/i18n/he.json +94 -1
- package/lib/module/i18n/hi.json +94 -1
- package/lib/module/i18n/it.json +94 -1
- package/lib/module/i18n/ja.json +94 -1
- package/lib/module/i18n/ko.json +94 -1
- package/lib/module/i18n/nl.json +94 -1
- package/lib/module/i18n/pt-br.json +94 -1
- package/lib/module/i18n/ru.json +94 -1
- package/lib/module/i18n/tr.json +94 -1
- package/lib/module/mock-builders/DB/mock.js +3 -1
- package/lib/module/mock-builders/DB/mock.js.map +1 -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/test-utils/BetterSqlite.js +3 -2
- package/lib/module/test-utils/BetterSqlite.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/a11y/a11yUtils.d.ts +3 -3
- package/lib/typescript/a11y/a11yUtils.d.ts.map +1 -1
- package/lib/typescript/a11y/hooks/useA11yLabel.d.ts +2 -1
- package/lib/typescript/a11y/hooks/useA11yLabel.d.ts.map +1 -1
- package/lib/typescript/a11y/hooks/useAccessibilityActivateAction.d.ts +17 -0
- package/lib/typescript/a11y/hooks/useAccessibilityActivateAction.d.ts.map +1 -0
- package/lib/typescript/a11y/index.d.ts +1 -0
- package/lib/typescript/a11y/index.d.ts.map +1 -1
- package/lib/typescript/components/AttachmentPicker/AttachmentPicker.d.ts.map +1 -1
- package/lib/typescript/components/AttachmentPicker/components/AttachmentMediaPicker/AttachmentMediaPicker.d.ts.map +1 -1
- package/lib/typescript/components/AttachmentPicker/components/AttachmentMediaPicker/AttachmentPickerItem.d.ts.map +1 -1
- package/lib/typescript/components/AttachmentPicker/components/AttachmentPickerContent.d.ts.map +1 -1
- package/lib/typescript/components/AttachmentPicker/components/AttachmentTypePickerButton.d.ts +2 -1
- package/lib/typescript/components/AttachmentPicker/components/AttachmentTypePickerButton.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/AttachmentRemoveControl.d.ts +5 -2
- package/lib/typescript/components/MessageInput/components/AttachmentPreview/AttachmentRemoveControl.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/MessageInput/components/InputButtons/AttachButton.d.ts +1 -0
- package/lib/typescript/components/MessageInput/components/InputButtons/AttachButton.d.ts.map +1 -1
- package/lib/typescript/components/MessageInput/components/OutputButtons/EditButton.d.ts.map +1 -1
- package/lib/typescript/components/MessageInput/components/OutputButtons/SendButton.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/MessageList/ScrollToBottomButton.d.ts +2 -0
- package/lib/typescript/components/MessageList/ScrollToBottomButton.d.ts.map +1 -1
- package/lib/typescript/components/MessageList/UnreadMessagesNotification.d.ts.map +1 -1
- package/lib/typescript/components/MessageList/hooks/useScrollToBottomAccessibilityAction.d.ts +20 -0
- package/lib/typescript/components/MessageList/hooks/useScrollToBottomAccessibilityAction.d.ts.map +1 -0
- package/lib/typescript/components/MessageMenu/MessageActionListItem.d.ts.map +1 -1
- package/lib/typescript/components/MessageMenu/MessageReactionPicker.d.ts.map +1 -1
- package/lib/typescript/components/MessageMenu/ReactionButton.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/CreatePollHeader.d.ts.map +1 -1
- package/lib/typescript/components/Poll/components/MultipleVotesSettings.d.ts.map +1 -1
- package/lib/typescript/components/Poll/components/PollModalHeader.d.ts.map +1 -1
- 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/Reply/Reply.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/components/ui/Avatar/Avatar.d.ts.map +1 -1
- package/lib/typescript/components/ui/Button/Button.d.ts +10 -1
- package/lib/typescript/components/ui/Button/Button.d.ts.map +1 -1
- package/lib/typescript/contexts/accessibilityContext/AccessibilityContext.d.ts +1 -1
- package/lib/typescript/contexts/accessibilityContext/AccessibilityContext.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 +94 -1
- package/lib/typescript/i18n/es.json +96 -3
- package/lib/typescript/i18n/fr.json +94 -1
- package/lib/typescript/i18n/he.json +94 -1
- package/lib/typescript/i18n/hi.json +94 -1
- package/lib/typescript/i18n/it.json +94 -1
- package/lib/typescript/i18n/ja.json +94 -1
- package/lib/typescript/i18n/ko.json +94 -1
- package/lib/typescript/i18n/nl.json +94 -1
- package/lib/typescript/i18n/pt-br.json +94 -1
- package/lib/typescript/i18n/ru.json +94 -1
- package/lib/typescript/i18n/tr.json +94 -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/test-utils/BetterSqlite.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 +93 -0
- package/lib/typescript/utils/i18n/Streami18n.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/offline-support/offline-feature.tsx +40 -34
- package/src/a11y/a11yUtils.ts +2 -2
- package/src/a11y/hooks/useA11yLabel.ts +7 -4
- package/src/a11y/hooks/useAccessibilityActivateAction.ts +44 -0
- package/src/a11y/index.ts +1 -0
- package/src/components/AttachmentPicker/AttachmentPicker.tsx +23 -1
- package/src/components/AttachmentPicker/components/AttachmentMediaPicker/AttachmentMediaPicker.tsx +1 -0
- package/src/components/AttachmentPicker/components/AttachmentMediaPicker/AttachmentPickerItem.tsx +15 -2
- package/src/components/AttachmentPicker/components/AttachmentPickerContent.tsx +4 -3
- package/src/components/AttachmentPicker/components/AttachmentTypePickerButton.tsx +9 -0
- 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/__tests__/ChannelListView.test.tsx +16 -5
- package/src/components/ChannelList/hooks/__tests__/useChannelActions.test.tsx +123 -0
- package/src/components/ChannelList/hooks/useChannelActions.ts +181 -12
- package/src/components/ImageGallery/__tests__/ImageGalleryFooter.test.tsx +9 -3
- package/src/components/ImageGallery/__tests__/ImageGalleryHeader.test.tsx +4 -1
- package/src/components/ImageGallery/components/ImageGalleryFooter.tsx +2 -2
- package/src/components/ImageGallery/components/ImageGalleryHeader.tsx +1 -1
- package/src/components/ImageGallery/components/ImageGalleryVideoControl.tsx +1 -1
- 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/AttachmentRemoveControl.tsx +18 -2
- package/src/components/MessageInput/components/AttachmentPreview/AttachmentUploadPreviewList.tsx +1 -10
- package/src/components/MessageInput/components/AudioRecorder/AudioRecorder.tsx +13 -2
- package/src/components/MessageInput/components/AudioRecorder/AudioRecordingButton.tsx +35 -14
- package/src/components/MessageInput/components/InputButtons/AttachButton.tsx +13 -3
- package/src/components/MessageInput/components/OutputButtons/EditButton.tsx +1 -0
- package/src/components/MessageInput/components/OutputButtons/SendButton.tsx +1 -0
- package/src/components/MessageInput/components/OutputButtons/index.tsx +1 -1
- package/src/components/MessageList/MessageFlashList.tsx +26 -3
- package/src/components/MessageList/MessageList.tsx +26 -3
- package/src/components/MessageList/ScrollToBottomButton.tsx +18 -6
- package/src/components/MessageList/UnreadMessagesNotification.tsx +1 -0
- package/src/components/MessageList/__tests__/MessageList.test.tsx +221 -0
- package/src/components/MessageList/__tests__/ScrollToBottomButton.test.tsx +2 -2
- package/src/components/MessageList/__tests__/__snapshots__/ScrollToBottomButton.test.tsx.snap +3 -1
- package/src/components/MessageList/hooks/useScrollToBottomAccessibilityAction.ts +74 -0
- package/src/components/MessageMenu/MessageActionListItem.tsx +10 -4
- package/src/components/MessageMenu/MessageReactionPicker.tsx +1 -0
- package/src/components/MessageMenu/ReactionButton.tsx +7 -9
- package/src/components/MessageMenu/__tests__/MessageReactionPicker.test.tsx +13 -15
- package/src/components/MessageMenu/__tests__/MessageUserReactions.test.tsx +20 -18
- package/src/components/MessageMenu/__tests__/ReactionButton.test.tsx +18 -5
- package/src/components/MessageMenu/hooks/useFetchReactions.ts +17 -2
- package/src/components/Notifications/Notification.tsx +254 -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/CreatePollHeader.tsx +2 -0
- package/src/components/Poll/components/MultipleVotesSettings.tsx +2 -0
- package/src/components/Poll/components/PollModalHeader.tsx +1 -0
- package/src/components/Poll/components/PollOption.tsx +10 -6
- package/src/components/Poll/hooks/usePollState.ts +26 -2
- package/src/components/Reply/Reply.tsx +4 -1
- package/src/components/Thread/Thread.tsx +24 -16
- package/src/components/Thread/__tests__/__snapshots__/Thread.test.tsx.snap +3 -0
- package/src/components/ThreadList/ThreadList.tsx +33 -9
- package/src/components/index.ts +2 -0
- package/src/components/ui/Avatar/Avatar.tsx +2 -1
- package/src/components/ui/Button/Button.tsx +26 -0
- package/src/components/ui/Button/__tests__/Button.test.tsx +44 -0
- package/src/contexts/accessibilityContext/AccessibilityContext.tsx +35 -1
- 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 +94 -1
- package/src/i18n/es.json +96 -3
- package/src/i18n/fr.json +94 -1
- package/src/i18n/he.json +94 -1
- package/src/i18n/hi.json +94 -1
- package/src/i18n/it.json +94 -1
- package/src/i18n/ja.json +94 -1
- package/src/i18n/ko.json +94 -1
- package/src/i18n/nl.json +94 -1
- package/src/i18n/pt-br.json +94 -1
- package/src/i18n/ru.json +94 -1
- package/src/i18n/tr.json +94 -1
- package/src/mock-builders/DB/mock.ts +2 -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/test-utils/BetterSqlite.ts +3 -1
- 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,480 @@
|
|
|
1
|
+
import React, { PropsWithChildren } from 'react';
|
|
2
|
+
|
|
3
|
+
import { Pressable, Text } from 'react-native';
|
|
4
|
+
|
|
5
|
+
import { act, fireEvent, render, screen, waitFor } from '@testing-library/react-native';
|
|
6
|
+
import { NotificationManager } from 'stream-chat';
|
|
7
|
+
|
|
8
|
+
import { ChannelProvider } from '../../../contexts/channelContext/ChannelContext';
|
|
9
|
+
import { ChatProvider } from '../../../contexts/chatContext/ChatContext';
|
|
10
|
+
import {
|
|
11
|
+
ComponentOverrides,
|
|
12
|
+
WithComponents,
|
|
13
|
+
} from '../../../contexts/componentsContext/ComponentsContext';
|
|
14
|
+
import { ThemeProvider } from '../../../contexts/themeContext/ThemeContext';
|
|
15
|
+
import {
|
|
16
|
+
DEFAULT_USER_LANGUAGE,
|
|
17
|
+
TranslationProvider,
|
|
18
|
+
} from '../../../contexts/translationContext/TranslationContext';
|
|
19
|
+
import type { TranslationContextValue } from '../../../contexts/translationContext/TranslationContext';
|
|
20
|
+
import { useNotificationApi } from '../hooks/useNotificationApi';
|
|
21
|
+
import { NotificationList } from '../NotificationList';
|
|
22
|
+
import { NotificationTargetProvider } from '../NotificationTargetContext';
|
|
23
|
+
|
|
24
|
+
const t = ((key: string, options?: Record<string, unknown>) => {
|
|
25
|
+
if (options?.reason && key.includes('{{reason}}')) {
|
|
26
|
+
return key.replace('{{reason}}', String(options.reason));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return key;
|
|
30
|
+
}) as TranslationContextValue['t'];
|
|
31
|
+
|
|
32
|
+
const createWrapper =
|
|
33
|
+
(manager: NotificationManager, overrides?: ComponentOverrides) =>
|
|
34
|
+
({ children }: PropsWithChildren) => (
|
|
35
|
+
<ChatProvider value={{ client: { notifications: manager } } as never}>
|
|
36
|
+
<ChannelProvider value={{ channel: { cid: 'messaging:general' } } as never}>
|
|
37
|
+
<TranslationProvider
|
|
38
|
+
value={{
|
|
39
|
+
t,
|
|
40
|
+
tDateTimeParser: (input) => input ?? new Date(),
|
|
41
|
+
userLanguage: DEFAULT_USER_LANGUAGE,
|
|
42
|
+
}}
|
|
43
|
+
>
|
|
44
|
+
<ThemeProvider>
|
|
45
|
+
<NotificationTargetProvider hostId='channel:messaging:general' panel='channel'>
|
|
46
|
+
{overrides ? (
|
|
47
|
+
<WithComponents overrides={overrides}>{children}</WithComponents>
|
|
48
|
+
) : (
|
|
49
|
+
children
|
|
50
|
+
)}
|
|
51
|
+
</NotificationTargetProvider>
|
|
52
|
+
</ThemeProvider>
|
|
53
|
+
</TranslationProvider>
|
|
54
|
+
</ChannelProvider>
|
|
55
|
+
</ChatProvider>
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
describe('NotificationList', () => {
|
|
59
|
+
it('renders client notifications and starts their timeout once displayed', async () => {
|
|
60
|
+
const manager = new NotificationManager();
|
|
61
|
+
const startTimeoutSpy = jest.spyOn(manager, 'startTimeout').mockImplementation();
|
|
62
|
+
|
|
63
|
+
render(<NotificationList panel='channel' />, { wrapper: createWrapper(manager) });
|
|
64
|
+
|
|
65
|
+
act(() => {
|
|
66
|
+
manager.add({
|
|
67
|
+
message: 'Upload failed',
|
|
68
|
+
options: { severity: 'error', tags: ['target:channel'] },
|
|
69
|
+
origin: { emitter: 'test' },
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
await waitFor(() => expect(screen.getByText('Upload failed')).toBeTruthy());
|
|
74
|
+
expect(screen.getByTestId('notification-icon')).toBeTruthy();
|
|
75
|
+
expect(startTimeoutSpy).toHaveBeenCalledWith(manager.notifications[0].id);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('applies a bottom offset on top of the default bottom inset', async () => {
|
|
79
|
+
const manager = new NotificationManager();
|
|
80
|
+
jest.spyOn(manager, 'startTimeout').mockImplementation();
|
|
81
|
+
|
|
82
|
+
render(<NotificationList bottomOffset={80} panel='channel' />, {
|
|
83
|
+
wrapper: createWrapper(manager),
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
act(() => {
|
|
87
|
+
manager.add({
|
|
88
|
+
message: 'Floating composer notice',
|
|
89
|
+
options: { severity: 'info', tags: ['target:channel'] },
|
|
90
|
+
origin: { emitter: 'test' },
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
await waitFor(() => expect(screen.getByText('Floating composer notice')).toBeTruthy());
|
|
95
|
+
expect(screen.queryByTestId('notification-icon')).toBeNull();
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('renders default notifications without an icon when severity is omitted', async () => {
|
|
99
|
+
const manager = new NotificationManager();
|
|
100
|
+
jest.spyOn(manager, 'startTimeout').mockImplementation();
|
|
101
|
+
|
|
102
|
+
render(<NotificationList panel='channel' />, {
|
|
103
|
+
wrapper: createWrapper(manager),
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
act(() => {
|
|
107
|
+
manager.add({
|
|
108
|
+
message: 'Default notice',
|
|
109
|
+
options: { tags: ['target:channel'] },
|
|
110
|
+
origin: { emitter: 'test' },
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
await waitFor(() => expect(screen.getByText('Default notice')).toBeTruthy());
|
|
115
|
+
expect(screen.queryByTestId('notification-icon')).toBeNull();
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it('applies a top offset on top of the default top inset', async () => {
|
|
119
|
+
const manager = new NotificationManager();
|
|
120
|
+
jest.spyOn(manager, 'startTimeout').mockImplementation();
|
|
121
|
+
|
|
122
|
+
render(<NotificationList panel='channel' topOffset={40} verticalAlignment='top' />, {
|
|
123
|
+
wrapper: createWrapper(manager),
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
act(() => {
|
|
127
|
+
manager.add({
|
|
128
|
+
message: 'Top notice',
|
|
129
|
+
options: { severity: 'info', tags: ['target:channel'] },
|
|
130
|
+
origin: { emitter: 'test' },
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
await waitFor(() => expect(screen.getByText('Top notice')).toBeTruthy());
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it('does not render system notifications in the snackbar list', () => {
|
|
138
|
+
const manager = new NotificationManager();
|
|
139
|
+
manager.add({
|
|
140
|
+
message: 'System notice',
|
|
141
|
+
options: { severity: 'info', tags: ['system'] },
|
|
142
|
+
origin: { emitter: 'test' },
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
render(<NotificationList />, { wrapper: createWrapper(manager) });
|
|
146
|
+
|
|
147
|
+
expect(screen.queryByTestId('notification-list')).toBeNull();
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it('removes non-system notifications for its panel on unmount', async () => {
|
|
151
|
+
const manager = new NotificationManager();
|
|
152
|
+
jest.spyOn(manager, 'startTimeout').mockImplementation();
|
|
153
|
+
let channelId = '';
|
|
154
|
+
let threadId = '';
|
|
155
|
+
let systemId = '';
|
|
156
|
+
|
|
157
|
+
const { unmount } = render(<NotificationList panel='channel' />, {
|
|
158
|
+
wrapper: createWrapper(manager),
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
act(() => {
|
|
162
|
+
channelId = manager.add({
|
|
163
|
+
message: 'Channel notice',
|
|
164
|
+
options: { severity: 'info', tags: ['target:channel'] },
|
|
165
|
+
origin: { emitter: 'test' },
|
|
166
|
+
});
|
|
167
|
+
threadId = manager.add({
|
|
168
|
+
message: 'Thread notice',
|
|
169
|
+
options: { severity: 'info', tags: ['target:thread'] },
|
|
170
|
+
origin: { emitter: 'test' },
|
|
171
|
+
});
|
|
172
|
+
systemId = manager.add({
|
|
173
|
+
message: 'System notice',
|
|
174
|
+
options: { severity: 'info', tags: ['system', 'target:channel'] },
|
|
175
|
+
origin: { emitter: 'test' },
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
await waitFor(() => expect(screen.getByText('Channel notice')).toBeTruthy());
|
|
180
|
+
|
|
181
|
+
unmount();
|
|
182
|
+
|
|
183
|
+
expect(manager.notifications.some((notification) => notification.id === channelId)).toBe(false);
|
|
184
|
+
expect(manager.notifications.some((notification) => notification.id === threadId)).toBe(true);
|
|
185
|
+
expect(manager.notifications.some((notification) => notification.id === systemId)).toBe(true);
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it('dismisses persistent notifications with the close button', async () => {
|
|
189
|
+
const manager = new NotificationManager();
|
|
190
|
+
const id = manager.add({
|
|
191
|
+
message: 'Persistent notice',
|
|
192
|
+
options: { duration: 0, severity: 'warning', tags: ['target:channel'] },
|
|
193
|
+
origin: { emitter: 'test' },
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
render(<NotificationList panel='channel' />, { wrapper: createWrapper(manager) });
|
|
197
|
+
|
|
198
|
+
await waitFor(() => expect(screen.getByText('Persistent notice')).toBeTruthy());
|
|
199
|
+
fireEvent.press(screen.getByTestId('notification-close-button'));
|
|
200
|
+
|
|
201
|
+
await waitFor(() => {
|
|
202
|
+
expect(manager.notifications.some((notification) => notification.id === id)).toBe(false);
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
it('shows the newest notification and removes older matching notifications instead of queueing', async () => {
|
|
207
|
+
const manager = new NotificationManager();
|
|
208
|
+
const startTimeoutSpy = jest.spyOn(manager, 'startTimeout').mockImplementation();
|
|
209
|
+
let firstId = '';
|
|
210
|
+
let threadId = '';
|
|
211
|
+
let secondId = '';
|
|
212
|
+
|
|
213
|
+
render(<NotificationList panel='channel' />, { wrapper: createWrapper(manager) });
|
|
214
|
+
|
|
215
|
+
act(() => {
|
|
216
|
+
firstId = manager.add({
|
|
217
|
+
message: 'First notice',
|
|
218
|
+
options: { severity: 'info', tags: ['target:channel'], type: 'ui:first' },
|
|
219
|
+
origin: { emitter: 'test' },
|
|
220
|
+
});
|
|
221
|
+
threadId = manager.add({
|
|
222
|
+
message: 'Thread notice',
|
|
223
|
+
options: { severity: 'info', tags: ['target:thread'], type: 'ui:thread' },
|
|
224
|
+
origin: { emitter: 'test' },
|
|
225
|
+
});
|
|
226
|
+
secondId = manager.add({
|
|
227
|
+
message: 'Second notice',
|
|
228
|
+
options: { severity: 'warning', tags: ['target:channel'], type: 'ui:second' },
|
|
229
|
+
origin: { emitter: 'test' },
|
|
230
|
+
});
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
await waitFor(() => expect(screen.getByText('Second notice')).toBeTruthy());
|
|
234
|
+
expect(screen.queryByText('First notice')).toBeNull();
|
|
235
|
+
|
|
236
|
+
await waitFor(() => {
|
|
237
|
+
expect(manager.notifications.some((notification) => notification.id === firstId)).toBe(false);
|
|
238
|
+
expect(manager.notifications.some((notification) => notification.id === threadId)).toBe(true);
|
|
239
|
+
expect(manager.notifications.some((notification) => notification.id === secondId)).toBe(true);
|
|
240
|
+
});
|
|
241
|
+
expect(startTimeoutSpy).toHaveBeenCalledWith(secondId);
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
it('keeps a persistent notification visible when a transient notification arrives', async () => {
|
|
245
|
+
const manager = new NotificationManager();
|
|
246
|
+
const startTimeoutSpy = jest.spyOn(manager, 'startTimeout').mockImplementation();
|
|
247
|
+
const retryHandler = jest.fn();
|
|
248
|
+
let persistentId = '';
|
|
249
|
+
let transientId = '';
|
|
250
|
+
|
|
251
|
+
render(<NotificationList panel='channel' />, { wrapper: createWrapper(manager) });
|
|
252
|
+
|
|
253
|
+
act(() => {
|
|
254
|
+
persistentId = manager.add({
|
|
255
|
+
message: 'Retry upload',
|
|
256
|
+
options: {
|
|
257
|
+
actions: [{ handler: retryHandler, label: 'Retry' }],
|
|
258
|
+
duration: 0,
|
|
259
|
+
severity: 'error',
|
|
260
|
+
tags: ['target:channel'],
|
|
261
|
+
type: 'ui:upload:retry',
|
|
262
|
+
},
|
|
263
|
+
origin: { emitter: 'test' },
|
|
264
|
+
});
|
|
265
|
+
transientId = manager.add({
|
|
266
|
+
message: 'Copied',
|
|
267
|
+
options: { severity: 'success', tags: ['target:channel'], type: 'ui:copy' },
|
|
268
|
+
origin: { emitter: 'test' },
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
await waitFor(() => expect(screen.getByText('Retry upload')).toBeTruthy());
|
|
273
|
+
fireEvent.press(screen.getByLabelText('Retry'));
|
|
274
|
+
expect(retryHandler).toHaveBeenCalledTimes(1);
|
|
275
|
+
expect(screen.queryByText('Copied')).toBeNull();
|
|
276
|
+
|
|
277
|
+
await waitFor(() => {
|
|
278
|
+
expect(manager.notifications.some((notification) => notification.id === persistentId)).toBe(
|
|
279
|
+
true,
|
|
280
|
+
);
|
|
281
|
+
expect(manager.notifications.some((notification) => notification.id === transientId)).toBe(
|
|
282
|
+
false,
|
|
283
|
+
);
|
|
284
|
+
});
|
|
285
|
+
expect(startTimeoutSpy).toHaveBeenCalledWith(persistentId);
|
|
286
|
+
expect(startTimeoutSpy).not.toHaveBeenCalledWith(transientId);
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
it('lets a persistent notification replace a transient notification', async () => {
|
|
290
|
+
const manager = new NotificationManager();
|
|
291
|
+
let transientId = '';
|
|
292
|
+
let persistentId = '';
|
|
293
|
+
|
|
294
|
+
render(<NotificationList panel='channel' />, { wrapper: createWrapper(manager) });
|
|
295
|
+
|
|
296
|
+
act(() => {
|
|
297
|
+
transientId = manager.add({
|
|
298
|
+
message: 'Copied',
|
|
299
|
+
options: { severity: 'success', tags: ['target:channel'], type: 'ui:copy' },
|
|
300
|
+
origin: { emitter: 'test' },
|
|
301
|
+
});
|
|
302
|
+
persistentId = manager.add({
|
|
303
|
+
message: 'Retry upload',
|
|
304
|
+
options: {
|
|
305
|
+
actions: [{ handler: jest.fn(), label: 'Retry' }],
|
|
306
|
+
duration: 0,
|
|
307
|
+
severity: 'error',
|
|
308
|
+
tags: ['target:channel'],
|
|
309
|
+
type: 'ui:upload:retry',
|
|
310
|
+
},
|
|
311
|
+
origin: { emitter: 'test' },
|
|
312
|
+
});
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
await waitFor(() => expect(screen.getByText('Retry upload')).toBeTruthy());
|
|
316
|
+
expect(screen.queryByText('Copied')).toBeNull();
|
|
317
|
+
|
|
318
|
+
await waitFor(() => {
|
|
319
|
+
expect(manager.notifications.some((notification) => notification.id === transientId)).toBe(
|
|
320
|
+
false,
|
|
321
|
+
);
|
|
322
|
+
expect(manager.notifications.some((notification) => notification.id === persistentId)).toBe(
|
|
323
|
+
true,
|
|
324
|
+
);
|
|
325
|
+
});
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
it('starts action notification timeouts with a longer LLC duration override', async () => {
|
|
329
|
+
const manager = new NotificationManager();
|
|
330
|
+
const startTimeoutSpy = jest.spyOn(manager, 'startTimeout').mockImplementation();
|
|
331
|
+
let id = '';
|
|
332
|
+
|
|
333
|
+
render(<NotificationList panel='channel' />, { wrapper: createWrapper(manager) });
|
|
334
|
+
|
|
335
|
+
act(() => {
|
|
336
|
+
id = manager.add({
|
|
337
|
+
message: 'Undo delete',
|
|
338
|
+
options: {
|
|
339
|
+
actions: [{ handler: jest.fn(), label: 'Undo' }],
|
|
340
|
+
severity: 'info',
|
|
341
|
+
tags: ['target:channel'],
|
|
342
|
+
type: 'ui:message:delete:undo',
|
|
343
|
+
},
|
|
344
|
+
origin: { emitter: 'test' },
|
|
345
|
+
});
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
await waitFor(() => expect(screen.getByText('Undo delete')).toBeTruthy());
|
|
349
|
+
expect(startTimeoutSpy).toHaveBeenCalledWith(id, 5000);
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
it('updates repeated matching notifications without remounting the snackbar item', async () => {
|
|
353
|
+
const manager = new NotificationManager();
|
|
354
|
+
const startTimeoutSpy = jest.spyOn(manager, 'startTimeout').mockImplementation();
|
|
355
|
+
let mountCount = 0;
|
|
356
|
+
let firstId = '';
|
|
357
|
+
let secondId = '';
|
|
358
|
+
|
|
359
|
+
const Notification: ComponentOverrides['Notification'] = ({ notification }) => {
|
|
360
|
+
React.useEffect(() => {
|
|
361
|
+
mountCount += 1;
|
|
362
|
+
}, []);
|
|
363
|
+
|
|
364
|
+
return <Text>{notification.message}</Text>;
|
|
365
|
+
};
|
|
366
|
+
|
|
367
|
+
render(<NotificationList panel='channel' />, {
|
|
368
|
+
wrapper: createWrapper(manager, { Notification }),
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
act(() => {
|
|
372
|
+
firstId = manager.add({
|
|
373
|
+
message: 'Copied',
|
|
374
|
+
options: { severity: 'success', tags: ['target:channel'], type: 'ui:copy' },
|
|
375
|
+
origin: { emitter: 'test' },
|
|
376
|
+
});
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
await waitFor(() => expect(screen.getByText('Copied')).toBeTruthy());
|
|
380
|
+
expect(mountCount).toBe(1);
|
|
381
|
+
|
|
382
|
+
act(() => {
|
|
383
|
+
secondId = manager.add({
|
|
384
|
+
message: 'Copied again',
|
|
385
|
+
options: { severity: 'success', tags: ['target:channel'], type: 'ui:copy' },
|
|
386
|
+
origin: { emitter: 'test' },
|
|
387
|
+
});
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
await waitFor(() => expect(screen.getByText('Copied again')).toBeTruthy());
|
|
391
|
+
await waitFor(() => {
|
|
392
|
+
expect(manager.notifications.some((notification) => notification.id === firstId)).toBe(false);
|
|
393
|
+
expect(manager.notifications.some((notification) => notification.id === secondId)).toBe(true);
|
|
394
|
+
});
|
|
395
|
+
expect(mountCount).toBe(1);
|
|
396
|
+
expect(startTimeoutSpy).toHaveBeenCalledWith(firstId);
|
|
397
|
+
expect(startTimeoutSpy).toHaveBeenCalledWith(secondId);
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
it('adds an exact target tag to untagged manager notifications from the latest active host', async () => {
|
|
401
|
+
const manager = new NotificationManager();
|
|
402
|
+
jest.spyOn(manager, 'startTimeout').mockImplementation();
|
|
403
|
+
let id = '';
|
|
404
|
+
|
|
405
|
+
render(
|
|
406
|
+
<>
|
|
407
|
+
<NotificationTargetProvider hostId='channel:messaging:first' panel='channel'>
|
|
408
|
+
<NotificationList />
|
|
409
|
+
</NotificationTargetProvider>
|
|
410
|
+
<NotificationTargetProvider hostId='channel:messaging:second' panel='channel'>
|
|
411
|
+
<NotificationList />
|
|
412
|
+
</NotificationTargetProvider>
|
|
413
|
+
</>,
|
|
414
|
+
{ wrapper: createWrapper(manager) },
|
|
415
|
+
);
|
|
416
|
+
|
|
417
|
+
act(() => {
|
|
418
|
+
id = manager.add({
|
|
419
|
+
message: 'Untagged notice',
|
|
420
|
+
options: { severity: 'info' },
|
|
421
|
+
origin: { emitter: 'test' },
|
|
422
|
+
});
|
|
423
|
+
});
|
|
424
|
+
|
|
425
|
+
await waitFor(() => expect(screen.getByText('Untagged notice')).toBeTruthy());
|
|
426
|
+
expect(screen.getAllByText('Untagged notice')).toHaveLength(1);
|
|
427
|
+
expect(manager.notifications.find((notification) => notification.id === id)?.tags).toEqual([
|
|
428
|
+
'target:channel:channel:messaging:second',
|
|
429
|
+
]);
|
|
430
|
+
});
|
|
431
|
+
|
|
432
|
+
it('adds an exact target tag to action-scoped manager notifications from the triggering host', async () => {
|
|
433
|
+
const manager = new NotificationManager();
|
|
434
|
+
jest.spyOn(manager, 'startTimeout').mockImplementation();
|
|
435
|
+
|
|
436
|
+
const Trigger = () => {
|
|
437
|
+
const { runWithNotificationTarget } = useNotificationApi();
|
|
438
|
+
|
|
439
|
+
return (
|
|
440
|
+
<Pressable
|
|
441
|
+
onPress={() =>
|
|
442
|
+
runWithNotificationTarget(() => {
|
|
443
|
+
manager.add({
|
|
444
|
+
message: 'Action-scoped notice',
|
|
445
|
+
options: { severity: 'info' },
|
|
446
|
+
origin: { emitter: 'Poll' },
|
|
447
|
+
});
|
|
448
|
+
})
|
|
449
|
+
}
|
|
450
|
+
testID='trigger-action-notification'
|
|
451
|
+
>
|
|
452
|
+
<Text>Trigger</Text>
|
|
453
|
+
</Pressable>
|
|
454
|
+
);
|
|
455
|
+
};
|
|
456
|
+
|
|
457
|
+
render(
|
|
458
|
+
<>
|
|
459
|
+
<NotificationTargetProvider hostId='channel:messaging:first' panel='channel'>
|
|
460
|
+
<Trigger />
|
|
461
|
+
<NotificationList />
|
|
462
|
+
</NotificationTargetProvider>
|
|
463
|
+
<NotificationTargetProvider hostId='channel:messaging:second' panel='channel'>
|
|
464
|
+
<NotificationList />
|
|
465
|
+
</NotificationTargetProvider>
|
|
466
|
+
</>,
|
|
467
|
+
{ wrapper: createWrapper(manager) },
|
|
468
|
+
);
|
|
469
|
+
|
|
470
|
+
fireEvent.press(screen.getByTestId('trigger-action-notification'));
|
|
471
|
+
|
|
472
|
+
await waitFor(() => expect(screen.getByText('Action-scoped notice')).toBeTruthy());
|
|
473
|
+
const notification = manager.notifications.find(
|
|
474
|
+
(notification) => notification.message === 'Action-scoped notice',
|
|
475
|
+
);
|
|
476
|
+
|
|
477
|
+
expect(screen.getAllByText('Action-scoped notice')).toHaveLength(1);
|
|
478
|
+
expect(notification?.tags).toEqual(['target:channel:channel:messaging:first']);
|
|
479
|
+
});
|
|
480
|
+
});
|
|
@@ -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
|
+
});
|