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,37 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
ChannelContext,
|
|
5
|
+
type ChannelContextValue,
|
|
6
|
+
} from '../../../contexts/channelContext/ChannelContext';
|
|
7
|
+
import {
|
|
8
|
+
ChannelsContext,
|
|
9
|
+
type ChannelsContextValue,
|
|
10
|
+
} from '../../../contexts/channelsContext/ChannelsContext';
|
|
11
|
+
import {
|
|
12
|
+
ThreadContext,
|
|
13
|
+
type ThreadContextValue,
|
|
14
|
+
} from '../../../contexts/threadContext/ThreadContext';
|
|
15
|
+
import {
|
|
16
|
+
ThreadsContext,
|
|
17
|
+
type ThreadsContextValue,
|
|
18
|
+
} from '../../../contexts/threadsContext/ThreadsContext';
|
|
19
|
+
import { DEFAULT_BASE_CONTEXT_VALUE } from '../../../contexts/utils/defaultBaseContextValue';
|
|
20
|
+
import type { NotificationTargetPanel } from '../notificationTarget';
|
|
21
|
+
|
|
22
|
+
const isProvided = <T>(value: T) => value !== (DEFAULT_BASE_CONTEXT_VALUE as T);
|
|
23
|
+
|
|
24
|
+
export const useNotificationTarget = (): NotificationTargetPanel | undefined => {
|
|
25
|
+
const channelContext = useContext(ChannelContext) as ChannelContextValue;
|
|
26
|
+
const channelsContext = useContext(ChannelsContext) as ChannelsContextValue;
|
|
27
|
+
const threadContext = useContext(ThreadContext) as ThreadContextValue;
|
|
28
|
+
const threadsContext = useContext(ThreadsContext) as ThreadsContextValue;
|
|
29
|
+
|
|
30
|
+
if (isProvided(channelContext) && channelContext.threadList) return 'thread';
|
|
31
|
+
if (isProvided(threadContext) && threadContext.threadInstance) return 'thread';
|
|
32
|
+
if (isProvided(channelContext) && channelContext.channel) return 'channel';
|
|
33
|
+
if (isProvided(threadsContext)) return 'thread-list';
|
|
34
|
+
if (isProvided(channelsContext)) return 'channel-list';
|
|
35
|
+
|
|
36
|
+
return undefined;
|
|
37
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
|
|
3
|
+
import type { Notification, NotificationManagerState } from 'stream-chat';
|
|
4
|
+
|
|
5
|
+
import { useChatContext } from '../../../contexts/chatContext/ChatContext';
|
|
6
|
+
import { useStateStore } from '../../../hooks/useStateStore';
|
|
7
|
+
import { isNotificationForTarget, type NotificationTarget } from '../notificationTarget';
|
|
8
|
+
|
|
9
|
+
export type UseNotificationsFilter = (notification: Notification) => boolean;
|
|
10
|
+
|
|
11
|
+
export type UseNotificationsOptions = {
|
|
12
|
+
/** Additional filter applied after optional target filtering. */
|
|
13
|
+
filter?: UseNotificationsFilter;
|
|
14
|
+
/** When true, returns an empty list unless an exact target is provided. */
|
|
15
|
+
requireTarget?: boolean;
|
|
16
|
+
/** Exact target used to select notifications for one host. */
|
|
17
|
+
target?: NotificationTarget;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/** Subscribes to the client notification store and returns matching non-system notifications. */
|
|
21
|
+
export const useNotifications = (options?: UseNotificationsOptions): Notification[] => {
|
|
22
|
+
const { client } = useChatContext();
|
|
23
|
+
const selector = useCallback(
|
|
24
|
+
(state: NotificationManagerState) => {
|
|
25
|
+
const notifications = state.notifications;
|
|
26
|
+
const target = options?.target;
|
|
27
|
+
const byTarget = target
|
|
28
|
+
? notifications.filter((notification) => isNotificationForTarget(notification, target))
|
|
29
|
+
: options?.requireTarget
|
|
30
|
+
? []
|
|
31
|
+
: notifications;
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
notifications: options?.filter ? byTarget.filter(options.filter) : byTarget,
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
[options?.filter, options?.requireTarget, options?.target],
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
const { notifications } = useStateStore(client.notifications.store, selector);
|
|
41
|
+
|
|
42
|
+
return notifications;
|
|
43
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
|
|
3
|
+
import type { Notification, NotificationManagerState } from 'stream-chat';
|
|
4
|
+
|
|
5
|
+
import { hasSystemNotificationTag } from './useNotificationApi';
|
|
6
|
+
|
|
7
|
+
import { useChatContext } from '../../../contexts/chatContext/ChatContext';
|
|
8
|
+
import { useStateStore } from '../../../hooks/useStateStore';
|
|
9
|
+
|
|
10
|
+
export type UseSystemNotificationsFilter = (notification: Notification) => boolean;
|
|
11
|
+
|
|
12
|
+
export type UseSystemNotificationsOptions = {
|
|
13
|
+
/** Additional filter applied to system-tagged notifications. */
|
|
14
|
+
filter?: UseSystemNotificationsFilter;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/** Subscribes to notifications tagged as system notifications. */
|
|
18
|
+
export const useSystemNotifications = (options?: UseSystemNotificationsOptions): Notification[] => {
|
|
19
|
+
const { client } = useChatContext();
|
|
20
|
+
const selector = useCallback(
|
|
21
|
+
(state: NotificationManagerState) => {
|
|
22
|
+
const withSystemTag = state.notifications.filter(hasSystemNotificationTag);
|
|
23
|
+
return {
|
|
24
|
+
notifications: options?.filter ? withSystemTag.filter(options.filter) : withSystemTag,
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
[options?.filter],
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
const { notifications } = useStateStore(client.notifications.store, selector);
|
|
31
|
+
|
|
32
|
+
return notifications;
|
|
33
|
+
};
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
import type { Notification } from 'stream-chat';
|
|
2
|
+
|
|
3
|
+
const NOTIFICATION_TARGET_PANELS = ['channel', 'thread', 'channel-list', 'thread-list'] as const;
|
|
4
|
+
const NOTIFICATION_TARGET_TAG_PREFIX = 'target:' as const;
|
|
5
|
+
|
|
6
|
+
/** Built-in SDK surfaces that can host snackbar notifications. */
|
|
7
|
+
export type BuiltInNotificationTargetPanel = (typeof NOTIFICATION_TARGET_PANELS)[number];
|
|
8
|
+
/** Notification surface name. Custom panel strings are supported for integrator-defined hosts. */
|
|
9
|
+
export type NotificationTargetPanel = BuiltInNotificationTargetPanel | (string & {});
|
|
10
|
+
/** Exact notification host within a panel. */
|
|
11
|
+
export type NotificationTarget = {
|
|
12
|
+
/** Stable id for a mounted notification host, for example a channel cid-derived id. */
|
|
13
|
+
hostId: string;
|
|
14
|
+
/** Surface that owns the host. */
|
|
15
|
+
panel: NotificationTargetPanel;
|
|
16
|
+
};
|
|
17
|
+
/** Owner object used to keep target stacks scoped to a notification manager instance. */
|
|
18
|
+
export type NotificationTargetOwner = object;
|
|
19
|
+
|
|
20
|
+
type ParsedNotificationTargetTag = {
|
|
21
|
+
hostId?: string;
|
|
22
|
+
panel: NotificationTargetPanel;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
type NotificationTargetStackItem = {
|
|
26
|
+
target: NotificationTarget;
|
|
27
|
+
token: symbol;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const activeNotificationTargets = new WeakMap<
|
|
31
|
+
NotificationTargetOwner,
|
|
32
|
+
NotificationTargetStackItem[]
|
|
33
|
+
>();
|
|
34
|
+
const actionNotificationTargets = new WeakMap<
|
|
35
|
+
NotificationTargetOwner,
|
|
36
|
+
NotificationTargetStackItem[]
|
|
37
|
+
>();
|
|
38
|
+
|
|
39
|
+
/** Returns whether a value can be encoded as a notification target panel segment. */
|
|
40
|
+
export const isNotificationTargetPanel = (value: unknown): value is NotificationTargetPanel =>
|
|
41
|
+
typeof value === 'string' && value.length > 0 && !value.includes(':');
|
|
42
|
+
|
|
43
|
+
/** Returns whether a value is one of the SDK's built-in notification panels. */
|
|
44
|
+
export const isBuiltInNotificationTargetPanel = (
|
|
45
|
+
value: unknown,
|
|
46
|
+
): value is BuiltInNotificationTargetPanel =>
|
|
47
|
+
typeof value === 'string' && (NOTIFICATION_TARGET_PANELS as readonly string[]).includes(value);
|
|
48
|
+
|
|
49
|
+
/** Builds a notification target tag. Without `hostId`, the tag targets every host in the panel. */
|
|
50
|
+
export const getNotificationTargetTag = (panel: NotificationTargetPanel, hostId?: string) =>
|
|
51
|
+
`${NOTIFICATION_TARGET_TAG_PREFIX}${panel}${hostId ? `:${hostId}` : ''}`;
|
|
52
|
+
|
|
53
|
+
/** Adds a broad or exact target tag to a notification tag list without duplicating tags. */
|
|
54
|
+
export const addNotificationTargetTag = (
|
|
55
|
+
panel: NotificationTargetPanel | undefined,
|
|
56
|
+
tags?: string[],
|
|
57
|
+
hostId?: string,
|
|
58
|
+
) => {
|
|
59
|
+
if (!panel) return tags ?? [];
|
|
60
|
+
|
|
61
|
+
return Array.from(new Set([getNotificationTargetTag(panel, hostId), ...(tags ?? [])]));
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/** Adds an exact panel and host target tag to a notification tag list. */
|
|
65
|
+
export const addExactNotificationTargetTag = (target: NotificationTarget, tags?: string[]) =>
|
|
66
|
+
addNotificationTargetTag(target.panel, tags, target.hostId);
|
|
67
|
+
|
|
68
|
+
/** Host id helper for channel notification targets. */
|
|
69
|
+
export const getChannelNotificationHostId = (cid: string) => `channel:${cid}` as const;
|
|
70
|
+
|
|
71
|
+
/** Host id helper for thread notification targets. */
|
|
72
|
+
export const getThreadNotificationHostId = (threadId: string) => `thread:${threadId}` as const;
|
|
73
|
+
|
|
74
|
+
/** Compares notification targets by panel and host id. */
|
|
75
|
+
export const isNotificationTargetEqual = (
|
|
76
|
+
left: NotificationTarget | undefined,
|
|
77
|
+
right: NotificationTarget | undefined,
|
|
78
|
+
) => !!left && !!right && left.panel === right.panel && left.hostId === right.hostId;
|
|
79
|
+
|
|
80
|
+
const isRecord = (value: unknown): value is Record<string, unknown> =>
|
|
81
|
+
typeof value === 'object' && value !== null;
|
|
82
|
+
|
|
83
|
+
const getStringValue = (value: unknown) => (typeof value === 'string' ? value : undefined);
|
|
84
|
+
|
|
85
|
+
const parseNotificationTargetTag = (tag: string): ParsedNotificationTargetTag | undefined => {
|
|
86
|
+
if (!tag.startsWith(NOTIFICATION_TARGET_TAG_PREFIX)) return undefined;
|
|
87
|
+
|
|
88
|
+
const tagValue = tag.slice(NOTIFICATION_TARGET_TAG_PREFIX.length);
|
|
89
|
+
const hostSeparatorIndex = tagValue.indexOf(':');
|
|
90
|
+
const panel = hostSeparatorIndex === -1 ? tagValue : tagValue.slice(0, hostSeparatorIndex);
|
|
91
|
+
|
|
92
|
+
if (!isNotificationTargetPanel(panel)) return undefined;
|
|
93
|
+
|
|
94
|
+
const hostId = hostSeparatorIndex === -1 ? undefined : tagValue.slice(hostSeparatorIndex + 1);
|
|
95
|
+
|
|
96
|
+
return hostId ? { hostId, panel } : { panel };
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const getNotificationTargetTags = (notification: Notification) =>
|
|
100
|
+
(notification.tags ?? [])
|
|
101
|
+
.map(parseNotificationTargetTag)
|
|
102
|
+
.filter((target): target is ParsedNotificationTargetTag => !!target);
|
|
103
|
+
|
|
104
|
+
/** Returns whether a tag list already contains a notification target tag. */
|
|
105
|
+
export const hasNotificationTargetTag = (tags: string[] | undefined) =>
|
|
106
|
+
tags?.some((tag) => !!parseNotificationTargetTag(tag)) ?? false;
|
|
107
|
+
|
|
108
|
+
const getExactNotificationTargetTags = (notification: Notification): NotificationTarget[] =>
|
|
109
|
+
getNotificationTargetTags(notification).filter(
|
|
110
|
+
(target): target is NotificationTarget => !!target.hostId,
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
const getNotificationTargetFromTags = (
|
|
114
|
+
notification: Notification,
|
|
115
|
+
): NotificationTarget | undefined => getExactNotificationTargetTags(notification)[0];
|
|
116
|
+
|
|
117
|
+
const getNotificationTargetFromComposer = (
|
|
118
|
+
notification: Notification,
|
|
119
|
+
): NotificationTarget | undefined => {
|
|
120
|
+
const composer = notification.origin.context?.composer;
|
|
121
|
+
if (!isRecord(composer)) return undefined;
|
|
122
|
+
|
|
123
|
+
const threadId = getStringValue(composer.threadId);
|
|
124
|
+
if (threadId) {
|
|
125
|
+
return { hostId: getThreadNotificationHostId(threadId), panel: 'thread' };
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const channel = composer.channel;
|
|
129
|
+
if (!isRecord(channel)) return undefined;
|
|
130
|
+
|
|
131
|
+
const cid = getStringValue(channel.cid);
|
|
132
|
+
return cid ? { hostId: getChannelNotificationHostId(cid), panel: 'channel' } : undefined;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
/** Resolves an exact notification target from tags or composer origin metadata. */
|
|
136
|
+
export const getNotificationTarget = (notification: Notification): NotificationTarget | undefined =>
|
|
137
|
+
getNotificationTargetFromTags(notification) ?? getNotificationTargetFromComposer(notification);
|
|
138
|
+
|
|
139
|
+
const getExplicitNotificationTargetPanels = (
|
|
140
|
+
notification: Notification,
|
|
141
|
+
): NotificationTargetPanel[] => {
|
|
142
|
+
const targetPanels = getNotificationTargetTags(notification).map(({ panel }) => panel);
|
|
143
|
+
|
|
144
|
+
if (targetPanels.length > 0) {
|
|
145
|
+
return Array.from(new Set(targetPanels));
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const panel = notification.origin.context?.panel;
|
|
149
|
+
return isNotificationTargetPanel(panel) ? [panel] : [];
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
/** Resolves the first target panel declared or inferred for a notification. */
|
|
153
|
+
export const getNotificationTargetPanel = (
|
|
154
|
+
notification: Notification,
|
|
155
|
+
): NotificationTargetPanel | undefined => {
|
|
156
|
+
const explicitPanels = getExplicitNotificationTargetPanels(notification);
|
|
157
|
+
if (explicitPanels.length > 0) return explicitPanels[0];
|
|
158
|
+
|
|
159
|
+
return getNotificationTarget(notification)?.panel;
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
/** Resolves all target panels declared or inferred for a notification. */
|
|
163
|
+
export const getNotificationTargetPanels = (
|
|
164
|
+
notification: Notification,
|
|
165
|
+
): NotificationTargetPanel[] => {
|
|
166
|
+
const explicitPanels = getExplicitNotificationTargetPanels(notification);
|
|
167
|
+
if (explicitPanels.length > 0) return explicitPanels;
|
|
168
|
+
|
|
169
|
+
const target = getNotificationTarget(notification);
|
|
170
|
+
return target ? [target.panel] : [];
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
const getNotificationTargetStack = (
|
|
174
|
+
stackMap: WeakMap<NotificationTargetOwner, NotificationTargetStackItem[]>,
|
|
175
|
+
owner: NotificationTargetOwner,
|
|
176
|
+
) => {
|
|
177
|
+
const stack = stackMap.get(owner) ?? [];
|
|
178
|
+
stackMap.set(owner, stack);
|
|
179
|
+
return stack;
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
const registerNotificationTarget = (
|
|
183
|
+
stackMap: WeakMap<NotificationTargetOwner, NotificationTargetStackItem[]>,
|
|
184
|
+
owner: NotificationTargetOwner,
|
|
185
|
+
target: NotificationTarget,
|
|
186
|
+
) => {
|
|
187
|
+
const token = Symbol('notification-target');
|
|
188
|
+
const stack = getNotificationTargetStack(stackMap, owner);
|
|
189
|
+
|
|
190
|
+
stack.push({ target, token });
|
|
191
|
+
|
|
192
|
+
return () => {
|
|
193
|
+
const currentStack = stackMap.get(owner);
|
|
194
|
+
if (!currentStack) return;
|
|
195
|
+
|
|
196
|
+
const itemIndex = currentStack.findIndex((item) => item.token === token);
|
|
197
|
+
if (itemIndex !== -1) {
|
|
198
|
+
currentStack.splice(itemIndex, 1);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if (currentStack.length === 0) {
|
|
202
|
+
stackMap.delete(owner);
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
const getLastNotificationTarget = (
|
|
208
|
+
stackMap: WeakMap<NotificationTargetOwner, NotificationTargetStackItem[]>,
|
|
209
|
+
owner: NotificationTargetOwner,
|
|
210
|
+
) => {
|
|
211
|
+
const stack = stackMap.get(owner);
|
|
212
|
+
return stack?.[stack.length - 1]?.target;
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
/** Registers a mounted notification host as the latest active fallback target. */
|
|
216
|
+
export const registerActiveNotificationTarget = (
|
|
217
|
+
owner: NotificationTargetOwner,
|
|
218
|
+
target: NotificationTarget,
|
|
219
|
+
) => registerNotificationTarget(activeNotificationTargets, owner, target);
|
|
220
|
+
|
|
221
|
+
/** Registers the target for notifications emitted while an action is running. */
|
|
222
|
+
export const registerNotificationActionTarget = (
|
|
223
|
+
owner: NotificationTargetOwner,
|
|
224
|
+
target: NotificationTarget,
|
|
225
|
+
) => registerNotificationTarget(actionNotificationTargets, owner, target);
|
|
226
|
+
|
|
227
|
+
/** Returns the latest mounted fallback target for a notification manager owner. */
|
|
228
|
+
export const getActiveNotificationTarget = (owner: NotificationTargetOwner) =>
|
|
229
|
+
getLastNotificationTarget(activeNotificationTargets, owner);
|
|
230
|
+
|
|
231
|
+
/** Returns the latest action-scoped target for a notification manager owner. */
|
|
232
|
+
export const getNotificationActionTarget = (owner: NotificationTargetOwner) =>
|
|
233
|
+
getLastNotificationTarget(actionNotificationTargets, owner);
|
|
234
|
+
|
|
235
|
+
const hasExactNotificationTargetTag = (notification: Notification) =>
|
|
236
|
+
getExactNotificationTargetTags(notification).length > 0;
|
|
237
|
+
|
|
238
|
+
const hasExplicitNotificationTargetPanel = (notification: Notification) =>
|
|
239
|
+
getExplicitNotificationTargetPanels(notification).length > 0;
|
|
240
|
+
|
|
241
|
+
const setNotificationTargetTag = (notification: Notification, target: NotificationTarget) => {
|
|
242
|
+
notification.tags = addExactNotificationTargetTag(target, notification.tags);
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
/** Mutates an unscoped notification by adding the best available exact target tag. */
|
|
246
|
+
export const resolveNotificationTargetTagIfNeeded = (
|
|
247
|
+
owner: NotificationTargetOwner,
|
|
248
|
+
notification: Notification,
|
|
249
|
+
) => {
|
|
250
|
+
if (hasExactNotificationTargetTag(notification)) return false;
|
|
251
|
+
if (hasExplicitNotificationTargetPanel(notification)) return false;
|
|
252
|
+
|
|
253
|
+
const composerTarget = getNotificationTargetFromComposer(notification);
|
|
254
|
+
if (composerTarget) {
|
|
255
|
+
setNotificationTargetTag(notification, composerTarget);
|
|
256
|
+
return true;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
const actionTarget = getNotificationActionTarget(owner);
|
|
260
|
+
if (actionTarget) {
|
|
261
|
+
setNotificationTargetTag(notification, actionTarget);
|
|
262
|
+
return true;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
const activeTarget = getActiveNotificationTarget(owner);
|
|
266
|
+
if (activeTarget) {
|
|
267
|
+
setNotificationTargetTag(notification, activeTarget);
|
|
268
|
+
return true;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
return false;
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
/** Returns whether a notification should be consumed by an exact target host. */
|
|
275
|
+
export const isNotificationForTarget = (notification: Notification, target: NotificationTarget) => {
|
|
276
|
+
const exactTargets = getExactNotificationTargetTags(notification);
|
|
277
|
+
if (exactTargets.length > 0) {
|
|
278
|
+
return exactTargets.some((exactTarget) => isNotificationTargetEqual(exactTarget, target));
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
const explicitTargetPanels = getExplicitNotificationTargetPanels(notification);
|
|
282
|
+
if (explicitTargetPanels.length > 0) {
|
|
283
|
+
return explicitTargetPanels.includes(target.panel);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
const inferredTarget = getNotificationTargetFromComposer(notification);
|
|
287
|
+
if (inferredTarget) {
|
|
288
|
+
return isNotificationTargetEqual(inferredTarget, target);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
return false;
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
/** Returns whether a notification should be consumed by any host in a panel. */
|
|
295
|
+
export const isNotificationForPanel = (
|
|
296
|
+
notification: Notification,
|
|
297
|
+
panel: NotificationTargetPanel,
|
|
298
|
+
) => {
|
|
299
|
+
const explicitTargetPanels = getNotificationTargetPanels(notification);
|
|
300
|
+
if (explicitTargetPanels.length > 0) {
|
|
301
|
+
return explicitTargetPanels.includes(panel);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
return false;
|
|
305
|
+
};
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import type { TFunction } from 'i18next';
|
|
2
|
+
import type { Notification } from 'stream-chat';
|
|
3
|
+
|
|
4
|
+
const normalizeReason = (notification?: Notification) => {
|
|
5
|
+
const reason = notification?.metadata?.reason;
|
|
6
|
+
if (typeof reason !== 'string' || !reason.length) return undefined;
|
|
7
|
+
|
|
8
|
+
return reason.toLowerCase();
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const withReasonFallback = ({
|
|
12
|
+
fallbackTranslationKey,
|
|
13
|
+
notification,
|
|
14
|
+
reasonTranslationKey,
|
|
15
|
+
t,
|
|
16
|
+
}: {
|
|
17
|
+
fallbackTranslationKey: string;
|
|
18
|
+
notification?: Notification;
|
|
19
|
+
reasonTranslationKey: string;
|
|
20
|
+
t: TFunction;
|
|
21
|
+
}) => {
|
|
22
|
+
const reason = normalizeReason(notification);
|
|
23
|
+
if (!reason) return t(fallbackTranslationKey);
|
|
24
|
+
|
|
25
|
+
return t(reasonTranslationKey, { reason });
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const translateAttachmentUploadBlocked = ({
|
|
29
|
+
notification,
|
|
30
|
+
t,
|
|
31
|
+
}: {
|
|
32
|
+
notification?: Notification;
|
|
33
|
+
t: TFunction;
|
|
34
|
+
}) => {
|
|
35
|
+
const rawReason = notification?.metadata?.reason;
|
|
36
|
+
let reason = t('unsupported file type');
|
|
37
|
+
if (typeof rawReason !== 'string') reason = t('unknown error');
|
|
38
|
+
if (rawReason === 'size_limit') reason = t('size limit');
|
|
39
|
+
|
|
40
|
+
return t('Attachment upload blocked due to {{reason}}', { reason });
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const translateAttachmentUploadFailed = ({
|
|
44
|
+
notification,
|
|
45
|
+
t,
|
|
46
|
+
}: {
|
|
47
|
+
notification?: Notification;
|
|
48
|
+
t: TFunction;
|
|
49
|
+
}) =>
|
|
50
|
+
withReasonFallback({
|
|
51
|
+
fallbackTranslationKey: 'Error uploading attachment',
|
|
52
|
+
notification,
|
|
53
|
+
reasonTranslationKey: 'Attachment upload failed due to {{reason}}',
|
|
54
|
+
t,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const translatePollCreateFailed = ({
|
|
58
|
+
notification,
|
|
59
|
+
t,
|
|
60
|
+
}: {
|
|
61
|
+
notification?: Notification;
|
|
62
|
+
t: TFunction;
|
|
63
|
+
}) =>
|
|
64
|
+
withReasonFallback({
|
|
65
|
+
fallbackTranslationKey: 'Failed to create the poll',
|
|
66
|
+
notification,
|
|
67
|
+
reasonTranslationKey: 'Failed to create the poll due to {{reason}}',
|
|
68
|
+
t,
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const translatePollEndFailed = ({
|
|
72
|
+
notification,
|
|
73
|
+
t,
|
|
74
|
+
}: {
|
|
75
|
+
notification?: Notification;
|
|
76
|
+
t: TFunction;
|
|
77
|
+
}) =>
|
|
78
|
+
withReasonFallback({
|
|
79
|
+
fallbackTranslationKey: 'Failed to end the poll',
|
|
80
|
+
notification,
|
|
81
|
+
reasonTranslationKey: 'Failed to end the poll due to {{reason}}',
|
|
82
|
+
t,
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
const translateCommandDisabled = ({
|
|
86
|
+
notification,
|
|
87
|
+
t,
|
|
88
|
+
}: {
|
|
89
|
+
notification?: Notification;
|
|
90
|
+
t: TFunction;
|
|
91
|
+
}) => {
|
|
92
|
+
const reason = normalizeReason(notification);
|
|
93
|
+
|
|
94
|
+
if (reason === 'editing') {
|
|
95
|
+
return t('Command not available while editing');
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (reason === 'quoted_message') {
|
|
99
|
+
return t('Command not available while replying');
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return t(notification?.message || 'Command not available');
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const notificationTranslatorsByType: Record<
|
|
106
|
+
string,
|
|
107
|
+
(options: { notification: Notification; t: TFunction }) => string
|
|
108
|
+
> = {
|
|
109
|
+
'api:attachment:upload:failed': translateAttachmentUploadFailed,
|
|
110
|
+
'api:location:create:failed': ({ t }) => t('Failed to share location'),
|
|
111
|
+
'api:location:share:failed': ({ t }) => t('Failed to share location'),
|
|
112
|
+
'api:poll:create:failed': translatePollCreateFailed,
|
|
113
|
+
'api:poll:end:failed': translatePollEndFailed,
|
|
114
|
+
'api:poll:end:success': ({ t }) => t('Poll ended'),
|
|
115
|
+
'api:reply:search:failed': ({ t }) => t('Thread has not been found'),
|
|
116
|
+
'browser:audio:playback:error': ({ notification, t }) =>
|
|
117
|
+
notification.message ? t(notification.message) : t('Error reproducing the recording'),
|
|
118
|
+
'browser:location:get:failed': ({ t }) => t('Failed to retrieve location'),
|
|
119
|
+
'channel:jumpToFirstUnread:failed': ({ t }) => t('Failed to jump to the first unread message'),
|
|
120
|
+
'validation:attachment:file:missing': ({ t }) => t('File is required for upload attachment'),
|
|
121
|
+
'validation:attachment:id:missing': ({ t }) => t('Local upload attachment missing local id'),
|
|
122
|
+
'validation:attachment:upload:blocked': translateAttachmentUploadBlocked,
|
|
123
|
+
'validation:attachment:upload:in-progress': ({ t }) =>
|
|
124
|
+
t('Wait until all attachments have uploaded'),
|
|
125
|
+
'validation:command:disabled': translateCommandDisabled,
|
|
126
|
+
'validation:poll:castVote:limit': ({ t }) =>
|
|
127
|
+
t('Reached the vote limit. Remove an existing vote first.'),
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export const getNotificationDisplayMessage = ({
|
|
131
|
+
notification,
|
|
132
|
+
t,
|
|
133
|
+
}: {
|
|
134
|
+
notification: Notification;
|
|
135
|
+
t: TFunction;
|
|
136
|
+
}) => {
|
|
137
|
+
const translator = notification.type
|
|
138
|
+
? notificationTranslatorsByType[notification.type]
|
|
139
|
+
: undefined;
|
|
140
|
+
|
|
141
|
+
return translator ? translator({ notification, t }) : t(notification.message);
|
|
142
|
+
};
|
|
@@ -51,6 +51,7 @@ export const CreatePollHeader = ({
|
|
|
51
51
|
return (
|
|
52
52
|
<View style={[styles.headerContainer, headerContainer]}>
|
|
53
53
|
<Button
|
|
54
|
+
accessibilityLabelKey='a11y/Close poll creation'
|
|
54
55
|
variant='secondary'
|
|
55
56
|
onPress={onBackPressHandler}
|
|
56
57
|
type='solid'
|
|
@@ -63,6 +64,7 @@ export const CreatePollHeader = ({
|
|
|
63
64
|
</Text>
|
|
64
65
|
|
|
65
66
|
<Button
|
|
67
|
+
accessibilityLabelKey='a11y/Create poll'
|
|
66
68
|
variant='primary'
|
|
67
69
|
onPress={onCreatePollPressHandler}
|
|
68
70
|
type='solid'
|
|
@@ -163,6 +163,7 @@ export const MultipleVotesSettings = () => {
|
|
|
163
163
|
style={[styles.row, multipleAnswers.row]}
|
|
164
164
|
>
|
|
165
165
|
<Button
|
|
166
|
+
accessibilityLabelKey='a11y/Decrease maximum votes'
|
|
166
167
|
variant='secondary'
|
|
167
168
|
type='outline'
|
|
168
169
|
size='md'
|
|
@@ -175,6 +176,7 @@ export const MultipleVotesSettings = () => {
|
|
|
175
176
|
/>
|
|
176
177
|
<MaxVotesTextInput />
|
|
177
178
|
<Button
|
|
179
|
+
accessibilityLabelKey='a11y/Increase maximum votes'
|
|
178
180
|
variant='secondary'
|
|
179
181
|
type='outline'
|
|
180
182
|
size='md'
|
|
@@ -25,6 +25,7 @@ export const PollModalHeader = ({ onPress, title }: PollModalHeaderProps) => {
|
|
|
25
25
|
<View style={[styles.container, container]}>
|
|
26
26
|
<View style={styles.sideContainer}>
|
|
27
27
|
<Button
|
|
28
|
+
accessibilityLabelKey='a11y/Close poll'
|
|
28
29
|
variant='secondary'
|
|
29
30
|
type='solid'
|
|
30
31
|
size='md'
|
|
@@ -20,6 +20,7 @@ import { useComponentsContext } from '../../../contexts/componentsContext/Compon
|
|
|
20
20
|
|
|
21
21
|
import { Check } from '../../../icons';
|
|
22
22
|
import { primitives } from '../../../theme';
|
|
23
|
+
import { useNotificationApi } from '../../Notifications';
|
|
23
24
|
import { ProgressBar } from '../../ProgressControl/ProgressBar';
|
|
24
25
|
import { UserAvatarStack } from '../../ui/Avatar/AvatarStack';
|
|
25
26
|
import { useIsPollCreatedByCurrentUser } from '../hook/useIsPollCreatedByCurrentUser';
|
|
@@ -160,6 +161,7 @@ export const PollOption = ({ option, showProgressBar = true, forceIncoming }: Po
|
|
|
160
161
|
export const VoteButton = ({ onPress, option }: PollVoteButtonProps) => {
|
|
161
162
|
const { message, poll } = usePollContext();
|
|
162
163
|
const { isClosed, ownVotesByOptionId } = usePollState();
|
|
164
|
+
const { runWithNotificationTarget } = useNotificationApi();
|
|
163
165
|
const ownCapabilities = useOwnCapabilitiesContext();
|
|
164
166
|
const {
|
|
165
167
|
theme: { semantics },
|
|
@@ -178,12 +180,14 @@ export const VoteButton = ({ onPress, option }: PollVoteButtonProps) => {
|
|
|
178
180
|
} = useTheme();
|
|
179
181
|
|
|
180
182
|
const toggleVote = useCallback(async () => {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
183
|
+
await runWithNotificationTarget(async () => {
|
|
184
|
+
if (ownVotesByOptionId[option.id]) {
|
|
185
|
+
await poll.removeVote(ownVotesByOptionId[option.id]?.id, message.id);
|
|
186
|
+
} else {
|
|
187
|
+
await poll.castVote(option.id, message.id);
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
}, [message.id, option.id, ownVotesByOptionId, poll, runWithNotificationTarget]);
|
|
187
191
|
|
|
188
192
|
const onPressHandler = useCallback(() => {
|
|
189
193
|
if (onPress) {
|