stream-chat-react-native-core 5.32.0-beta.1 → 5.32.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.
Files changed (228) hide show
  1. package/lib/commonjs/components/Channel/Channel.js +7 -1
  2. package/lib/commonjs/components/Channel/Channel.js.map +1 -1
  3. package/lib/commonjs/components/Channel/hooks/useCreateMessagesContext.js +2 -0
  4. package/lib/commonjs/components/Channel/hooks/useCreateMessagesContext.js.map +1 -1
  5. package/lib/commonjs/components/ChannelPreview/ChannelPreviewStatus.js +18 -3
  6. package/lib/commonjs/components/ChannelPreview/ChannelPreviewStatus.js.map +1 -1
  7. package/lib/commonjs/components/ChannelPreview/hooks/useLatestMessagePreview.js +4 -17
  8. package/lib/commonjs/components/ChannelPreview/hooks/useLatestMessagePreview.js.map +1 -1
  9. package/lib/commonjs/components/Chat/Chat.js.map +1 -1
  10. package/lib/commonjs/components/ImageGallery/components/ImageGalleryHeader.js +9 -6
  11. package/lib/commonjs/components/ImageGallery/components/ImageGalleryHeader.js.map +1 -1
  12. package/lib/commonjs/components/Message/MessageSimple/MessageEditedTimestamp.js +4 -5
  13. package/lib/commonjs/components/Message/MessageSimple/MessageEditedTimestamp.js.map +1 -1
  14. package/lib/commonjs/components/Message/MessageSimple/MessageFooter.js +8 -8
  15. package/lib/commonjs/components/Message/MessageSimple/MessageFooter.js.map +1 -1
  16. package/lib/commonjs/components/Message/MessageSimple/MessageTimestamp.js +21 -18
  17. package/lib/commonjs/components/Message/MessageSimple/MessageTimestamp.js.map +1 -1
  18. package/lib/commonjs/components/MessageList/InlineDateSeparator.js +14 -12
  19. package/lib/commonjs/components/MessageList/InlineDateSeparator.js.map +1 -1
  20. package/lib/commonjs/components/MessageList/MessageList.js +4 -28
  21. package/lib/commonjs/components/MessageList/MessageList.js.map +1 -1
  22. package/lib/commonjs/components/MessageList/MessageSystem.js +14 -8
  23. package/lib/commonjs/components/MessageList/MessageSystem.js.map +1 -1
  24. package/lib/commonjs/components/MessageList/StickyHeader.js +36 -0
  25. package/lib/commonjs/components/MessageList/StickyHeader.js.map +1 -0
  26. package/lib/commonjs/components/index.js +11 -0
  27. package/lib/commonjs/components/index.js.map +1 -1
  28. package/lib/commonjs/contexts/channelContext/ChannelContext.js.map +1 -1
  29. package/lib/commonjs/contexts/messagesContext/MessagesContext.js.map +1 -1
  30. package/lib/commonjs/hooks/useStreami18n.js +1 -1
  31. package/lib/commonjs/i18n/en.json +88 -81
  32. package/lib/commonjs/i18n/es.json +88 -81
  33. package/lib/commonjs/i18n/fr.json +88 -81
  34. package/lib/commonjs/i18n/he.json +88 -81
  35. package/lib/commonjs/i18n/hi.json +88 -81
  36. package/lib/commonjs/i18n/it.json +88 -81
  37. package/lib/commonjs/i18n/ja.json +88 -81
  38. package/lib/commonjs/i18n/ko.json +88 -81
  39. package/lib/commonjs/i18n/nl.json +88 -81
  40. package/lib/commonjs/i18n/pt-br.json +90 -0
  41. package/lib/commonjs/i18n/ru.json +88 -81
  42. package/lib/commonjs/i18n/tr.json +88 -81
  43. package/lib/commonjs/index.js +2 -1
  44. package/lib/commonjs/index.js.map +1 -1
  45. package/lib/{module/utils → commonjs/utils/i18n}/Streami18n.js +62 -69
  46. package/lib/commonjs/utils/i18n/Streami18n.js.map +1 -0
  47. package/lib/commonjs/utils/i18n/calendarFormats.js +104 -0
  48. package/lib/commonjs/utils/i18n/calendarFormats.js.map +1 -0
  49. package/lib/commonjs/utils/i18n/getDateString.js +47 -0
  50. package/lib/commonjs/utils/i18n/getDateString.js.map +1 -0
  51. package/lib/commonjs/utils/i18n/predefinedFormatters.js +40 -0
  52. package/lib/commonjs/utils/i18n/predefinedFormatters.js.map +1 -0
  53. package/lib/commonjs/version.json +1 -1
  54. package/lib/module/components/Channel/Channel.js +7 -1
  55. package/lib/module/components/Channel/Channel.js.map +1 -1
  56. package/lib/module/components/Channel/hooks/useCreateMessagesContext.js +2 -0
  57. package/lib/module/components/Channel/hooks/useCreateMessagesContext.js.map +1 -1
  58. package/lib/module/components/ChannelPreview/ChannelPreviewStatus.js +18 -3
  59. package/lib/module/components/ChannelPreview/ChannelPreviewStatus.js.map +1 -1
  60. package/lib/module/components/ChannelPreview/hooks/useLatestMessagePreview.js +4 -17
  61. package/lib/module/components/ChannelPreview/hooks/useLatestMessagePreview.js.map +1 -1
  62. package/lib/module/components/Chat/Chat.js.map +1 -1
  63. package/lib/module/components/ImageGallery/components/ImageGalleryHeader.js +9 -6
  64. package/lib/module/components/ImageGallery/components/ImageGalleryHeader.js.map +1 -1
  65. package/lib/module/components/Message/MessageSimple/MessageEditedTimestamp.js +4 -5
  66. package/lib/module/components/Message/MessageSimple/MessageEditedTimestamp.js.map +1 -1
  67. package/lib/module/components/Message/MessageSimple/MessageFooter.js +8 -8
  68. package/lib/module/components/Message/MessageSimple/MessageFooter.js.map +1 -1
  69. package/lib/module/components/Message/MessageSimple/MessageTimestamp.js +21 -18
  70. package/lib/module/components/Message/MessageSimple/MessageTimestamp.js.map +1 -1
  71. package/lib/module/components/MessageList/InlineDateSeparator.js +14 -12
  72. package/lib/module/components/MessageList/InlineDateSeparator.js.map +1 -1
  73. package/lib/module/components/MessageList/MessageList.js +4 -28
  74. package/lib/module/components/MessageList/MessageList.js.map +1 -1
  75. package/lib/module/components/MessageList/MessageSystem.js +14 -8
  76. package/lib/module/components/MessageList/MessageSystem.js.map +1 -1
  77. package/lib/module/components/MessageList/StickyHeader.js +36 -0
  78. package/lib/module/components/MessageList/StickyHeader.js.map +1 -0
  79. package/lib/module/components/index.js +11 -0
  80. package/lib/module/components/index.js.map +1 -1
  81. package/lib/module/contexts/channelContext/ChannelContext.js.map +1 -1
  82. package/lib/module/contexts/messagesContext/MessagesContext.js.map +1 -1
  83. package/lib/module/hooks/useStreami18n.js +1 -1
  84. package/lib/module/i18n/en.json +88 -81
  85. package/lib/module/i18n/es.json +88 -81
  86. package/lib/module/i18n/fr.json +88 -81
  87. package/lib/module/i18n/he.json +88 -81
  88. package/lib/module/i18n/hi.json +88 -81
  89. package/lib/module/i18n/it.json +88 -81
  90. package/lib/module/i18n/ja.json +88 -81
  91. package/lib/module/i18n/ko.json +88 -81
  92. package/lib/module/i18n/nl.json +88 -81
  93. package/lib/module/i18n/pt-br.json +90 -0
  94. package/lib/module/i18n/ru.json +88 -81
  95. package/lib/module/i18n/tr.json +88 -81
  96. package/lib/module/index.js +2 -1
  97. package/lib/module/index.js.map +1 -1
  98. package/lib/{commonjs/utils → module/utils/i18n}/Streami18n.js +62 -69
  99. package/lib/module/utils/i18n/Streami18n.js.map +1 -0
  100. package/lib/module/utils/i18n/calendarFormats.js +104 -0
  101. package/lib/module/utils/i18n/calendarFormats.js.map +1 -0
  102. package/lib/module/utils/i18n/getDateString.js +47 -0
  103. package/lib/module/utils/i18n/getDateString.js.map +1 -0
  104. package/lib/module/utils/i18n/predefinedFormatters.js +40 -0
  105. package/lib/module/utils/i18n/predefinedFormatters.js.map +1 -0
  106. package/lib/module/version.json +1 -1
  107. package/lib/typescript/components/Channel/Channel.d.ts +1 -1
  108. package/lib/typescript/components/Channel/Channel.d.ts.map +1 -1
  109. package/lib/typescript/components/Channel/hooks/useCreateMessagesContext.d.ts +1 -1
  110. package/lib/typescript/components/Channel/hooks/useCreateMessagesContext.d.ts.map +1 -1
  111. package/lib/typescript/components/ChannelPreview/ChannelPreviewStatus.d.ts.map +1 -1
  112. package/lib/typescript/components/ChannelPreview/hooks/useLatestMessagePreview.d.ts +1 -1
  113. package/lib/typescript/components/ChannelPreview/hooks/useLatestMessagePreview.d.ts.map +1 -1
  114. package/lib/typescript/components/Chat/Chat.d.ts +1 -1
  115. package/lib/typescript/components/Chat/Chat.d.ts.map +1 -1
  116. package/lib/typescript/components/ImageGallery/components/ImageGalleryHeader.d.ts.map +1 -1
  117. package/lib/typescript/components/Message/MessageSimple/MessageEditedTimestamp.d.ts +2 -2
  118. package/lib/typescript/components/Message/MessageSimple/MessageEditedTimestamp.d.ts.map +1 -1
  119. package/lib/typescript/components/Message/MessageSimple/MessageFooter.d.ts.map +1 -1
  120. package/lib/typescript/components/Message/MessageSimple/MessageTimestamp.d.ts +2 -13
  121. package/lib/typescript/components/Message/MessageSimple/MessageTimestamp.d.ts.map +1 -1
  122. package/lib/typescript/components/Message/hooks/useMessageActionHandlers.d.ts +1 -1
  123. package/lib/typescript/components/Message/hooks/useMessageActions.d.ts +1 -1
  124. package/lib/typescript/components/MessageList/DateHeader.d.ts +1 -1
  125. package/lib/typescript/components/MessageList/DateHeader.d.ts.map +1 -1
  126. package/lib/typescript/components/MessageList/InlineDateSeparator.d.ts +7 -1
  127. package/lib/typescript/components/MessageList/InlineDateSeparator.d.ts.map +1 -1
  128. package/lib/typescript/components/MessageList/MessageList.d.ts +1 -2
  129. package/lib/typescript/components/MessageList/MessageList.d.ts.map +1 -1
  130. package/lib/typescript/components/MessageList/MessageSystem.d.ts +3 -0
  131. package/lib/typescript/components/MessageList/MessageSystem.d.ts.map +1 -1
  132. package/lib/typescript/components/MessageList/StickyHeader.d.ts +18 -0
  133. package/lib/typescript/components/MessageList/StickyHeader.d.ts.map +1 -0
  134. package/lib/typescript/components/index.d.ts +1 -0
  135. package/lib/typescript/components/index.d.ts.map +1 -1
  136. package/lib/typescript/contexts/channelContext/ChannelContext.d.ts +2 -3
  137. package/lib/typescript/contexts/channelContext/ChannelContext.d.ts.map +1 -1
  138. package/lib/typescript/contexts/messageContext/MessageContext.d.ts +1 -1
  139. package/lib/typescript/contexts/messageInputContext/MessageInputContext.d.ts +1 -1
  140. package/lib/typescript/contexts/messagesContext/MessagesContext.d.ts +6 -0
  141. package/lib/typescript/contexts/messagesContext/MessagesContext.d.ts.map +1 -1
  142. package/lib/typescript/contexts/overlayContext/OverlayContext.d.ts +1 -1
  143. package/lib/typescript/contexts/overlayContext/OverlayContext.d.ts.map +1 -1
  144. package/lib/typescript/hooks/useStreami18n.d.ts +1 -1
  145. package/lib/typescript/hooks/useStreami18n.d.ts.map +1 -1
  146. package/lib/typescript/i18n/en.json +88 -81
  147. package/lib/typescript/i18n/es.json +88 -81
  148. package/lib/typescript/i18n/fr.json +88 -81
  149. package/lib/typescript/i18n/he.json +88 -81
  150. package/lib/typescript/i18n/hi.json +88 -81
  151. package/lib/typescript/i18n/it.json +88 -81
  152. package/lib/typescript/i18n/ja.json +88 -81
  153. package/lib/typescript/i18n/ko.json +88 -81
  154. package/lib/typescript/i18n/nl.json +88 -81
  155. package/lib/typescript/i18n/pt-br.json +90 -0
  156. package/lib/typescript/i18n/ru.json +88 -81
  157. package/lib/typescript/i18n/tr.json +88 -81
  158. package/lib/typescript/index.d.ts +3 -1
  159. package/lib/typescript/index.d.ts.map +1 -1
  160. package/lib/typescript/utils/{Streami18n.d.ts → i18n/Streami18n.d.ts} +16 -10
  161. package/lib/typescript/utils/i18n/Streami18n.d.ts.map +1 -0
  162. package/lib/typescript/utils/i18n/calendarFormats.d.ts +14 -0
  163. package/lib/typescript/utils/i18n/calendarFormats.d.ts.map +1 -0
  164. package/lib/typescript/utils/i18n/getDateString.d.ts +16 -0
  165. package/lib/typescript/utils/i18n/getDateString.d.ts.map +1 -0
  166. package/lib/typescript/utils/i18n/predefinedFormatters.d.ts +13 -0
  167. package/lib/typescript/utils/i18n/predefinedFormatters.d.ts.map +1 -0
  168. package/package.json +10 -10
  169. package/src/components/Attachment/__tests__/Giphy.test.js +1 -1
  170. package/src/components/Channel/Channel.tsx +6 -1
  171. package/src/components/Channel/hooks/useCreateMessagesContext.ts +2 -0
  172. package/src/components/ChannelPreview/ChannelPreviewStatus.tsx +16 -2
  173. package/src/components/ChannelPreview/hooks/useLatestMessagePreview.ts +7 -28
  174. package/src/components/Chat/Chat.tsx +1 -1
  175. package/src/components/Chat/__tests__/Chat.test.js +1 -1
  176. package/src/components/ImageGallery/components/ImageGalleryHeader.tsx +13 -3
  177. package/src/components/Message/MessageSimple/MessageEditedTimestamp.tsx +10 -5
  178. package/src/components/Message/MessageSimple/MessageFooter.tsx +10 -7
  179. package/src/components/Message/MessageSimple/MessageTimestamp.tsx +20 -29
  180. package/src/components/Message/MessageSimple/__tests__/MessageStatus.test.js +1 -1
  181. package/src/components/MessageList/DateHeader.tsx +1 -1
  182. package/src/components/MessageList/InlineDateSeparator.tsx +20 -15
  183. package/src/components/MessageList/MessageList.tsx +4 -31
  184. package/src/components/MessageList/MessageSystem.tsx +20 -8
  185. package/src/components/MessageList/StickyHeader.tsx +42 -0
  186. package/src/components/MessageList/__tests__/MessageSystem.test.js +8 -3
  187. package/src/components/MessageList/__tests__/ScrollToBottomButton.test.js +1 -1
  188. package/src/components/MessageList/__tests__/TypingIndicator.test.js +1 -1
  189. package/src/components/Thread/__tests__/Thread.test.js +1 -1
  190. package/src/components/Thread/__tests__/__snapshots__/Thread.test.js.snap +1 -1
  191. package/src/components/index.ts +1 -0
  192. package/src/contexts/channelContext/ChannelContext.tsx +2 -1
  193. package/src/contexts/messagesContext/MessagesContext.tsx +6 -0
  194. package/src/contexts/overlayContext/OverlayContext.tsx +1 -1
  195. package/src/hooks/useStreami18n.ts +1 -1
  196. package/src/i18n/en.json +8 -1
  197. package/src/i18n/es.json +73 -66
  198. package/src/i18n/fr.json +73 -66
  199. package/src/i18n/he.json +73 -66
  200. package/src/i18n/hi.json +73 -66
  201. package/src/i18n/it.json +73 -66
  202. package/src/i18n/ja.json +73 -66
  203. package/src/i18n/ko.json +75 -68
  204. package/src/i18n/nl.json +73 -66
  205. package/src/i18n/pt-br.json +90 -0
  206. package/src/i18n/ru.json +73 -66
  207. package/src/i18n/tr.json +73 -66
  208. package/src/index.ts +4 -1
  209. package/src/utils/__tests__/Streami18n.test.js +23 -1
  210. package/src/utils/{Streami18n.ts → i18n/Streami18n.ts} +60 -71
  211. package/src/utils/i18n/calendarFormats.ts +110 -0
  212. package/src/utils/i18n/getDateString.ts +76 -0
  213. package/src/utils/i18n/predefinedFormatters.ts +63 -0
  214. package/src/version.json +1 -1
  215. package/lib/commonjs/i18n/pt-BR.json +0 -83
  216. package/lib/commonjs/utils/Streami18n.js.map +0 -1
  217. package/lib/commonjs/utils/getDateString.js +0 -31
  218. package/lib/commonjs/utils/getDateString.js.map +0 -1
  219. package/lib/module/i18n/pt-BR.json +0 -83
  220. package/lib/module/utils/Streami18n.js.map +0 -1
  221. package/lib/module/utils/getDateString.js +0 -31
  222. package/lib/module/utils/getDateString.js.map +0 -1
  223. package/lib/typescript/i18n/pt-BR.json +0 -83
  224. package/lib/typescript/utils/Streami18n.d.ts.map +0 -1
  225. package/lib/typescript/utils/getDateString.d.ts +0 -30
  226. package/lib/typescript/utils/getDateString.d.ts.map +0 -1
  227. package/src/i18n/pt-BR.json +0 -83
  228. package/src/utils/getDateString.ts +0 -67
@@ -27,8 +27,8 @@ import { SDK } from '../../native';
27
27
  import { QuickSqliteClient } from '../../store/QuickSqliteClient';
28
28
  import type { DefaultStreamChatGenerics } from '../../types/types';
29
29
  import { DBSyncManager } from '../../utils/DBSyncManager';
30
+ import type { Streami18n } from '../../utils/i18n/Streami18n';
30
31
  import { StreamChatRN } from '../../utils/StreamChatRN';
31
- import type { Streami18n } from '../../utils/Streami18n';
32
32
  import { version } from '../../version.json';
33
33
 
34
34
  init();
@@ -10,7 +10,7 @@ import { useTranslationContext } from '../../../contexts/translationContext/Tran
10
10
  import dispatchConnectionChangedEvent from '../../../mock-builders/event/connectionChanged';
11
11
  import dispatchConnectionRecoveredEvent from '../../../mock-builders/event/connectionRecovered';
12
12
  import { getTestClient } from '../../../mock-builders/mock';
13
- import { Streami18n } from '../../../utils/Streami18n';
13
+ import { Streami18n } from '../../../utils/i18n/Streami18n';
14
14
  import { Chat } from '../Chat';
15
15
 
16
16
  const ChatContextConsumer = ({ fn }) => {
@@ -1,4 +1,4 @@
1
- import React, { useState } from 'react';
1
+ import React, { useMemo, useState } from 'react';
2
2
  import { Pressable, SafeAreaView, StyleSheet, Text, View, ViewStyle } from 'react-native';
3
3
  import Animated, { Extrapolate, interpolate, useAnimatedStyle } from 'react-native-reanimated';
4
4
 
@@ -8,7 +8,7 @@ import { useTranslationContext } from '../../../contexts/translationContext/Tran
8
8
  import { Close } from '../../../icons';
9
9
 
10
10
  import type { DefaultStreamChatGenerics } from '../../../types/types';
11
- import { getDateString } from '../../../utils/getDateString';
11
+ import { getDateString } from '../../../utils/i18n/getDateString';
12
12
  import type { Photo } from '../ImageGallery';
13
13
 
14
14
  const ReanimatedSafeAreaView = Animated.createAnimatedComponent
@@ -70,6 +70,7 @@ type Props<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamC
70
70
  opacity: Animated.SharedValue<number>;
71
71
  visible: Animated.SharedValue<number>;
72
72
  photo?: Photo<StreamChatGenerics>;
73
+ /* Lookup key in the language corresponding translations sheet to perform date formatting */
73
74
  };
74
75
 
75
76
  export const ImageGalleryHeader = <
@@ -98,7 +99,16 @@ export const ImageGalleryHeader = <
98
99
  const { t, tDateTimeParser } = useTranslationContext();
99
100
  const { setOverlay } = useOverlayContext();
100
101
 
101
- const date = getDateString({ calendar: true, date: photo?.created_at, tDateTimeParser });
102
+ const date = useMemo(
103
+ () =>
104
+ getDateString({
105
+ date: photo?.created_at,
106
+ t,
107
+ tDateTimeParser,
108
+ timestampTranslationKey: 'timestamp/ImageGalleryHeader',
109
+ }),
110
+ [photo?.created_at, t, tDateTimeParser],
111
+ );
102
112
 
103
113
  const headerStyle = useAnimatedStyle<ViewStyle>(() => ({
104
114
  opacity: opacity.value,
@@ -1,12 +1,11 @@
1
1
  import React from 'react';
2
2
  import { StyleSheet, Text, View } from 'react-native';
3
3
 
4
- import { MessageTimestamp, MessageTimestampProps } from './MessageTimestamp';
5
-
6
4
  import {
7
5
  MessageContextValue,
8
6
  useMessageContext,
9
7
  } from '../../../contexts/messageContext/MessageContext';
8
+ import { MessagesContextValue } from '../../../contexts/messagesContext/MessagesContext';
10
9
  import { useTheme } from '../../../contexts/themeContext/ThemeContext';
11
10
  import { useTranslationContext } from '../../../contexts/translationContext/TranslationContext';
12
11
  import { DefaultStreamChatGenerics } from '../../../types/types';
@@ -14,14 +13,15 @@ import { isEditedMessage } from '../../../utils/utils';
14
13
 
15
14
  export type MessageEditedTimestampProps<
16
15
  StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
17
- > = Partial<Pick<MessageContextValue<StreamChatGenerics>, 'message'>> & MessageTimestampProps;
16
+ > = Partial<Pick<MessageContextValue<StreamChatGenerics>, 'message'>> &
17
+ Partial<Pick<MessagesContextValue<StreamChatGenerics>, 'MessageTimestamp'>>;
18
18
 
19
19
  export const MessageEditedTimestamp = <
20
20
  StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
21
21
  >(
22
22
  props: MessageEditedTimestampProps<StreamChatGenerics>,
23
23
  ) => {
24
- const { message: propMessage, timestamp } = props;
24
+ const { message: propMessage, MessageTimestamp } = props;
25
25
  const {
26
26
  theme: {
27
27
  colors: { grey },
@@ -41,7 +41,12 @@ export const MessageEditedTimestamp = <
41
41
  return (
42
42
  <View style={[styles.container, editedTimestampContainer]}>
43
43
  <Text style={[styles.text, { color: grey }, editedLabel]}>{t<string>('Edited') + ' '}</Text>
44
- <MessageTimestamp calendar={true} timestamp={timestamp} />
44
+ {MessageTimestamp && (
45
+ <MessageTimestamp
46
+ timestamp={message.message_text_updated_at}
47
+ timestampTranslationKey='timestamp/MessageEditedTimestamp'
48
+ />
49
+ )}
45
50
  </View>
46
51
  );
47
52
  };
@@ -5,8 +5,6 @@ import type { Attachment } from 'stream-chat';
5
5
 
6
6
  import type { MessageStatusProps } from './MessageStatus';
7
7
 
8
- import { MessageTimestamp } from './MessageTimestamp';
9
-
10
8
  import type { ChannelContextValue } from '../../../contexts/channelContext/ChannelContext';
11
9
  import {
12
10
  Alignment,
@@ -46,7 +44,10 @@ type MessageFooterPropsWithContext<
46
44
  > &
47
45
  Pick<
48
46
  MessagesContextValue<StreamChatGenerics>,
49
- 'deletedMessagesVisibilityType' | 'MessageEditedTimestamp' | 'MessageStatus'
47
+ | 'deletedMessagesVisibilityType'
48
+ | 'MessageEditedTimestamp'
49
+ | 'MessageStatus'
50
+ | 'MessageTimestamp'
50
51
  > &
51
52
  MessageFooterComponentProps;
52
53
 
@@ -98,6 +99,7 @@ const MessageFooterWithContext = <
98
99
  message,
99
100
  MessageEditedTimestamp,
100
101
  MessageStatus,
102
+ MessageTimestamp,
101
103
  otherAttachments,
102
104
  showMessageStatus,
103
105
  } = props;
@@ -118,7 +120,7 @@ const MessageFooterWithContext = <
118
120
  {deletedMessagesVisibilityType === 'sender' && (
119
121
  <OnlyVisibleToYouComponent alignment={alignment} />
120
122
  )}
121
- <MessageTimestamp format='LT' formattedDate={formattedDate} timestamp={date} />
123
+ <MessageTimestamp formattedDate={formattedDate} timestamp={date} />
122
124
  </View>
123
125
  );
124
126
  }
@@ -137,7 +139,7 @@ const MessageFooterWithContext = <
137
139
  <Text style={[styles.text, { color: grey }, messageUser]}>{message.user.name}</Text>
138
140
  ) : null}
139
141
  {showMessageStatus && <MessageStatus />}
140
- <MessageTimestamp format='LT' formattedDate={formattedDate} timestamp={date} />
142
+ <MessageTimestamp formattedDate={formattedDate} timestamp={date} />
141
143
 
142
144
  {isEditedMessage(message) && !isEditedMessageOpen && (
143
145
  <>
@@ -160,7 +162,7 @@ const MessageFooterWithContext = <
160
162
  )}
161
163
  </View>
162
164
  {isEditedMessageOpen && (
163
- <MessageEditedTimestamp format='LT' timestamp={message.message_text_updated_at} />
165
+ <MessageEditedTimestamp message={message} MessageTimestamp={MessageTimestamp} />
164
166
  )}
165
167
  </>
166
168
  );
@@ -270,7 +272,7 @@ export const MessageFooter = <
270
272
  showMessageStatus,
271
273
  } = useMessageContext<StreamChatGenerics>();
272
274
 
273
- const { deletedMessagesVisibilityType, MessageEditedTimestamp, MessageStatus } =
275
+ const { deletedMessagesVisibilityType, MessageEditedTimestamp, MessageStatus, MessageTimestamp } =
274
276
  useMessagesContext<StreamChatGenerics>();
275
277
 
276
278
  return (
@@ -284,6 +286,7 @@ export const MessageFooter = <
284
286
  message,
285
287
  MessageEditedTimestamp,
286
288
  MessageStatus,
289
+ MessageTimestamp,
287
290
  otherAttachments,
288
291
  showMessageStatus,
289
292
  }}
@@ -1,27 +1,14 @@
1
- import React from 'react';
1
+ import React, { useMemo } from 'react';
2
2
  import { StyleSheet, Text } from 'react-native';
3
3
 
4
4
  import { useTheme } from '../../../contexts/themeContext/ThemeContext';
5
5
  import {
6
- TDateTimeParserInput,
7
6
  TranslationContextValue,
8
7
  useTranslationContext,
9
8
  } from '../../../contexts/translationContext/TranslationContext';
10
- import { getDateString } from '../../../utils/getDateString';
9
+ import { getDateString } from '../../../utils/i18n/getDateString';
11
10
 
12
11
  export type MessageTimestampProps = Partial<Pick<TranslationContextValue, 'tDateTimeParser'>> & {
13
- /**
14
- * Whether to show the time in Calendar time format. Calendar time displays time relative to a today's date.
15
- */
16
- calendar?: boolean;
17
- /**
18
- * The format in which the date should be displayed.
19
- */
20
- format?: string;
21
- /**
22
- * A function to format the date.
23
- */
24
- formatDate?: (date: TDateTimeParserInput) => string;
25
12
  /**
26
13
  * Already Formatted date
27
14
  */
@@ -30,17 +17,21 @@ export type MessageTimestampProps = Partial<Pick<TranslationContextValue, 'tDate
30
17
  * The timestamp of the message.
31
18
  */
32
19
  timestamp?: string | Date;
20
+ /*
21
+ * Lookup key in the language corresponding translations sheet to perform date formatting
22
+ */
23
+ timestampTranslationKey?: string;
33
24
  };
34
25
 
35
26
  export const MessageTimestamp = (props: MessageTimestampProps) => {
36
27
  const {
37
- calendar,
38
- format,
39
- formatDate,
40
28
  formattedDate,
41
29
  tDateTimeParser: propsTDateTimeParser,
42
30
  timestamp,
31
+ timestampTranslationKey = 'timestamp/MessageTimestamp',
43
32
  } = props;
33
+ const { t, tDateTimeParser: contextTDateTimeParser } = useTranslationContext();
34
+ const tDateTimeParser = propsTDateTimeParser || contextTDateTimeParser;
44
35
 
45
36
  const {
46
37
  theme: {
@@ -50,7 +41,17 @@ export const MessageTimestamp = (props: MessageTimestampProps) => {
50
41
  },
51
42
  },
52
43
  } = useTheme();
53
- const { tDateTimeParser: contextTDateTimeParser } = useTranslationContext();
44
+
45
+ const dateString = useMemo(
46
+ () =>
47
+ getDateString({
48
+ date: timestamp,
49
+ t,
50
+ tDateTimeParser,
51
+ timestampTranslationKey,
52
+ }),
53
+ [timestamp, t, tDateTimeParser, timestampTranslationKey],
54
+ );
54
55
 
55
56
  if (formattedDate) {
56
57
  return (
@@ -58,16 +59,6 @@ export const MessageTimestamp = (props: MessageTimestampProps) => {
58
59
  );
59
60
  }
60
61
 
61
- if (!timestamp) return null;
62
-
63
- const dateString = getDateString({
64
- calendar,
65
- date: timestamp,
66
- format,
67
- formatDate,
68
- tDateTimeParser: propsTDateTimeParser || contextTDateTimeParser,
69
- });
70
-
71
62
  if (!dateString) return null;
72
63
 
73
64
  return <Text style={[styles.text, { color: grey }, timestampText]}>{dateString.toString()}</Text>;
@@ -5,7 +5,7 @@ import { cleanup, render, waitFor } from '@testing-library/react-native';
5
5
  import { generateMessage } from '../../../../mock-builders/generator/message';
6
6
  import { generateStaticUser, generateUser } from '../../../../mock-builders/generator/user';
7
7
  import { getTestClientWithUser } from '../../../../mock-builders/mock';
8
- import { Streami18n } from '../../../../utils/Streami18n';
8
+ import { Streami18n } from '../../../../utils/i18n/Streami18n';
9
9
  import { Chat } from '../../../Chat/Chat';
10
10
  import { MessageStatus } from '../MessageStatus';
11
11
 
@@ -21,7 +21,7 @@ const styles = StyleSheet.create({
21
21
  });
22
22
 
23
23
  export type DateHeaderProps = {
24
- dateString: string | number;
24
+ dateString?: string | number;
25
25
  };
26
26
 
27
27
  export const DateHeader = ({ dateString }: DateHeaderProps) => {
@@ -1,9 +1,9 @@
1
- import React from 'react';
1
+ import React, { useMemo } from 'react';
2
2
  import { StyleSheet, Text, View } from 'react-native';
3
3
 
4
4
  import { useTheme } from '../../contexts/themeContext/ThemeContext';
5
5
  import { useTranslationContext } from '../../contexts/translationContext/TranslationContext';
6
- import { getDateString } from '../../utils/getDateString';
6
+ import { getDateString } from '../../utils/i18n/getDateString';
7
7
 
8
8
  const styles = StyleSheet.create({
9
9
  container: {
@@ -22,7 +22,13 @@ const styles = StyleSheet.create({
22
22
  },
23
23
  });
24
24
 
25
+ /**
26
+ * Props for the `InlineDateSeparator` component.
27
+ */
25
28
  export type InlineDateSeparatorProps = {
29
+ /**
30
+ * Date to be displayed.
31
+ */
26
32
  date?: Date;
27
33
  };
28
34
 
@@ -33,19 +39,18 @@ export const InlineDateSeparator = ({ date }: InlineDateSeparatorProps) => {
33
39
  inlineDateSeparator: { container, text },
34
40
  },
35
41
  } = useTheme();
36
- const { tDateTimeParser } = useTranslationContext();
37
-
38
- if (!date) {
39
- return null;
40
- }
41
-
42
- const dateFormat = date.getFullYear() === new Date().getFullYear() ? 'MMM D' : 'MMM D, YYYY';
43
-
44
- const dateString = getDateString({
45
- date,
46
- format: dateFormat,
47
- tDateTimeParser,
48
- });
42
+ const { t, tDateTimeParser } = useTranslationContext();
43
+
44
+ const dateString = useMemo(
45
+ () =>
46
+ getDateString({
47
+ date,
48
+ t,
49
+ tDateTimeParser,
50
+ timestampTranslationKey: 'timestamp/InlineDateSeparator',
51
+ }),
52
+ [date, t, tDateTimeParser],
53
+ );
49
54
 
50
55
  return (
51
56
  <View
@@ -51,13 +51,8 @@ import {
51
51
  } from '../../contexts/paginatedMessageListContext/PaginatedMessageListContext';
52
52
  import { mergeThemes, ThemeProvider, useTheme } from '../../contexts/themeContext/ThemeContext';
53
53
  import { ThreadContextValue, useThreadContext } from '../../contexts/threadContext/ThreadContext';
54
- import {
55
- TranslationContextValue,
56
- useTranslationContext,
57
- } from '../../contexts/translationContext/TranslationContext';
58
54
 
59
55
  import type { DefaultStreamChatGenerics } from '../../types/types';
60
- import { getDateString } from '../../utils/getDateString';
61
56
 
62
57
  const WAIT_FOR_SCROLL_TO_OFFSET_TIMEOUT = 150;
63
58
  const MAX_RETRIES_AFTER_SCROLL_FAILURE = 10;
@@ -156,8 +151,7 @@ type MessageListPropsWithContext<
156
151
  | 'TypingIndicator'
157
152
  | 'TypingIndicatorContainer'
158
153
  > &
159
- Pick<ThreadContextValue<StreamChatGenerics>, 'loadMoreThread' | 'thread'> &
160
- Pick<TranslationContextValue, 't' | 'tDateTimeParser'> & {
154
+ Pick<ThreadContextValue<StreamChatGenerics>, 'loadMoreThread' | 'thread'> & {
161
155
  /**
162
156
  * Besides existing (default) UX behavior of underlying FlatList of MessageList component, if you want
163
157
  * to attach some additional props to underlying FlatList, you can add it to following prop.
@@ -278,7 +272,6 @@ const MessageListWithContext = <
278
272
  setTargetedMessage,
279
273
  StickyHeader,
280
274
  targetedMessage,
281
- tDateTimeParser,
282
275
  thread,
283
276
  threadList = false,
284
277
  TypingIndicator,
@@ -1025,18 +1018,6 @@ const MessageListWithContext = <
1025
1018
  threadList,
1026
1019
  ]);
1027
1020
 
1028
- const stickyHeaderDateFormat =
1029
- stickyHeaderDate?.getFullYear() === new Date().getFullYear() ? 'MMM D' : 'MMM D, YYYY';
1030
-
1031
- const stickyHeaderDateString = useMemo(() => {
1032
- if (!stickyHeaderDate) return null;
1033
- return getDateString({
1034
- date: stickyHeaderDate,
1035
- format: stickyHeaderDateFormat,
1036
- tDateTimeParser,
1037
- });
1038
- }, [stickyHeaderDate, stickyHeaderDateFormat]);
1039
-
1040
1021
  const dismissImagePicker = () => {
1041
1022
  if (!hasMoved && selectedPicker) {
1042
1023
  setSelectedPicker(undefined);
@@ -1092,13 +1073,6 @@ const MessageListWithContext = <
1092
1073
  [shouldApplyAndroidWorkaround, HeaderComponent],
1093
1074
  );
1094
1075
 
1095
- const StickyHeaderComponent = () => {
1096
- if (!stickyHeaderDateString) return null;
1097
- if (StickyHeader) return <StickyHeader dateString={stickyHeaderDateString} />;
1098
- if (messageListLengthAfterUpdate) return <DateHeader dateString={stickyHeaderDateString} />;
1099
- return null;
1100
- };
1101
-
1102
1076
  // We need to omit the style related props from the additionalFlatListProps and add them directly instead of spreading
1103
1077
  let additionalFlatListPropsExcludingStyle:
1104
1078
  | Omit<NonNullable<typeof additionalFlatListProps>, 'style' | 'contentContainerStyle'>
@@ -1183,7 +1157,9 @@ const MessageListWithContext = <
1183
1157
  {!loading && (
1184
1158
  <>
1185
1159
  <View style={styles.stickyHeader}>
1186
- <StickyHeaderComponent />
1160
+ {messageListLengthAfterUpdate && StickyHeader && (
1161
+ <StickyHeader date={stickyHeaderDate} DateHeader={DateHeader} />
1162
+ )}
1187
1163
  </View>
1188
1164
  {!disableTypingIndicator && TypingIndicator && (
1189
1165
  <TypingIndicatorContainer>
@@ -1253,7 +1229,6 @@ export const MessageList = <
1253
1229
  usePaginatedMessageListContext<StreamChatGenerics>();
1254
1230
  const { overlay } = useOverlayContext();
1255
1231
  const { loadMoreThread, thread } = useThreadContext<StreamChatGenerics>();
1256
- const { t, tDateTimeParser } = useTranslationContext();
1257
1232
 
1258
1233
  return (
1259
1234
  <MessageListWithContext
@@ -1295,9 +1270,7 @@ export const MessageList = <
1295
1270
  setSelectedPicker,
1296
1271
  setTargetedMessage,
1297
1272
  StickyHeader,
1298
- t,
1299
1273
  targetedMessage,
1300
- tDateTimeParser,
1301
1274
  thread,
1302
1275
  threadList,
1303
1276
  TypingIndicator,
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { useMemo } from 'react';
2
2
  import { StyleProp, StyleSheet, Text, View, ViewStyle } from 'react-native';
3
3
 
4
4
  import type { MessageType } from './hooks/useMessageList';
@@ -7,14 +7,20 @@ import { useTheme } from '../../contexts/themeContext/ThemeContext';
7
7
  import { useTranslationContext } from '../../contexts/translationContext/TranslationContext';
8
8
 
9
9
  import type { DefaultStreamChatGenerics } from '../../types/types';
10
- import { getDateString } from '../../utils/getDateString';
10
+ import { getDateString } from '../../utils/i18n/getDateString';
11
11
 
12
12
  export type MessageSystemProps<
13
13
  StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
14
14
  > = {
15
15
  /** Current [message object](https://getstream.io/chat/docs/#message_format) */
16
16
  message: MessageType<StreamChatGenerics>;
17
+ /**
18
+ * Additional styles for the system message container.
19
+ */
17
20
  style?: StyleProp<ViewStyle>;
21
+ /*
22
+ * Lookup key in the language corresponding translations sheet to perform date formatting
23
+ */
18
24
  };
19
25
 
20
26
  /**
@@ -37,14 +43,20 @@ export const MessageSystem = <
37
43
  },
38
44
  },
39
45
  } = useTheme();
40
- const { tDateTimeParser } = useTranslationContext();
46
+ const { t, tDateTimeParser } = useTranslationContext();
41
47
 
42
48
  const createdAt = message.created_at;
43
- const formattedDate = getDateString({
44
- calendar: true,
45
- date: createdAt,
46
- tDateTimeParser,
47
- });
49
+
50
+ const formattedDate = useMemo(
51
+ () =>
52
+ getDateString({
53
+ date: createdAt,
54
+ t,
55
+ tDateTimeParser,
56
+ timestampTranslationKey: 'timestamp/MessageSystem',
57
+ }),
58
+ [createdAt, t, tDateTimeParser],
59
+ );
48
60
 
49
61
  return (
50
62
  <View style={[styles.container, style, container]} testID='message-system'>
@@ -0,0 +1,42 @@
1
+ import React, { useMemo } from 'react';
2
+
3
+ import { MessagesContextValue } from '../../contexts/messagesContext/MessagesContext';
4
+ import { useTranslationContext } from '../../contexts/translationContext/TranslationContext';
5
+
6
+ import { DefaultStreamChatGenerics } from '../../types/types';
7
+ import { getDateString } from '../../utils/i18n/getDateString';
8
+
9
+ /**
10
+ * Props for the StickyHeader component.
11
+ */
12
+ export type StickyHeaderProps<
13
+ StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
14
+ > = Pick<MessagesContextValue<StreamChatGenerics>, 'DateHeader'> & {
15
+ /**
16
+ * Date to be displayed in the sticky header.
17
+ */
18
+ date?: Date;
19
+ /**
20
+ * The formatted date string to be displayed in the sticky header.
21
+ */
22
+ dateString?: string | number;
23
+ };
24
+
25
+ export const StickyHeader = ({ date, DateHeader, dateString }: StickyHeaderProps) => {
26
+ const { t, tDateTimeParser } = useTranslationContext();
27
+
28
+ const stickyHeaderDateString = useMemo(() => {
29
+ if (dateString) return dateString;
30
+
31
+ return getDateString({
32
+ date,
33
+ t,
34
+ tDateTimeParser,
35
+ timestampTranslationKey: 'timestamp/StickyHeader',
36
+ });
37
+ }, [date]);
38
+
39
+ if (!date) return null;
40
+
41
+ return <DateHeader dateString={stickyHeaderDateString} />;
42
+ };
@@ -8,14 +8,20 @@ import { TranslationProvider } from '../../../contexts/translationContext/Transl
8
8
 
9
9
  import { generateMessage, generateStaticMessage } from '../../../mock-builders/generator/message';
10
10
  import { generateStaticUser } from '../../../mock-builders/generator/user';
11
- import { Streami18n } from '../../../utils/Streami18n';
11
+ import { Streami18n } from '../../../utils/i18n/Streami18n';
12
12
  import { MessageSystem } from '../MessageSystem';
13
13
 
14
14
  afterEach(cleanup);
15
15
 
16
+ let i18nInstance;
17
+
16
18
  describe('MessageSystem', () => {
19
+ beforeAll(() => {
20
+ i18nInstance = new Streami18n();
21
+ });
22
+ afterEach(cleanup);
23
+
17
24
  it('should render the message system', async () => {
18
- const i18nInstance = new Streami18n();
19
25
  const translators = await i18nInstance.getTranslators();
20
26
  const message = generateMessage();
21
27
  const { queryByTestId } = render(
@@ -32,7 +38,6 @@ describe('MessageSystem', () => {
32
38
  });
33
39
 
34
40
  it('should match the snapshot for message system', async () => {
35
- const i18nInstance = new Streami18n();
36
41
  const translators = await i18nInstance.getTranslators();
37
42
  const user = generateStaticUser(0);
38
43
  const message = generateStaticMessage('Hello World', { user });
@@ -4,7 +4,7 @@ import { cleanup, fireEvent, render, waitFor } from '@testing-library/react-nati
4
4
 
5
5
  import { ThemeProvider } from '../../../contexts/themeContext/ThemeContext';
6
6
  import { TranslationProvider } from '../../../contexts/translationContext/TranslationContext';
7
- import { Streami18n } from '../../../utils/Streami18n';
7
+ import { Streami18n } from '../../../utils/i18n/Streami18n';
8
8
  import { ScrollToBottomButton } from '../ScrollToBottomButton';
9
9
 
10
10
  afterEach(cleanup);
@@ -7,7 +7,7 @@ import { TypingProvider } from '../../../contexts/typingContext/TypingContext';
7
7
 
8
8
  import { generateStaticUser, generateUser } from '../../../mock-builders/generator/user';
9
9
  import { getTestClientWithUser } from '../../../mock-builders/mock';
10
- import { Streami18n } from '../../../utils/Streami18n';
10
+ import { Streami18n } from '../../../utils/i18n/Streami18n';
11
11
  import { Chat } from '../../Chat/Chat';
12
12
  import { TypingIndicator } from '../TypingIndicator';
13
13
 
@@ -15,7 +15,7 @@ import { generateMember } from '../../../mock-builders/generator/member';
15
15
  import { generateMessage, generateStaticMessage } from '../../../mock-builders/generator/message';
16
16
  import { generateStaticUser } from '../../../mock-builders/generator/user';
17
17
  import { getTestClientWithUser } from '../../../mock-builders/mock';
18
- import { Streami18n } from '../../../utils/Streami18n';
18
+ import { Streami18n } from '../../../utils/i18n/Streami18n';
19
19
  import { Channel } from '../../Channel/Channel';
20
20
  import { Chat } from '../../Chat/Chat';
21
21
  import { Thread } from '../Thread';
@@ -1197,7 +1197,7 @@ exports[`Thread should match thread snapshot 1`] = `
1197
1197
  ]
1198
1198
  }
1199
1199
  >
1200
- May 5, 2020
1200
+ 05/05/2020
1201
1201
  </Text>
1202
1202
  </View>
1203
1203
  </View>
@@ -108,6 +108,7 @@ export * from './Message/MessageSimple/MessageRepliesAvatars';
108
108
  export * from './Message/MessageSimple/MessageSimple';
109
109
  export * from './Message/MessageSimple/MessageStatus';
110
110
  export * from './Message/MessageSimple/MessageTextContainer';
111
+ export * from './Message/MessageSimple/MessageTimestamp';
111
112
  export * from './Message/MessageSimple/ReactionList';
112
113
  export * from './Message/MessageSimple/utils/renderText';
113
114
  export * from './Message/utils/messageActions';
@@ -4,6 +4,7 @@ import type { Channel, ChannelState } from 'stream-chat';
4
4
 
5
5
  import type { EmptyStateProps } from '../../components/Indicators/EmptyStateIndicator';
6
6
  import type { LoadingProps } from '../../components/Indicators/LoadingIndicator';
7
+ import { StickyHeaderProps } from '../../components/MessageList/StickyHeader';
7
8
  import type { DefaultStreamChatGenerics, UnknownType } from '../../types/types';
8
9
  import { DEFAULT_BASE_CONTEXT_VALUE } from '../utils/defaultBaseContextValue';
9
10
 
@@ -180,7 +181,7 @@ export type ChannelContextValue<
180
181
  *
181
182
  * **Default** [DateHeader](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/MessageList/DateHeader.tsx)
182
183
  */
183
- StickyHeader?: React.ComponentType<{ dateString: string | number }>;
184
+ StickyHeader?: React.ComponentType<StickyHeaderProps>;
184
185
  /**
185
186
  * Id of message, around which Channel/MessageList gets loaded when opened.
186
187
  * You will see a highlighted background for targetted message, when opened.
@@ -33,6 +33,7 @@ import type { MessageRepliesAvatarsProps } from '../../components/Message/Messag
33
33
  import type { MessageSimpleProps } from '../../components/Message/MessageSimple/MessageSimple';
34
34
  import type { MessageStatusProps } from '../../components/Message/MessageSimple/MessageStatus';
35
35
  import type { MessageTextProps } from '../../components/Message/MessageSimple/MessageTextContainer';
36
+ import { MessageTimestampProps } from '../../components/Message/MessageSimple/MessageTimestamp';
36
37
  import type { ReactionListProps } from '../../components/Message/MessageSimple/ReactionList';
37
38
  import type { MarkdownRules } from '../../components/Message/MessageSimple/utils/renderText';
38
39
  import type { MessageActionsParams } from '../../components/Message/utils/messageActions';
@@ -217,6 +218,11 @@ export type MessagesContextValue<
217
218
  * Defaults to: [MessageSystem](https://getstream.io/chat/docs/sdk/reactnative/ui-components/message-system/)
218
219
  */
219
220
  MessageSystem: React.ComponentType<MessageSystemProps<StreamChatGenerics>>;
221
+ /**
222
+ * UI component for MessageTimestamp
223
+ * Defaults to: [MessageTimestamp](https://github.com/GetStream/stream-chat-react-native/blob/develop/package/src/components/Message/MessageSimple/MessageTimestamp.tsx)
224
+ */
225
+ MessageTimestamp: React.ComponentType<MessageTimestampProps>;
220
226
  /**
221
227
  * UI component for OverlayReactionList
222
228
  */