@linktr.ee/messaging-react 1.15.0 → 1.15.1

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.15.0",
3
+ "version": "1.15.1",
4
4
  "description": "React messaging components built on messaging-core for web applications",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,6 +1,6 @@
1
1
  import type { Meta, StoryFn } from '@storybook/react'
2
2
  import React from 'react'
3
- import { Channel, LocalMessage, StreamChat } from 'stream-chat'
3
+ import { Channel, CustomMessageData, LocalMessage, StreamChat } from 'stream-chat'
4
4
 
5
5
  import CustomChannelPreview from './CustomChannelPreview'
6
6
 
@@ -41,6 +41,7 @@ const createMockChannel = (options: {
41
41
  og_scrape_url?: string
42
42
  thumb_url?: string
43
43
  }>
44
+ lastMessageMetadata?: CustomMessageData['metadata']
44
45
  }): Channel => {
45
46
  const {
46
47
  id,
@@ -51,6 +52,7 @@ const createMockChannel = (options: {
51
52
  lastMessageTime = new Date(),
52
53
  unreadCount = 0,
53
54
  lastMessageAttachments,
55
+ lastMessageMetadata,
54
56
  } = options
55
57
 
56
58
  return {
@@ -86,6 +88,7 @@ const createMockChannel = (options: {
86
88
  name: participantName,
87
89
  },
88
90
  attachments: lastMessageAttachments,
91
+ metadata: lastMessageMetadata,
89
92
  },
90
93
  ] as unknown as LocalMessage[])
91
94
  : ([] as LocalMessage[]),
@@ -204,6 +207,19 @@ LongName.args = {
204
207
  }),
205
208
  }
206
209
 
210
+ export const ChatbotMessage: StoryFn<ComponentProps> = Template.bind({})
211
+ ChatbotMessage.args = {
212
+ channel: createMockChannel({
213
+ id: 'channel-chatbot',
214
+ participantName: 'Emily Watson',
215
+ participantId: 'participant-chatbot',
216
+ participantImage: 'https://i.pravatar.cc/150?img=9',
217
+ lastMessageText: 'Thanks for reaching out! How can I help you today?',
218
+ lastMessageTime: new Date(Date.now() - 1000 * 60 * 2), // 2 minutes ago
219
+ lastMessageMetadata: { custom_type: 'MESSAGE_CHATBOT' },
220
+ }),
221
+ }
222
+
207
223
  export const SelectedWithUnread: StoryFn<ComponentProps> = Template.bind({})
208
224
  SelectedWithUnread.args = {
209
225
  channel: createMockChannel({
@@ -5,6 +5,7 @@ import { ChannelPreviewUIComponentProps } from 'stream-chat-react'
5
5
 
6
6
  import { formatRelativeTime } from '../../utils/formatRelativeTime'
7
7
  import { Avatar } from '../Avatar'
8
+ import { isChatbotMessage } from '../CustomMessage/MessageTag'
8
9
 
9
10
  type CustomChannelPreviewProps = ChannelPreviewUIComponentProps & {
10
11
  selectedChannel?: Channel | null
@@ -62,6 +63,9 @@ const CustomChannelPreview = React.memo<CustomChannelPreviewProps>(
62
63
  const lastMessageTime = lastMessage?.created_at
63
64
  ? formatRelativeTime(new Date(lastMessage.created_at))
64
65
  : ''
66
+ const isLastMessageFromChatbot = lastMessage
67
+ ? isChatbotMessage(lastMessage)
68
+ : false
65
69
 
66
70
  // Use the unread prop passed by Stream Chat (reactive and updates automatically)
67
71
  const unreadCount = unread ?? 0
@@ -120,6 +124,7 @@ const CustomChannelPreview = React.memo<CustomChannelPreviewProps>(
120
124
  {/* Message and unread badge row */}
121
125
  <div className="flex items-center justify-between gap-2 min-w-0">
122
126
  <p className="text-xs text-stone mr-2 flex-1 line-clamp-2">
127
+ {isLastMessageFromChatbot && '✨ '}
123
128
  {lastMessageText}
124
129
  </p>
125
130
  {unreadCount > 0 && (