@linktr.ee/messaging-react 1.25.1 → 1.26.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.25.1",
3
+ "version": "1.26.0",
4
4
  "description": "React messaging components built on messaging-core for web applications",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -76,4 +76,22 @@ describe('ChannelList', () => {
76
76
  expect(streamProps.onMessageNew).toBe(onMessageNew)
77
77
  expect(streamProps.onAddedToChannel).toBe(onAddedToChannel)
78
78
  })
79
+
80
+ it('passes channelRenderFilterFn through to Stream ChannelList', () => {
81
+ const filterFn = vi.fn()
82
+
83
+ renderWithProviders(
84
+ React.createElement(ChannelList, {
85
+ ...defaultProps,
86
+ channelRenderFilterFn: filterFn,
87
+ })
88
+ )
89
+
90
+ expect(streamChannelListMock).toHaveBeenCalledOnce()
91
+ const streamProps = streamChannelListMock.mock.calls[0][0] as {
92
+ channelRenderFilterFn?: unknown
93
+ }
94
+
95
+ expect(streamProps.channelRenderFilterFn).toBe(filterFn)
96
+ })
79
97
  })
@@ -21,6 +21,7 @@ export const ChannelList = React.memo<ChannelListProps>(
21
21
  allowNewMessagesFromUnfilteredChannels = false,
22
22
  onMessageNew,
23
23
  onAddedToChannel,
24
+ channelRenderFilterFn,
24
25
  sort = DEFAULT_SORT,
25
26
  className,
26
27
  customEmptyStateIndicator,
@@ -71,6 +72,7 @@ export const ChannelList = React.memo<ChannelListProps>(
71
72
  }
72
73
  onMessageNew={onMessageNew}
73
74
  onAddedToChannel={onAddedToChannel}
75
+ channelRenderFilterFn={channelRenderFilterFn}
74
76
  Preview={CustomChannelPreview}
75
77
  EmptyStateIndicator={customEmptyStateIndicator}
76
78
  />
@@ -27,6 +27,7 @@ export const MessagingShell: React.FC<MessagingShellProps> = ({
27
27
  CustomChannelEmptyState,
28
28
  showChannelList = true,
29
29
  filters,
30
+ channelRenderFilterFn,
30
31
  channelListCustomEmptyStateIndicator,
31
32
  onDeleteConversationClick,
32
33
  onBlockParticipantClick,
@@ -455,6 +456,7 @@ export const MessagingShell: React.FC<MessagingShellProps> = ({
455
456
  onChannelSelect={handleChannelSelect}
456
457
  selectedChannel={selectedChannel || undefined}
457
458
  filters={channelFilters}
459
+ channelRenderFilterFn={channelRenderFilterFn}
458
460
  customEmptyStateIndicator={channelListCustomEmptyStateIndicator}
459
461
  renderMessagePreview={renderMessagePreview}
460
462
  />
package/src/types.ts CHANGED
@@ -91,6 +91,20 @@ export interface ChannelListProps {
91
91
  * channel belongs in the current list before inserting it.
92
92
  */
93
93
  onAddedToChannel?: StreamChannelListProps['onAddedToChannel']
94
+ /**
95
+ * Client-side filter applied before rendering the channel list.
96
+ * Websocket events can add channels to the list that bypass server-side
97
+ * query filters. Use this to enforce visibility rules that can't be
98
+ * automatically derived from the filters prop (e.g. $or conditions).
99
+ *
100
+ * @example
101
+ * // Hide channels where the visitor hasn't sent a message yet,
102
+ * // but keep legacy channels that predate the has_visitor_message field
103
+ * channelRenderFilterFn={(channels) =>
104
+ * channels.filter(ch => ch.data?.has_visitor_message !== false)
105
+ * }
106
+ */
107
+ channelRenderFilterFn?: (channels: Channel[]) => Channel[]
94
108
  /**
95
109
  * Sort order for the channel list query.
96
110
  * Defaults to `{ last_message_at: -1 }` (most recent first).
@@ -282,6 +296,18 @@ export interface MessagingShellProps extends ChannelViewPassthroughProps {
282
296
  */
283
297
  filters?: ChannelFilters
284
298
 
299
+ /**
300
+ * Client-side filter applied before rendering the channel list.
301
+ * Websocket events can add channels to the list that bypass server-side
302
+ * query filters. Use this to enforce visibility rules client-side.
303
+ *
304
+ * @example
305
+ * channelRenderFilterFn={(channels) =>
306
+ * channels.filter(ch => ch.data?.has_visitor_message !== false)
307
+ * }
308
+ */
309
+ channelRenderFilterFn?: (channels: Channel[]) => Channel[]
310
+
285
311
  /**
286
312
  * Custom empty state indicator component to render when the channel list is empty.
287
313
  * Useful for showing a custom empty state indicator when the channel list is empty.