stream-chat-react-native-core 9.4.0-beta.1 → 9.4.0-beta.10
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/lib/commonjs/components/Attachment/Attachment.js +10 -5
- package/lib/commonjs/components/Attachment/Attachment.js.map +1 -1
- package/lib/commonjs/components/Attachment/Audio/AudioAttachment.js +2 -4
- package/lib/commonjs/components/Attachment/Audio/AudioAttachment.js.map +1 -1
- package/lib/commonjs/components/ChannelDetails/hooks/useChannelDetailsActionItems.js +2 -1
- package/lib/commonjs/components/ChannelDetails/hooks/useChannelDetailsActionItems.js.map +1 -1
- package/lib/commonjs/components/ChannelList/ChannelList.js +4 -1
- package/lib/commonjs/components/ChannelList/ChannelList.js.map +1 -1
- package/lib/commonjs/components/ChannelList/hooks/useCreateChannelsContext.js +5 -3
- package/lib/commonjs/components/ChannelList/hooks/useCreateChannelsContext.js.map +1 -1
- package/lib/commonjs/components/ChannelPreview/ChannelMessagePreviewDeliveryStatus.js +5 -3
- package/lib/commonjs/components/ChannelPreview/ChannelMessagePreviewDeliveryStatus.js.map +1 -1
- package/lib/commonjs/components/ChannelPreview/ChannelPreview.js +3 -0
- package/lib/commonjs/components/ChannelPreview/ChannelPreview.js.map +1 -1
- package/lib/commonjs/components/ChannelPreview/ChannelPreviewPinnedStatus.js +30 -0
- package/lib/commonjs/components/ChannelPreview/ChannelPreviewPinnedStatus.js.map +1 -0
- package/lib/commonjs/components/ChannelPreview/ChannelPreviewView.js +8 -3
- package/lib/commonjs/components/ChannelPreview/ChannelPreviewView.js.map +1 -1
- package/lib/commonjs/components/ChannelPreview/ChannelSwipableWrapper.js +2 -1
- package/lib/commonjs/components/ChannelPreview/ChannelSwipableWrapper.js.map +1 -1
- package/lib/commonjs/components/ChannelPreview/hooks/index.js +11 -0
- package/lib/commonjs/components/ChannelPreview/hooks/index.js.map +1 -1
- package/lib/commonjs/components/ChannelPreview/hooks/useChannelPreviewData.js +3 -0
- package/lib/commonjs/components/ChannelPreview/hooks/useChannelPreviewData.js.map +1 -1
- package/lib/commonjs/components/ChannelPreview/hooks/useIsChannelPinned.js +11 -0
- package/lib/commonjs/components/ChannelPreview/hooks/useIsChannelPinned.js.map +1 -0
- package/lib/commonjs/components/Message/Message.js +53 -16
- package/lib/commonjs/components/Message/Message.js.map +1 -1
- package/lib/commonjs/components/Message/MessageItemView/MessageItemView.js +6 -84
- package/lib/commonjs/components/Message/MessageItemView/MessageItemView.js.map +1 -1
- package/lib/commonjs/components/MessageInput/MessageComposer.js +8 -29
- package/lib/commonjs/components/MessageInput/MessageComposer.js.map +1 -1
- package/lib/commonjs/components/MessageMenu/MessageActionList.js +1 -1
- package/lib/commonjs/components/Poll/components/CreatePollHeader.js +5 -5
- package/lib/commonjs/components/Poll/components/CreatePollHeader.js.map +1 -1
- package/lib/commonjs/components/Poll/components/PollButtons.js +25 -56
- package/lib/commonjs/components/Poll/components/PollButtons.js.map +1 -1
- package/lib/commonjs/components/Poll/components/PollInputDialog.js +9 -11
- package/lib/commonjs/components/Poll/components/PollInputDialog.js.map +1 -1
- package/lib/commonjs/components/Poll/components/PollModal.js +50 -0
- package/lib/commonjs/components/Poll/components/PollModal.js.map +1 -0
- package/lib/commonjs/components/Poll/components/PollModalHeader.js +4 -5
- package/lib/commonjs/components/Poll/components/PollModalHeader.js.map +1 -1
- package/lib/commonjs/components/Poll/components/PollResults/PollResultItem.js +10 -24
- package/lib/commonjs/components/Poll/components/PollResults/PollResultItem.js.map +1 -1
- package/lib/commonjs/components/Poll/components/index.js +11 -0
- package/lib/commonjs/components/Poll/components/index.js.map +1 -1
- package/lib/commonjs/components/index.js +11 -0
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/contexts/channelsContext/ChannelsContext.js.map +1 -1
- package/lib/commonjs/contexts/componentsContext/defaultComponents.js +2 -0
- package/lib/commonjs/contexts/componentsContext/defaultComponents.js.map +1 -1
- package/lib/commonjs/contexts/messageInputContext/hooks/useCreateMessageComposer.js +2 -2
- package/lib/commonjs/contexts/messageInputContext/hooks/useCreateMessageComposer.js.map +1 -1
- package/lib/commonjs/contexts/themeContext/utils/theme.js +3 -1
- package/lib/commonjs/contexts/themeContext/utils/theme.js.map +1 -1
- package/lib/commonjs/hooks/actions/useChannelActionItems.js +20 -1
- package/lib/commonjs/hooks/actions/useChannelActionItems.js.map +1 -1
- package/lib/commonjs/hooks/actions/useChannelActionItemsById.js +3 -1
- package/lib/commonjs/hooks/actions/useChannelActionItemsById.js.map +1 -1
- package/lib/commonjs/i18n/ar.json +6 -1
- package/lib/commonjs/i18n/en.json +5 -0
- package/lib/commonjs/i18n/es.json +6 -1
- package/lib/commonjs/i18n/fr.json +6 -1
- package/lib/commonjs/i18n/he.json +6 -1
- package/lib/commonjs/i18n/hi.json +6 -1
- package/lib/commonjs/i18n/it.json +6 -1
- package/lib/commonjs/i18n/ja.json +6 -1
- package/lib/commonjs/i18n/ko.json +6 -1
- package/lib/commonjs/i18n/nl.json +6 -1
- package/lib/commonjs/i18n/pt-br.json +6 -1
- package/lib/commonjs/i18n/ru.json +6 -1
- package/lib/commonjs/i18n/tr.json +6 -1
- package/lib/commonjs/icons/index.js +12 -0
- package/lib/commonjs/icons/index.js.map +1 -1
- package/lib/commonjs/version.json +1 -1
- package/lib/module/components/Attachment/Attachment.js +10 -5
- package/lib/module/components/Attachment/Attachment.js.map +1 -1
- package/lib/module/components/Attachment/Audio/AudioAttachment.js +2 -4
- package/lib/module/components/Attachment/Audio/AudioAttachment.js.map +1 -1
- package/lib/module/components/ChannelDetails/hooks/useChannelDetailsActionItems.js +2 -1
- package/lib/module/components/ChannelDetails/hooks/useChannelDetailsActionItems.js.map +1 -1
- package/lib/module/components/ChannelList/ChannelList.js +4 -1
- package/lib/module/components/ChannelList/ChannelList.js.map +1 -1
- package/lib/module/components/ChannelList/hooks/useCreateChannelsContext.js +5 -3
- package/lib/module/components/ChannelList/hooks/useCreateChannelsContext.js.map +1 -1
- package/lib/module/components/ChannelPreview/ChannelMessagePreviewDeliveryStatus.js +5 -3
- package/lib/module/components/ChannelPreview/ChannelMessagePreviewDeliveryStatus.js.map +1 -1
- package/lib/module/components/ChannelPreview/ChannelPreview.js +3 -0
- package/lib/module/components/ChannelPreview/ChannelPreview.js.map +1 -1
- package/lib/module/components/ChannelPreview/ChannelPreviewPinnedStatus.js +30 -0
- package/lib/module/components/ChannelPreview/ChannelPreviewPinnedStatus.js.map +1 -0
- package/lib/module/components/ChannelPreview/ChannelPreviewView.js +8 -3
- package/lib/module/components/ChannelPreview/ChannelPreviewView.js.map +1 -1
- package/lib/module/components/ChannelPreview/ChannelSwipableWrapper.js +2 -1
- package/lib/module/components/ChannelPreview/ChannelSwipableWrapper.js.map +1 -1
- package/lib/module/components/ChannelPreview/hooks/index.js +11 -0
- package/lib/module/components/ChannelPreview/hooks/index.js.map +1 -1
- package/lib/module/components/ChannelPreview/hooks/useChannelPreviewData.js +3 -0
- package/lib/module/components/ChannelPreview/hooks/useChannelPreviewData.js.map +1 -1
- package/lib/module/components/ChannelPreview/hooks/useIsChannelPinned.js +11 -0
- package/lib/module/components/ChannelPreview/hooks/useIsChannelPinned.js.map +1 -0
- package/lib/module/components/Message/Message.js +53 -16
- package/lib/module/components/Message/Message.js.map +1 -1
- package/lib/module/components/Message/MessageItemView/MessageItemView.js +6 -84
- package/lib/module/components/Message/MessageItemView/MessageItemView.js.map +1 -1
- package/lib/module/components/MessageInput/MessageComposer.js +8 -29
- package/lib/module/components/MessageInput/MessageComposer.js.map +1 -1
- package/lib/module/components/MessageMenu/MessageActionList.js +1 -1
- package/lib/module/components/Poll/components/CreatePollHeader.js +5 -5
- package/lib/module/components/Poll/components/CreatePollHeader.js.map +1 -1
- package/lib/module/components/Poll/components/PollButtons.js +25 -56
- package/lib/module/components/Poll/components/PollButtons.js.map +1 -1
- package/lib/module/components/Poll/components/PollInputDialog.js +9 -11
- package/lib/module/components/Poll/components/PollInputDialog.js.map +1 -1
- package/lib/module/components/Poll/components/PollModal.js +50 -0
- package/lib/module/components/Poll/components/PollModal.js.map +1 -0
- package/lib/module/components/Poll/components/PollModalHeader.js +4 -5
- package/lib/module/components/Poll/components/PollModalHeader.js.map +1 -1
- package/lib/module/components/Poll/components/PollResults/PollResultItem.js +10 -24
- package/lib/module/components/Poll/components/PollResults/PollResultItem.js.map +1 -1
- package/lib/module/components/Poll/components/index.js +11 -0
- package/lib/module/components/Poll/components/index.js.map +1 -1
- package/lib/module/components/index.js +11 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/contexts/channelsContext/ChannelsContext.js.map +1 -1
- package/lib/module/contexts/componentsContext/defaultComponents.js +2 -0
- package/lib/module/contexts/componentsContext/defaultComponents.js.map +1 -1
- package/lib/module/contexts/messageInputContext/hooks/useCreateMessageComposer.js +2 -2
- package/lib/module/contexts/messageInputContext/hooks/useCreateMessageComposer.js.map +1 -1
- package/lib/module/contexts/themeContext/utils/theme.js +3 -1
- package/lib/module/contexts/themeContext/utils/theme.js.map +1 -1
- package/lib/module/hooks/actions/useChannelActionItems.js +20 -1
- package/lib/module/hooks/actions/useChannelActionItems.js.map +1 -1
- package/lib/module/hooks/actions/useChannelActionItemsById.js +3 -1
- package/lib/module/hooks/actions/useChannelActionItemsById.js.map +1 -1
- package/lib/module/i18n/ar.json +6 -1
- package/lib/module/i18n/en.json +5 -0
- package/lib/module/i18n/es.json +6 -1
- package/lib/module/i18n/fr.json +6 -1
- package/lib/module/i18n/he.json +6 -1
- package/lib/module/i18n/hi.json +6 -1
- package/lib/module/i18n/it.json +6 -1
- package/lib/module/i18n/ja.json +6 -1
- package/lib/module/i18n/ko.json +6 -1
- package/lib/module/i18n/nl.json +6 -1
- package/lib/module/i18n/pt-br.json +6 -1
- package/lib/module/i18n/ru.json +6 -1
- package/lib/module/i18n/tr.json +6 -1
- package/lib/module/icons/index.js +12 -0
- package/lib/module/icons/index.js.map +1 -1
- package/lib/module/version.json +1 -1
- package/lib/typescript/components/Attachment/Audio/AudioAttachment.d.ts +1 -0
- package/lib/typescript/components/Attachment/Audio/AudioAttachment.d.ts.map +1 -1
- package/lib/typescript/components/ChannelList/ChannelList.d.ts +1 -1
- package/lib/typescript/components/ChannelList/ChannelList.d.ts.map +1 -1
- package/lib/typescript/components/ChannelList/hooks/useCreateChannelsContext.d.ts +1 -1
- package/lib/typescript/components/ChannelList/hooks/useCreateChannelsContext.d.ts.map +1 -1
- package/lib/typescript/components/ChannelPreview/ChannelPreview.d.ts.map +1 -1
- package/lib/typescript/components/ChannelPreview/ChannelPreviewPinnedStatus.d.ts +6 -0
- package/lib/typescript/components/ChannelPreview/ChannelPreviewPinnedStatus.d.ts.map +1 -0
- package/lib/typescript/components/ChannelPreview/ChannelPreviewView.d.ts +3 -1
- package/lib/typescript/components/ChannelPreview/ChannelPreviewView.d.ts.map +1 -1
- package/lib/typescript/components/ChannelPreview/ChannelSwipableWrapper.d.ts.map +1 -1
- package/lib/typescript/components/ChannelPreview/hooks/index.d.ts +1 -0
- package/lib/typescript/components/ChannelPreview/hooks/index.d.ts.map +1 -1
- package/lib/typescript/components/ChannelPreview/hooks/useChannelPreviewData.d.ts +1 -0
- package/lib/typescript/components/ChannelPreview/hooks/useChannelPreviewData.d.ts.map +1 -1
- package/lib/typescript/components/ChannelPreview/hooks/useIsChannelPinned.d.ts +3 -0
- package/lib/typescript/components/ChannelPreview/hooks/useIsChannelPinned.d.ts.map +1 -0
- package/lib/typescript/components/Message/Message.d.ts.map +1 -1
- package/lib/typescript/components/Message/MessageItemView/MessageItemView.d.ts.map +1 -1
- package/lib/typescript/components/MessageInput/MessageComposer.d.ts.map +1 -1
- package/lib/typescript/components/Poll/components/CreatePollHeader.d.ts.map +1 -1
- package/lib/typescript/components/Poll/components/PollButtons.d.ts.map +1 -1
- package/lib/typescript/components/Poll/components/PollModal.d.ts +9 -0
- package/lib/typescript/components/Poll/components/PollModal.d.ts.map +1 -0
- package/lib/typescript/components/Poll/components/PollResults/PollResultItem.d.ts.map +1 -1
- package/lib/typescript/components/Poll/components/index.d.ts +1 -0
- package/lib/typescript/components/Poll/components/index.d.ts.map +1 -1
- package/lib/typescript/components/index.d.ts +1 -0
- package/lib/typescript/components/index.d.ts.map +1 -1
- package/lib/typescript/contexts/channelsContext/ChannelsContext.d.ts +1 -0
- package/lib/typescript/contexts/channelsContext/ChannelsContext.d.ts.map +1 -1
- package/lib/typescript/contexts/componentsContext/defaultComponents.d.ts +1 -0
- package/lib/typescript/contexts/componentsContext/defaultComponents.d.ts.map +1 -1
- package/lib/typescript/contexts/messageInputContext/hooks/useCreateMessageComposer.d.ts.map +1 -1
- package/lib/typescript/contexts/themeContext/ThemeContext.d.ts +2 -0
- package/lib/typescript/contexts/themeContext/ThemeContext.d.ts.map +1 -1
- package/lib/typescript/contexts/themeContext/utils/theme.d.ts +2 -0
- package/lib/typescript/contexts/themeContext/utils/theme.d.ts.map +1 -1
- package/lib/typescript/hooks/actions/useChannelActionItems.d.ts +35 -2
- package/lib/typescript/hooks/actions/useChannelActionItems.d.ts.map +1 -1
- package/lib/typescript/hooks/actions/useChannelActionItemsById.d.ts +3 -2
- package/lib/typescript/hooks/actions/useChannelActionItemsById.d.ts.map +1 -1
- package/lib/typescript/i18n/ar.json +6 -1
- package/lib/typescript/i18n/en.json +5 -0
- package/lib/typescript/i18n/es.json +6 -1
- package/lib/typescript/i18n/fr.json +6 -1
- package/lib/typescript/i18n/he.json +6 -1
- package/lib/typescript/i18n/hi.json +6 -1
- package/lib/typescript/i18n/it.json +6 -1
- package/lib/typescript/i18n/ja.json +6 -1
- package/lib/typescript/i18n/ko.json +6 -1
- package/lib/typescript/i18n/nl.json +6 -1
- package/lib/typescript/i18n/pt-br.json +6 -1
- package/lib/typescript/i18n/ru.json +6 -1
- package/lib/typescript/i18n/tr.json +6 -1
- package/lib/typescript/icons/index.d.ts +1 -0
- package/lib/typescript/icons/index.d.ts.map +1 -1
- package/lib/typescript/utils/i18n/Streami18n.d.ts +5 -0
- package/lib/typescript/utils/i18n/Streami18n.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/components/Attachment/Attachment.tsx +15 -6
- package/src/components/Attachment/Audio/AudioAttachment.tsx +3 -4
- package/src/components/ChannelDetails/__tests__/useChannelDetailsActionItems.test.tsx +6 -2
- package/src/components/ChannelDetails/hooks/useChannelDetailsActionItems.ts +1 -1
- package/src/components/ChannelList/ChannelList.tsx +3 -0
- package/src/components/ChannelList/hooks/useCreateChannelsContext.ts +3 -0
- package/src/components/ChannelPreview/ChannelMessagePreviewDeliveryStatus.tsx +3 -2
- package/src/components/ChannelPreview/ChannelPreview.tsx +21 -3
- package/src/components/ChannelPreview/ChannelPreviewPinnedStatus.tsx +25 -0
- package/src/components/ChannelPreview/ChannelPreviewView.tsx +18 -2
- package/src/components/ChannelPreview/ChannelSwipableWrapper.tsx +5 -1
- package/src/components/ChannelPreview/hooks/__tests__/useIsChannelPinned.test.tsx +35 -0
- package/src/components/ChannelPreview/hooks/index.ts +1 -0
- package/src/components/ChannelPreview/hooks/useChannelPreviewData.ts +3 -1
- package/src/components/ChannelPreview/hooks/useIsChannelPinned.ts +8 -0
- package/src/components/Message/Message.tsx +68 -22
- package/src/components/Message/MessageItemView/MessageItemView.tsx +5 -116
- package/src/components/Message/MessageItemView/__tests__/MessageItemView.test.tsx +22 -13
- package/src/components/MessageInput/MessageComposer.tsx +9 -30
- package/src/components/MessageMenu/MessageActionList.tsx +1 -1
- package/src/components/Poll/components/CreatePollHeader.tsx +12 -5
- package/src/components/Poll/components/PollButtons.tsx +14 -38
- package/src/components/Poll/components/PollInputDialog.tsx +12 -12
- package/src/components/Poll/components/PollModal.tsx +55 -0
- package/src/components/Poll/components/PollModalHeader.tsx +4 -5
- package/src/components/Poll/components/PollResults/PollResultItem.tsx +6 -18
- package/src/components/Poll/components/__tests__/CreatePollHeader.test.tsx +4 -36
- package/src/components/Poll/components/__tests__/PollModalHeader.test.tsx +8 -45
- package/src/components/Poll/components/index.ts +1 -0
- package/src/components/Thread/__tests__/__snapshots__/Thread.test.tsx.snap +5 -5
- package/src/components/index.ts +1 -0
- package/src/contexts/channelsContext/ChannelsContext.tsx +1 -0
- package/src/contexts/componentsContext/defaultComponents.ts +2 -0
- package/src/contexts/messageInputContext/hooks/useCreateMessageComposer.ts +10 -4
- package/src/contexts/themeContext/utils/theme.ts +4 -0
- package/src/hooks/actions/__tests__/useChannelActionItems.test.tsx +137 -14
- package/src/hooks/actions/__tests__/useChannelActionItemsById.test.tsx +3 -1
- package/src/hooks/actions/useChannelActionItems.tsx +60 -2
- package/src/hooks/actions/useChannelActionItemsById.ts +8 -1
- package/src/i18n/ar.json +6 -1
- package/src/i18n/en.json +5 -0
- package/src/i18n/es.json +6 -1
- package/src/i18n/fr.json +6 -1
- package/src/i18n/he.json +6 -1
- package/src/i18n/hi.json +6 -1
- package/src/i18n/it.json +6 -1
- package/src/i18n/ja.json +6 -1
- package/src/i18n/ko.json +6 -1
- package/src/i18n/nl.json +6 -1
- package/src/i18n/pt-br.json +6 -1
- package/src/i18n/ru.json +6 -1
- package/src/i18n/tr.json +6 -1
- package/src/icons/index.ts +1 -0
- package/src/version.json +1 -1
|
@@ -78,6 +78,7 @@ export type AudioAttachmentProps = {
|
|
|
78
78
|
playPauseButton?: StyleProp<ViewStyle>;
|
|
79
79
|
speedSettingsButton?: StyleProp<ViewStyle>;
|
|
80
80
|
durationText?: StyleProp<TextStyle>;
|
|
81
|
+
leftContainer?: StyleProp<TextStyle>;
|
|
81
82
|
};
|
|
82
83
|
};
|
|
83
84
|
|
|
@@ -215,7 +216,7 @@ export const AudioAttachment = (props: AudioAttachmentProps) => {
|
|
|
215
216
|
style={[styles.container, container, containerStyle, stylesProps?.container]}
|
|
216
217
|
testID={testID}
|
|
217
218
|
>
|
|
218
|
-
<View style={[styles.leftContainer, leftContainer]}>
|
|
219
|
+
<View style={[styles.leftContainer, stylesProps?.leftContainer, leftContainer]}>
|
|
219
220
|
<PlayPauseButton
|
|
220
221
|
isPlaying={isPlaying}
|
|
221
222
|
accessibilityLabel='Play Pause Button'
|
|
@@ -341,9 +342,7 @@ const useStyles = () => {
|
|
|
341
342
|
fontWeight: primitives.typographyFontWeightSemiBold,
|
|
342
343
|
lineHeight: primitives.typographyLineHeightTight,
|
|
343
344
|
},
|
|
344
|
-
leftContainer: {
|
|
345
|
-
padding: primitives.spacingXxs,
|
|
346
|
-
},
|
|
345
|
+
leftContainer: {},
|
|
347
346
|
progressControlContainer: {
|
|
348
347
|
flex: 1,
|
|
349
348
|
},
|
|
@@ -51,7 +51,11 @@ describe('useChannelDetailsActionItems', () => {
|
|
|
51
51
|
renderHook(() => useChannelDetailsActionItems());
|
|
52
52
|
|
|
53
53
|
expect(spy).toHaveBeenCalledTimes(1);
|
|
54
|
-
expect(spy).toHaveBeenCalledWith({
|
|
54
|
+
expect(spy).toHaveBeenCalledWith({
|
|
55
|
+
channel,
|
|
56
|
+
getChannelActionItems: undefined,
|
|
57
|
+
surface: 'details',
|
|
58
|
+
});
|
|
55
59
|
});
|
|
56
60
|
|
|
57
61
|
it('forwards the getChannelActionItems prop from context unchanged', () => {
|
|
@@ -61,7 +65,7 @@ describe('useChannelDetailsActionItems', () => {
|
|
|
61
65
|
|
|
62
66
|
renderHook(() => useChannelDetailsActionItems());
|
|
63
67
|
|
|
64
|
-
expect(spy).toHaveBeenCalledWith({ channel, getChannelActionItems });
|
|
68
|
+
expect(spy).toHaveBeenCalledWith({ channel, getChannelActionItems, surface: 'details' });
|
|
65
69
|
});
|
|
66
70
|
|
|
67
71
|
it('returns non-leave/non-delete items referentially unchanged', () => {
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
export const useChannelDetailsActionItems = (): ChannelActionItem[] => {
|
|
13
13
|
const { channel, getChannelActionItems, onChannelDismiss } = useChannelDetailsContext();
|
|
14
14
|
|
|
15
|
-
const items = useChannelActionItems({ channel, getChannelActionItems });
|
|
15
|
+
const items = useChannelActionItems({ channel, getChannelActionItems, surface: 'details' });
|
|
16
16
|
|
|
17
17
|
return useMemo(
|
|
18
18
|
() =>
|
|
@@ -41,6 +41,7 @@ export type ChannelListProps = Partial<
|
|
|
41
41
|
| 'maxUnreadCount'
|
|
42
42
|
| 'numberOfSkeletons'
|
|
43
43
|
| 'mutedStatusPosition'
|
|
44
|
+
| 'pinnedStatusPosition'
|
|
44
45
|
>
|
|
45
46
|
> & {
|
|
46
47
|
/** Optional function to filter channels prior to rendering the list. Do not use any complex logic that would delay the loading of the ChannelList. We recommend using a pure function with array methods like filter/sort/reduce. */
|
|
@@ -252,6 +253,7 @@ export const ChannelList = (props: ChannelListProps) => {
|
|
|
252
253
|
queryChannelsOverride,
|
|
253
254
|
notificationHostId: notificationHostIdProp,
|
|
254
255
|
mutedStatusPosition = 'inlineTitle',
|
|
256
|
+
pinnedStatusPosition = 'inlineTitle',
|
|
255
257
|
swipeActionsEnabled = true,
|
|
256
258
|
} = props;
|
|
257
259
|
|
|
@@ -375,6 +377,7 @@ export const ChannelList = (props: ChannelListProps) => {
|
|
|
375
377
|
}
|
|
376
378
|
},
|
|
377
379
|
mutedStatusPosition,
|
|
380
|
+
pinnedStatusPosition,
|
|
378
381
|
});
|
|
379
382
|
|
|
380
383
|
return (
|
|
@@ -23,6 +23,7 @@ export const useCreateChannelsContext = ({
|
|
|
23
23
|
reloadList,
|
|
24
24
|
setFlatListRef,
|
|
25
25
|
mutedStatusPosition,
|
|
26
|
+
pinnedStatusPosition,
|
|
26
27
|
}: ChannelsContextValue) => {
|
|
27
28
|
const channelValueString = channels
|
|
28
29
|
?.map(
|
|
@@ -56,6 +57,7 @@ export const useCreateChannelsContext = ({
|
|
|
56
57
|
reloadList,
|
|
57
58
|
setFlatListRef,
|
|
58
59
|
mutedStatusPosition,
|
|
60
|
+
pinnedStatusPosition,
|
|
59
61
|
}),
|
|
60
62
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
61
63
|
[
|
|
@@ -69,6 +71,7 @@ export const useCreateChannelsContext = ({
|
|
|
69
71
|
swipeActionsEnabled,
|
|
70
72
|
refreshing,
|
|
71
73
|
mutedStatusPosition,
|
|
74
|
+
pinnedStatusPosition,
|
|
72
75
|
],
|
|
73
76
|
);
|
|
74
77
|
|
|
@@ -107,7 +107,7 @@ const useStyles = () => {
|
|
|
107
107
|
theme: {
|
|
108
108
|
semantics,
|
|
109
109
|
channelPreview: {
|
|
110
|
-
messageDeliveryStatus: { container, text },
|
|
110
|
+
messageDeliveryStatus: { container, text, username },
|
|
111
111
|
},
|
|
112
112
|
},
|
|
113
113
|
} = useTheme();
|
|
@@ -132,7 +132,8 @@ const useStyles = () => {
|
|
|
132
132
|
fontSize: primitives.typographyFontSizeSm,
|
|
133
133
|
fontWeight: primitives.typographyFontWeightSemiBold,
|
|
134
134
|
lineHeight: primitives.typographyLineHeightNormal,
|
|
135
|
+
...username,
|
|
135
136
|
},
|
|
136
137
|
});
|
|
137
|
-
}, [semantics, text, container]);
|
|
138
|
+
}, [semantics, text, username, container]);
|
|
138
139
|
};
|
|
@@ -30,19 +30,37 @@ export const ChannelPreview = (props: ChannelPreviewProps) => {
|
|
|
30
30
|
|
|
31
31
|
const client = propClient || contextClient;
|
|
32
32
|
|
|
33
|
-
const { muted, unread, lastMessage } = useChannelPreviewData(
|
|
33
|
+
const { muted, pinned, unread, lastMessage } = useChannelPreviewData(
|
|
34
|
+
channel,
|
|
35
|
+
client,
|
|
36
|
+
propForceUpdate,
|
|
37
|
+
);
|
|
34
38
|
|
|
35
39
|
const translatedLastMessage = useTranslatedMessage(lastMessage);
|
|
36
40
|
|
|
37
41
|
const message = translatedLastMessage ? translatedLastMessage : lastMessage;
|
|
38
42
|
|
|
39
43
|
if (!swipeActionsEnabled) {
|
|
40
|
-
return
|
|
44
|
+
return (
|
|
45
|
+
<ChannelPreview
|
|
46
|
+
channel={channel}
|
|
47
|
+
muted={muted}
|
|
48
|
+
pinned={pinned}
|
|
49
|
+
unread={unread}
|
|
50
|
+
lastMessage={message}
|
|
51
|
+
/>
|
|
52
|
+
);
|
|
41
53
|
}
|
|
42
54
|
|
|
43
55
|
return (
|
|
44
56
|
<ChannelSwipableWrapper channel={channel} getChannelActionItems={getChannelActionItems}>
|
|
45
|
-
<ChannelPreview
|
|
57
|
+
<ChannelPreview
|
|
58
|
+
channel={channel}
|
|
59
|
+
muted={muted}
|
|
60
|
+
pinned={pinned}
|
|
61
|
+
unread={unread}
|
|
62
|
+
lastMessage={message}
|
|
63
|
+
/>
|
|
46
64
|
</ChannelSwipableWrapper>
|
|
47
65
|
);
|
|
48
66
|
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { useA11yLabel } from '../../a11y/hooks/useA11yLabel';
|
|
4
|
+
import { useTheme } from '../../contexts/themeContext/ThemeContext';
|
|
5
|
+
import { Pin } from '../../icons';
|
|
6
|
+
import { CompositeAccessibilityProbe } from '../Accessibility/CompositeAccessibilityProbe';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* This UI component displays a pinned indicator for a particular channel.
|
|
10
|
+
*/
|
|
11
|
+
export const ChannelPreviewPinnedStatus = () => {
|
|
12
|
+
const {
|
|
13
|
+
theme: {
|
|
14
|
+
channelPreview: { pinnedStatus },
|
|
15
|
+
semantics,
|
|
16
|
+
},
|
|
17
|
+
} = useTheme();
|
|
18
|
+
const accessibilityLabel = useA11yLabel('a11y/Pinned');
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<CompositeAccessibilityProbe label={accessibilityLabel}>
|
|
22
|
+
<Pin height={20} stroke={semantics.textTertiary} width={20} {...pinnedStatus} />
|
|
23
|
+
</CompositeAccessibilityProbe>
|
|
24
|
+
);
|
|
25
|
+
};
|
|
@@ -17,7 +17,10 @@ import { useStableCallback } from '../../hooks';
|
|
|
17
17
|
import { primitives } from '../../theme';
|
|
18
18
|
|
|
19
19
|
export type ChannelPreviewViewPropsWithContext = Pick<ChannelPreviewProps, 'channel'> &
|
|
20
|
-
Pick<
|
|
20
|
+
Pick<
|
|
21
|
+
ChannelsContextValue,
|
|
22
|
+
'maxUnreadCount' | 'onSelect' | 'mutedStatusPosition' | 'pinnedStatusPosition'
|
|
23
|
+
> & {
|
|
21
24
|
/**
|
|
22
25
|
* Formatter function for date of latest message.
|
|
23
26
|
* @param date Message date
|
|
@@ -30,6 +33,8 @@ export type ChannelPreviewViewPropsWithContext = Pick<ChannelPreviewProps, 'chan
|
|
|
30
33
|
formatLatestMessageDate?: (date: Date) => string;
|
|
31
34
|
/** If the channel is muted. */
|
|
32
35
|
muted?: boolean;
|
|
36
|
+
/** If the channel is pinned for the current user. */
|
|
37
|
+
pinned?: boolean;
|
|
33
38
|
/** Number of unread messages on the channel */
|
|
34
39
|
unread?: number;
|
|
35
40
|
lastMessage?: LastMessageType;
|
|
@@ -42,14 +47,17 @@ const ChannelPreviewViewWithContext = (props: ChannelPreviewViewPropsWithContext
|
|
|
42
47
|
maxUnreadCount,
|
|
43
48
|
muted,
|
|
44
49
|
onSelect,
|
|
50
|
+
pinned,
|
|
45
51
|
unread,
|
|
46
52
|
mutedStatusPosition,
|
|
53
|
+
pinnedStatusPosition,
|
|
47
54
|
lastMessage,
|
|
48
55
|
} = props;
|
|
49
56
|
const {
|
|
50
57
|
ChannelPreviewAvatar,
|
|
51
58
|
ChannelPreviewMessage,
|
|
52
59
|
ChannelPreviewMutedStatus,
|
|
60
|
+
ChannelPreviewPinnedStatus,
|
|
53
61
|
ChannelPreviewStatus,
|
|
54
62
|
ChannelPreviewTitle,
|
|
55
63
|
ChannelPreviewUnreadCount,
|
|
@@ -111,6 +119,9 @@ const ChannelPreviewViewWithContext = (props: ChannelPreviewViewPropsWithContext
|
|
|
111
119
|
{muted && mutedStatusPosition === 'inlineTitle' ? (
|
|
112
120
|
<ChannelPreviewMutedStatus />
|
|
113
121
|
) : null}
|
|
122
|
+
{pinned && pinnedStatusPosition === 'inlineTitle' ? (
|
|
123
|
+
<ChannelPreviewPinnedStatus />
|
|
124
|
+
) : null}
|
|
114
125
|
</View>
|
|
115
126
|
|
|
116
127
|
<View style={[styles.statusContainer, statusContainer]}>
|
|
@@ -132,6 +143,9 @@ const ChannelPreviewViewWithContext = (props: ChannelPreviewViewPropsWithContext
|
|
|
132
143
|
{muted && mutedStatusPosition === 'trailingBottom' ? (
|
|
133
144
|
<ChannelPreviewMutedStatus />
|
|
134
145
|
) : null}
|
|
146
|
+
{pinned && pinnedStatusPosition === 'trailingBottom' ? (
|
|
147
|
+
<ChannelPreviewPinnedStatus />
|
|
148
|
+
) : null}
|
|
135
149
|
</View>
|
|
136
150
|
</View>
|
|
137
151
|
</Pressable>
|
|
@@ -151,7 +165,8 @@ const MemoizedChannelPreviewViewWithContext = React.memo(
|
|
|
151
165
|
* from the ChannelPreview component.
|
|
152
166
|
*/
|
|
153
167
|
export const ChannelPreviewView = (props: ChannelPreviewViewProps) => {
|
|
154
|
-
const { forceUpdate, maxUnreadCount, onSelect, mutedStatusPosition } =
|
|
168
|
+
const { forceUpdate, maxUnreadCount, onSelect, mutedStatusPosition, pinnedStatusPosition } =
|
|
169
|
+
useChannelsContext();
|
|
155
170
|
return (
|
|
156
171
|
<MemoizedChannelPreviewViewWithContext
|
|
157
172
|
{...{
|
|
@@ -159,6 +174,7 @@ export const ChannelPreviewView = (props: ChannelPreviewViewProps) => {
|
|
|
159
174
|
maxUnreadCount,
|
|
160
175
|
onSelect,
|
|
161
176
|
mutedStatusPosition,
|
|
177
|
+
pinnedStatusPosition,
|
|
162
178
|
}}
|
|
163
179
|
{...props}
|
|
164
180
|
/>
|
|
@@ -41,7 +41,11 @@ export const ChannelSwipableWrapper = ({
|
|
|
41
41
|
}>) => {
|
|
42
42
|
const { ChannelDetailsBottomSheet: ChannelDetailsBottomSheetComponent } = useComponentsContext();
|
|
43
43
|
const [channelDetailSheetOpen, setChannelDetailSheetOpen] = useState(false);
|
|
44
|
-
const channelActionItems = useChannelActionItems({
|
|
44
|
+
const channelActionItems = useChannelActionItems({
|
|
45
|
+
channel,
|
|
46
|
+
getChannelActionItems,
|
|
47
|
+
surface: 'list',
|
|
48
|
+
});
|
|
45
49
|
const sheetItems = useMemo(
|
|
46
50
|
() => channelActionItems.filter((item) => item.placement !== 'swipe'),
|
|
47
51
|
[channelActionItems],
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { renderHook } from '@testing-library/react-native';
|
|
2
|
+
import { Channel } from 'stream-chat';
|
|
3
|
+
|
|
4
|
+
import { useIsChannelPinned } from '../useIsChannelPinned';
|
|
5
|
+
|
|
6
|
+
describe('useIsChannelPinned', () => {
|
|
7
|
+
afterEach(() => {
|
|
8
|
+
jest.clearAllMocks();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
const buildMockChannel = (membership: Record<string, unknown> = {}) =>
|
|
12
|
+
({
|
|
13
|
+
initialized: true,
|
|
14
|
+
on: jest.fn().mockReturnValue({ unsubscribe: jest.fn() }),
|
|
15
|
+
state: { membership },
|
|
16
|
+
}) as unknown as Channel;
|
|
17
|
+
|
|
18
|
+
it('returns false when membership has no pinned_at', () => {
|
|
19
|
+
const channel = buildMockChannel({ pinned_at: null });
|
|
20
|
+
const { result } = renderHook(() => useIsChannelPinned(channel));
|
|
21
|
+
expect(result.current).toBe(false);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('returns true when membership has a pinned_at timestamp', () => {
|
|
25
|
+
const channel = buildMockChannel({ pinned_at: '2026-06-15T08:00:00.000Z' });
|
|
26
|
+
const { result } = renderHook(() => useIsChannelPinned(channel));
|
|
27
|
+
expect(result.current).toBe(true);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('subscribes to member.updated events', () => {
|
|
31
|
+
const channel = buildMockChannel({ pinned_at: null });
|
|
32
|
+
renderHook(() => useIsChannelPinned(channel));
|
|
33
|
+
expect(channel.on).toHaveBeenCalledWith('member.updated', expect.any(Function));
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -4,6 +4,7 @@ import throttle from 'lodash/throttle';
|
|
|
4
4
|
import type { Channel, Event, LocalMessage, MessageResponse, StreamChat } from 'stream-chat';
|
|
5
5
|
|
|
6
6
|
import { useIsChannelMuted } from './useIsChannelMuted';
|
|
7
|
+
import { useIsChannelPinned } from './useIsChannelPinned';
|
|
7
8
|
|
|
8
9
|
import { useChannelsContext } from '../../../contexts';
|
|
9
10
|
import { useStableCallback } from '../../../hooks';
|
|
@@ -39,6 +40,7 @@ export const useChannelPreviewData = (
|
|
|
39
40
|
);
|
|
40
41
|
const [unread, setUnread] = useState(channel.countUnread());
|
|
41
42
|
const { muted } = useIsChannelMuted(channel);
|
|
43
|
+
const pinned = useIsChannelPinned(channel);
|
|
42
44
|
const { forceUpdate: contextForceUpdate } = useChannelsContext();
|
|
43
45
|
const channelListForceUpdate = forceUpdateOverride ?? contextForceUpdate;
|
|
44
46
|
|
|
@@ -170,5 +172,5 @@ export const useChannelPreviewData = (
|
|
|
170
172
|
return () => listeners.forEach((l) => l.unsubscribe());
|
|
171
173
|
}, [channel, refreshUnreadCount, forceUpdate, channelListForceUpdate, setLastMessage]);
|
|
172
174
|
|
|
173
|
-
return { lastMessage, muted, unread };
|
|
175
|
+
return { lastMessage, muted, pinned, unread };
|
|
174
176
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Channel } from 'stream-chat';
|
|
2
|
+
|
|
3
|
+
import { useChannelMembershipState } from '../../../hooks/useChannelMembershipState';
|
|
4
|
+
|
|
5
|
+
export const useIsChannelPinned = (channel: Channel) => {
|
|
6
|
+
const membership = useChannelMembershipState(channel);
|
|
7
|
+
return Boolean(membership?.pinned_at);
|
|
8
|
+
};
|
|
@@ -67,6 +67,7 @@ import {
|
|
|
67
67
|
setOverlayTopH,
|
|
68
68
|
useIsOverlayActive,
|
|
69
69
|
} from '../../state-store';
|
|
70
|
+
import { primitives } from '../../theme';
|
|
70
71
|
import { FileTypes } from '../../types/types';
|
|
71
72
|
import {
|
|
72
73
|
checkMessageEquality,
|
|
@@ -830,8 +831,20 @@ const MessageWithContext = (props: MessagePropsWithContext) => {
|
|
|
830
831
|
}
|
|
831
832
|
}, [overlayActive, message]);
|
|
832
833
|
|
|
834
|
+
const groupKey: 'single' | 'top' | 'middle' | 'bottom' | undefined =
|
|
835
|
+
groupStyles?.[0] === 'single' ||
|
|
836
|
+
groupStyles?.[0] === 'top' ||
|
|
837
|
+
groupStyles?.[0] === 'middle' ||
|
|
838
|
+
groupStyles?.[0] === 'bottom'
|
|
839
|
+
? groupStyles[0]
|
|
840
|
+
: undefined;
|
|
841
|
+
const isVeryLastBubble =
|
|
842
|
+
messagesContext.enableMessageGroupingByUser &&
|
|
843
|
+
channel?.state.messages[channel.state.messages.length - 1]?.id === message.id;
|
|
833
844
|
const styles = useStyles({
|
|
845
|
+
groupKey,
|
|
834
846
|
highlightedMessage: (isTargetedMessage || message.pinned) && !isMessageTypeDeleted,
|
|
847
|
+
isVeryLastBubble,
|
|
835
848
|
});
|
|
836
849
|
const rect = rectRef.current;
|
|
837
850
|
const overlayItemsAnchorRect = bubbleRect.current ?? rect;
|
|
@@ -1147,34 +1160,67 @@ export const Message = (props: MessageProps) => {
|
|
|
1147
1160
|
);
|
|
1148
1161
|
};
|
|
1149
1162
|
|
|
1150
|
-
const useStyles = ({
|
|
1163
|
+
const useStyles = ({
|
|
1164
|
+
groupKey,
|
|
1165
|
+
highlightedMessage,
|
|
1166
|
+
isVeryLastBubble,
|
|
1167
|
+
}: {
|
|
1168
|
+
groupKey: 'single' | 'top' | 'middle' | 'bottom' | undefined;
|
|
1169
|
+
highlightedMessage?: boolean;
|
|
1170
|
+
isVeryLastBubble: boolean;
|
|
1171
|
+
}) => {
|
|
1151
1172
|
const {
|
|
1152
|
-
theme: {
|
|
1153
|
-
messageItemView: { wrapper, targetedMessageContainer, blockedMessageContainer },
|
|
1154
|
-
screenPadding,
|
|
1155
|
-
semantics,
|
|
1156
|
-
},
|
|
1173
|
+
theme: { messageItemView, screenPadding, semantics },
|
|
1157
1174
|
} = useTheme();
|
|
1175
|
+
|
|
1158
1176
|
return useMemo(() => {
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
...
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1177
|
+
const groupStylesMap: Record<'single' | 'top' | 'middle' | 'bottom', ViewStyle> = {
|
|
1178
|
+
single: {
|
|
1179
|
+
paddingVertical: primitives.spacingXs,
|
|
1180
|
+
...messageItemView.messageGroupedSingleStyles,
|
|
1181
|
+
},
|
|
1182
|
+
top: {
|
|
1183
|
+
paddingTop: primitives.spacingXs,
|
|
1184
|
+
paddingBottom: primitives.spacingXxs,
|
|
1185
|
+
...messageItemView.messageGroupedTopStyles,
|
|
1186
|
+
},
|
|
1187
|
+
middle: {
|
|
1188
|
+
paddingBottom: primitives.spacingXxs,
|
|
1189
|
+
...messageItemView.messageGroupedMiddleStyles,
|
|
1190
|
+
},
|
|
1191
|
+
bottom: {
|
|
1192
|
+
paddingBottom: primitives.spacingXs,
|
|
1193
|
+
...messageItemView.messageGroupedBottomStyles,
|
|
1166
1194
|
},
|
|
1195
|
+
};
|
|
1196
|
+
|
|
1197
|
+
let wrapper: ViewStyle = {
|
|
1198
|
+
paddingHorizontal: screenPadding,
|
|
1199
|
+
...(highlightedMessage
|
|
1200
|
+
? {
|
|
1201
|
+
backgroundColor: semantics.backgroundCoreHighlight,
|
|
1202
|
+
...messageItemView.targetedMessageContainer,
|
|
1203
|
+
}
|
|
1204
|
+
: {}),
|
|
1205
|
+
...messageItemView.wrapper,
|
|
1206
|
+
};
|
|
1207
|
+
if (groupKey) {
|
|
1208
|
+
wrapper = { ...wrapper, ...groupStylesMap[groupKey] };
|
|
1209
|
+
}
|
|
1210
|
+
if (isVeryLastBubble) {
|
|
1211
|
+
wrapper = {
|
|
1212
|
+
...wrapper,
|
|
1213
|
+
marginBottom: primitives.spacingSm,
|
|
1214
|
+
...messageItemView.lastMessageContainer,
|
|
1215
|
+
};
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
return StyleSheet.create({
|
|
1219
|
+
wrapper,
|
|
1167
1220
|
blockedMessageContainer: {
|
|
1168
1221
|
alignItems: 'center',
|
|
1169
|
-
...blockedMessageContainer,
|
|
1222
|
+
...messageItemView.blockedMessageContainer,
|
|
1170
1223
|
},
|
|
1171
1224
|
});
|
|
1172
|
-
}, [
|
|
1173
|
-
wrapper,
|
|
1174
|
-
screenPadding,
|
|
1175
|
-
highlightedMessage,
|
|
1176
|
-
semantics,
|
|
1177
|
-
targetedMessageContainer,
|
|
1178
|
-
blockedMessageContainer,
|
|
1179
|
-
]);
|
|
1225
|
+
}, [messageItemView, screenPadding, semantics, highlightedMessage, groupKey, isVeryLastBubble]);
|
|
1180
1226
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useMemo } from 'react';
|
|
2
|
-
import { Dimensions, StyleSheet, View
|
|
2
|
+
import { Dimensions, StyleSheet, View } from 'react-native';
|
|
3
3
|
|
|
4
4
|
import { SwipableMessageWrapper } from './MessageBubble';
|
|
5
5
|
|
|
@@ -22,25 +22,7 @@ import { FileTypes } from '../../../types/types';
|
|
|
22
22
|
import { checkMessageEquality, checkQuotedMessageEquality } from '../../../utils/utils';
|
|
23
23
|
import { useMessageData } from '../hooks/useMessageData';
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const useStyles = ({
|
|
28
|
-
alignment,
|
|
29
|
-
isVeryLastMessage,
|
|
30
|
-
messageGroupedSingle,
|
|
31
|
-
messageGroupedBottom,
|
|
32
|
-
messageGroupedTop,
|
|
33
|
-
messageGroupedMiddle,
|
|
34
|
-
enableMessageGroupingByUser,
|
|
35
|
-
}: {
|
|
36
|
-
alignment: Alignment;
|
|
37
|
-
isVeryLastMessage: boolean;
|
|
38
|
-
messageGroupedSingle: boolean;
|
|
39
|
-
messageGroupedBottom: boolean;
|
|
40
|
-
messageGroupedTop: boolean;
|
|
41
|
-
messageGroupedMiddle: boolean;
|
|
42
|
-
enableMessageGroupingByUser: boolean;
|
|
43
|
-
}) => {
|
|
25
|
+
const useStyles = ({ alignment }: { alignment: Alignment }) => {
|
|
44
26
|
const {
|
|
45
27
|
theme: {
|
|
46
28
|
messageItemView: {
|
|
@@ -53,24 +35,11 @@ const useStyles = ({
|
|
|
53
35
|
repliesContainer,
|
|
54
36
|
leftAlignItems,
|
|
55
37
|
rightAlignItems,
|
|
56
|
-
messageGroupedSingleStyles,
|
|
57
|
-
messageGroupedBottomStyles,
|
|
58
|
-
messageGroupedTopStyles,
|
|
59
|
-
messageGroupedMiddleStyles,
|
|
60
|
-
lastMessageContainer,
|
|
61
38
|
},
|
|
62
39
|
},
|
|
63
40
|
} = useTheme();
|
|
64
41
|
|
|
65
|
-
|
|
66
|
-
if (messageGroupedSingle) return 'single';
|
|
67
|
-
if (messageGroupedTop) return 'top';
|
|
68
|
-
if (messageGroupedMiddle) return 'middle';
|
|
69
|
-
if (messageGroupedBottom) return 'bottom';
|
|
70
|
-
return undefined;
|
|
71
|
-
}, [messageGroupedSingle, messageGroupedTop, messageGroupedMiddle, messageGroupedBottom]);
|
|
72
|
-
|
|
73
|
-
const styles = useMemo(
|
|
42
|
+
return useMemo(
|
|
74
43
|
() =>
|
|
75
44
|
StyleSheet.create({
|
|
76
45
|
baseContainer: {
|
|
@@ -129,73 +98,6 @@ const useStyles = ({
|
|
|
129
98
|
rightAlignItems,
|
|
130
99
|
],
|
|
131
100
|
);
|
|
132
|
-
|
|
133
|
-
const groupStylesMap = useMemo(() => {
|
|
134
|
-
return {
|
|
135
|
-
single: {
|
|
136
|
-
paddingVertical: primitives.spacingXs,
|
|
137
|
-
...messageGroupedSingleStyles,
|
|
138
|
-
},
|
|
139
|
-
top: {
|
|
140
|
-
paddingTop: primitives.spacingXs,
|
|
141
|
-
paddingBottom: primitives.spacingXxs,
|
|
142
|
-
...messageGroupedTopStyles,
|
|
143
|
-
},
|
|
144
|
-
middle: {
|
|
145
|
-
paddingBottom: primitives.spacingXxs,
|
|
146
|
-
...messageGroupedMiddleStyles,
|
|
147
|
-
},
|
|
148
|
-
bottom: {
|
|
149
|
-
paddingBottom: primitives.spacingXs,
|
|
150
|
-
...messageGroupedBottomStyles,
|
|
151
|
-
},
|
|
152
|
-
};
|
|
153
|
-
}, [
|
|
154
|
-
messageGroupedBottomStyles,
|
|
155
|
-
messageGroupedMiddleStyles,
|
|
156
|
-
messageGroupedSingleStyles,
|
|
157
|
-
messageGroupedTopStyles,
|
|
158
|
-
]);
|
|
159
|
-
|
|
160
|
-
const containerStyle = useMemo(() => {
|
|
161
|
-
let results: ViewStyle = styles.baseContainer;
|
|
162
|
-
|
|
163
|
-
if (groupType) {
|
|
164
|
-
results = {
|
|
165
|
-
...results,
|
|
166
|
-
...groupStylesMap[groupType],
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
if (isVeryLastMessage && enableMessageGroupingByUser) {
|
|
171
|
-
results = {
|
|
172
|
-
...results,
|
|
173
|
-
marginBottom: primitives.spacingSm,
|
|
174
|
-
...lastMessageContainer,
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
return results;
|
|
179
|
-
}, [
|
|
180
|
-
styles.baseContainer,
|
|
181
|
-
groupStylesMap,
|
|
182
|
-
groupType,
|
|
183
|
-
isVeryLastMessage,
|
|
184
|
-
enableMessageGroupingByUser,
|
|
185
|
-
lastMessageContainer,
|
|
186
|
-
]);
|
|
187
|
-
|
|
188
|
-
return {
|
|
189
|
-
container: containerStyle,
|
|
190
|
-
bubbleContentContainer: styles.bubbleContentContainer,
|
|
191
|
-
bubbleErrorContainer: styles.bubbleErrorContainer,
|
|
192
|
-
bubbleReactionListTopContainer: styles.bubbleReactionListTopContainer,
|
|
193
|
-
bubbleWrapper: styles.bubbleWrapper,
|
|
194
|
-
contentContainer: styles.contentContainer,
|
|
195
|
-
repliesContainer: styles.repliesContainer,
|
|
196
|
-
leftAlignItems: styles.leftAlignItems,
|
|
197
|
-
rightAlignItems: styles.rightAlignItems,
|
|
198
|
-
};
|
|
199
101
|
};
|
|
200
102
|
|
|
201
103
|
export type MessageItemViewPropsWithContext = Pick<
|
|
@@ -232,7 +134,6 @@ const MessageItemViewWithContext = (props: MessageItemViewPropsWithContext) => {
|
|
|
232
134
|
channel,
|
|
233
135
|
contextMenuAnchorRef,
|
|
234
136
|
customMessageSwipeAction,
|
|
235
|
-
enableMessageGroupingByUser,
|
|
236
137
|
enableSwipeToReply,
|
|
237
138
|
groupStyles,
|
|
238
139
|
hasAttachmentActions,
|
|
@@ -273,22 +174,10 @@ const MessageItemViewWithContext = (props: MessageItemViewPropsWithContext) => {
|
|
|
273
174
|
isMessageReceivedOrErrorType,
|
|
274
175
|
isMessageTypeDeleted,
|
|
275
176
|
isVeryLastMessage,
|
|
276
|
-
messageGroupedSingle,
|
|
277
|
-
messageGroupedBottom,
|
|
278
|
-
messageGroupedTop,
|
|
279
177
|
messageGroupedSingleOrBottom,
|
|
280
|
-
messageGroupedMiddle,
|
|
281
178
|
} = useMessageData({});
|
|
282
179
|
|
|
283
|
-
const styles = useStyles({
|
|
284
|
-
alignment,
|
|
285
|
-
isVeryLastMessage,
|
|
286
|
-
messageGroupedSingle,
|
|
287
|
-
messageGroupedBottom,
|
|
288
|
-
messageGroupedTop,
|
|
289
|
-
messageGroupedMiddle,
|
|
290
|
-
enableMessageGroupingByUser,
|
|
291
|
-
});
|
|
180
|
+
const styles = useStyles({ alignment });
|
|
292
181
|
|
|
293
182
|
const groupStyle = `${alignment}_${groupStyles?.[0]?.toLowerCase?.()}`;
|
|
294
183
|
const hasVisibleQuotedReply = !!message.quoted_message && !hasAttachmentActions;
|
|
@@ -324,7 +213,7 @@ const MessageItemViewWithContext = (props: MessageItemViewPropsWithContext) => {
|
|
|
324
213
|
});
|
|
325
214
|
|
|
326
215
|
const itemViewContent = (
|
|
327
|
-
<View pointerEvents='box-none' style={styles.
|
|
216
|
+
<View pointerEvents='box-none' style={styles.baseContainer} testID='message-item-view-wrapper'>
|
|
328
217
|
{alignment === 'left' ? <MessageAuthor /> : null}
|
|
329
218
|
{isMessageTypeDeleted ? (
|
|
330
219
|
<MessageDeleted date={message.created_at} groupStyle={groupStyle} />
|