@linktr.ee/messaging-react 1.10.0 → 1.11.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@linktr.ee/messaging-react",
3
- "version": "1.10.0",
3
+ "version": "1.11.0",
4
4
  "description": "React messaging components built on messaging-core for web applications",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -23,6 +23,7 @@ import ActionButton from './ActionButton'
23
23
  import { Avatar } from './Avatar'
24
24
  import { CloseButton } from './CloseButton'
25
25
  import { CustomMessageInput } from './CustomMessageInput'
26
+ import { CustomSystemMessage } from './CustomSystemMessage'
26
27
  import { ChannelEmptyState } from './MessagingShell/ChannelEmptyState'
27
28
 
28
29
  // Custom user type with email and username
@@ -529,7 +530,7 @@ export const ChannelView: React.FC<ChannelViewProps> = ({
529
530
  className
530
531
  )}
531
532
  >
532
- <Channel channel={channel}>
533
+ <Channel channel={channel} MessageSystem={CustomSystemMessage}>
533
534
  <ChannelViewInner
534
535
  onBack={onBack}
535
536
  showBackButton={showBackButton}
@@ -0,0 +1,16 @@
1
+ import { MessageTimestamp, type EventComponentProps } from 'stream-chat-react'
2
+
3
+ export const CustomSystemMessage: React.FC<EventComponentProps> = (props) => {
4
+ const isDateHidden = props.message.hide_date === true
5
+
6
+ return (
7
+ <div className="str-chat__message--system" data-testid="message-system">
8
+ <div className="str-chat__message--system__text">
9
+ <div className="str-chat__message--system__line"></div>
10
+ <p>{props.message.text}</p>
11
+ <div className="str-chat__message--system__line"></div>
12
+ </div>
13
+ {!isDateHidden && <MessageTimestamp message={props.message} />}
14
+ </div>
15
+ )
16
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Stream Chat custom data type augmentation.
3
+ *
4
+ * This file extends Stream Chat's type system by augmenting their empty
5
+ * CustomMessageData interface with our custom properties.
6
+ *
7
+ * @see https://getstream.io/chat/docs/sdk/react/guides/typescript_and_custom_data_types/
8
+ *
9
+ * Note: We use a .ts extension instead of .d.ts so that this file can be
10
+ * imported as a module and included in the build. Declaration files (.d.ts)
11
+ * are ambient and cannot be imported - they require manual build configuration
12
+ * to be included in the distributed types.
13
+ */
14
+
15
+ import 'stream-chat'
16
+
17
+ declare module 'stream-chat' {
18
+ interface CustomMessageData {
19
+ /**
20
+ * When true, hides the date timestamp in system messages.
21
+ * Used by CustomSystemMessage component.
22
+ */
23
+ hide_date?: boolean
24
+ }
25
+ }
26
+
27
+ // Required to make this a module (enables the module augmentation above)
28
+ export {}
package/src/types.ts CHANGED
@@ -5,6 +5,8 @@ import type {
5
5
  import type { Channel, ChannelFilters } from 'stream-chat'
6
6
  import { EmptyStateIndicatorProps } from 'stream-chat-react'
7
7
 
8
+ import './stream-custom-data'
9
+
8
10
  /**
9
11
  * Generic participant interface for different host environments
10
12
  */