@linktr.ee/messaging-react 1.16.0 → 1.17.0-rc-1769666674

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.16.0",
3
+ "version": "1.17.0-rc-1769666674",
4
4
  "description": "React messaging components built on messaging-core for web applications",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -628,8 +628,13 @@ export const ChannelView = React.memo<ChannelViewProps>(
628
628
  onBlockParticipantClick,
629
629
  onReportParticipantClick,
630
630
  dmAgentEnabled,
631
+ messageMetadata,
632
+ onMessageSent,
631
633
  }) => {
632
- // Custom send message handler that adds skip_push and silent when DM agent is active
634
+ // Custom send message handler that:
635
+ // 1. Applies messageMetadata if provided
636
+ // 2. Adds skip_push and silent when DM agent is active
637
+ // 3. Calls onMessageSent callback with full response
633
638
  // Read chatbot_paused inside callback to get current value at send time (not stale closure)
634
639
  const doSendMessageRequest = useCallback(
635
640
  async (
@@ -641,15 +646,27 @@ export const ChannelView = React.memo<ChannelViewProps>(
641
646
  (channel.data as { chatbot_paused?: boolean })?.chatbot_paused === true
642
647
  const shouldSuppressNotifications = dmAgentEnabled && !agentPaused
643
648
 
644
- if (shouldSuppressNotifications) {
645
- return channel.sendMessage(
646
- { ...message, silent: true },
647
- { ...options, skip_push: true }
648
- )
649
+ // Build final message with metadata
650
+ const finalMessage = {
651
+ ...message,
652
+ ...(shouldSuppressNotifications && { silent: true }),
653
+ ...(messageMetadata && messageMetadata),
649
654
  }
650
- return channel.sendMessage(message, options)
655
+
656
+ // Build final options
657
+ const finalOptions = {
658
+ ...options,
659
+ ...(shouldSuppressNotifications && { skip_push: true }),
660
+ }
661
+
662
+ const response = await channel.sendMessage(finalMessage, finalOptions)
663
+
664
+ // Fire callback with full response (includes message.id)
665
+ onMessageSent?.(response)
666
+
667
+ return response
651
668
  },
652
- [channel, dmAgentEnabled]
669
+ [channel, dmAgentEnabled, messageMetadata, onMessageSent]
653
670
  )
654
671
 
655
672
  return (
@@ -31,6 +31,8 @@ export const MessagingShell: React.FC<MessagingShellProps> = ({
31
31
  onBlockParticipantClick,
32
32
  onReportParticipantClick,
33
33
  dmAgentEnabled,
34
+ messageMetadata,
35
+ onMessageSent,
34
36
  }) => {
35
37
  const {
36
38
  service,
@@ -477,6 +479,8 @@ export const MessagingShell: React.FC<MessagingShellProps> = ({
477
479
  onBlockParticipantClick={onBlockParticipantClick}
478
480
  onReportParticipantClick={onReportParticipantClick}
479
481
  dmAgentEnabled={dmAgentEnabled}
482
+ messageMetadata={messageMetadata}
483
+ onMessageSent={onMessageSent}
480
484
  />
481
485
  </div>
482
486
  ) : initialParticipantFilter ? (
package/src/index.ts CHANGED
@@ -32,6 +32,7 @@ export type {
32
32
  ParticipantSource,
33
33
  Participant,
34
34
  } from './types'
35
+ export type { MessageMetadata } from './stream-custom-data'
35
36
  export type { AvatarProps } from './components/Avatar'
36
37
  export type { Faq, FaqListProps } from './components/FaqList'
37
38
  export type { FaqListItemProps } from './components/FaqList/FaqListItem'
@@ -14,6 +14,18 @@
14
14
 
15
15
  import 'stream-chat'
16
16
 
17
+ /**
18
+ * Message metadata for paid messaging and chatbot flows.
19
+ * Used to identify message types and payment status.
20
+ */
21
+ export interface MessageMetadata {
22
+ custom_type?: 'MESSAGE_TIP' | 'MESSAGE_PAID' | 'MESSAGE_CHATBOT'
23
+ amount_text?: string
24
+ payment_status?: string
25
+ payment_intent_id?: string
26
+ listing_id?: string
27
+ }
28
+
17
29
  declare module 'stream-chat' {
18
30
  interface CustomMessageData {
19
31
  /**
@@ -25,15 +37,6 @@ declare module 'stream-chat' {
25
37
  * Message metadata from backend.
26
38
  * Contains type and payment information.
27
39
  */
28
- metadata?: {
29
- custom_type?: 'MESSAGE_TIP' | 'MESSAGE_PAID' | 'MESSAGE_CHATBOT'
30
- amount_text?: string
31
- payment_status?: string
32
- payment_intent_id?: string
33
- listing_id?: string
34
- }
40
+ metadata?: MessageMetadata
35
41
  }
36
42
  }
37
-
38
- // Required to make this a module (enables the module augmentation above)
39
- export {}
package/src/styles.css CHANGED
@@ -109,6 +109,10 @@
109
109
  flex-direction: column;
110
110
  }
111
111
 
112
+ .str-chat__typing-indicator {
113
+ inset-inline: auto;
114
+ }
115
+
112
116
  /* Custom message tag styles */
113
117
  .message-tag {
114
118
  display: inline-flex;
package/src/types.ts CHANGED
@@ -2,10 +2,10 @@ import type {
2
2
  MessagingUser,
3
3
  StreamChatServiceConfig,
4
4
  } from '@linktr.ee/messaging-core'
5
- import type { Channel, ChannelFilters } from 'stream-chat'
5
+ import type { Channel, ChannelFilters, SendMessageAPIResponse } from 'stream-chat'
6
6
  import { EmptyStateIndicatorProps } from 'stream-chat-react'
7
7
 
8
- import './stream-custom-data'
8
+ import type { MessageMetadata } from './stream-custom-data'
9
9
 
10
10
  /**
11
11
  * Generic participant interface for different host environments
@@ -102,6 +102,27 @@ export interface ChannelViewProps {
102
102
  * The library reads chatbot_paused from channel.data internally.
103
103
  */
104
104
  dmAgentEnabled?: boolean
105
+
106
+ /**
107
+ * Custom metadata to attach to all outgoing messages.
108
+ * Used for paid messaging flows where messages need custom_type and listing_id.
109
+ *
110
+ * @example
111
+ * messageMetadata={{ custom_type: 'MESSAGE_PAID', listing_id: '...' }}
112
+ */
113
+ messageMetadata?: Pick<MessageMetadata, 'custom_type' | 'listing_id'>
114
+
115
+ /**
116
+ * Callback fired after a message is successfully sent.
117
+ * Receives the full API response including message.id.
118
+ * Useful for triggering payment flows with the message ID.
119
+ *
120
+ * @example
121
+ * onMessageSent={(response) => {
122
+ * openPaymentModal(response.message.id)
123
+ * }}
124
+ */
125
+ onMessageSent?: (response: SendMessageAPIResponse) => void
105
126
  }
106
127
 
107
128
  /**
@@ -116,6 +137,8 @@ export type ChannelViewPassthroughProps = Pick<
116
137
  | 'onBlockParticipantClick'
117
138
  | 'onReportParticipantClick'
118
139
  | 'dmAgentEnabled'
140
+ | 'messageMetadata'
141
+ | 'onMessageSent'
119
142
  >
120
143
 
121
144
  /**