@linktr.ee/messaging-react 1.24.3 → 1.24.4-rc-1773546789
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/dist/index.d.ts +8 -0
- package/dist/index.js +179 -178
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/ChannelList/index.test.tsx +57 -0
- package/src/components/ChannelList/index.tsx +4 -1
- package/src/types.ts +8 -0
package/package.json
CHANGED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { describe, expect, it, vi, beforeEach } from 'vitest'
|
|
3
|
+
|
|
4
|
+
import { renderWithProviders } from '../../test/utils'
|
|
5
|
+
|
|
6
|
+
import { ChannelList } from '.'
|
|
7
|
+
|
|
8
|
+
const streamChannelListMock = vi.fn()
|
|
9
|
+
|
|
10
|
+
vi.mock('stream-chat-react', () => ({
|
|
11
|
+
ChannelList: (props: unknown) => {
|
|
12
|
+
streamChannelListMock(props)
|
|
13
|
+
return <div data-testid="stream-channel-list" />
|
|
14
|
+
},
|
|
15
|
+
}))
|
|
16
|
+
|
|
17
|
+
vi.mock('../../providers/MessagingProvider', () => ({
|
|
18
|
+
useMessagingContext: () => ({ debug: false }),
|
|
19
|
+
}))
|
|
20
|
+
|
|
21
|
+
vi.mock('./CustomChannelPreview', () => ({
|
|
22
|
+
default: () => null,
|
|
23
|
+
}))
|
|
24
|
+
|
|
25
|
+
describe('ChannelList', () => {
|
|
26
|
+
const defaultProps = {
|
|
27
|
+
filters: { type: 'messaging' },
|
|
28
|
+
onChannelSelect: vi.fn(),
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
beforeEach(() => {
|
|
32
|
+
streamChannelListMock.mockClear()
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
it('defaults unseen-channel promotion to false', () => {
|
|
36
|
+
renderWithProviders(<ChannelList {...defaultProps} />)
|
|
37
|
+
|
|
38
|
+
expect(streamChannelListMock).toHaveBeenCalledOnce()
|
|
39
|
+
expect(streamChannelListMock.mock.calls[0][0]).toMatchObject({
|
|
40
|
+
allowNewMessagesFromUnfilteredChannels: false,
|
|
41
|
+
})
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
it('passes allowNewMessagesFromUnfilteredChannels through to Stream ChannelList', () => {
|
|
45
|
+
const props: React.ComponentProps<typeof ChannelList> = {
|
|
46
|
+
...defaultProps,
|
|
47
|
+
allowNewMessagesFromUnfilteredChannels: true,
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
renderWithProviders(React.createElement(ChannelList, props))
|
|
51
|
+
|
|
52
|
+
expect(streamChannelListMock).toHaveBeenCalledOnce()
|
|
53
|
+
expect(streamChannelListMock.mock.calls[0][0]).toMatchObject({
|
|
54
|
+
allowNewMessagesFromUnfilteredChannels: true,
|
|
55
|
+
})
|
|
56
|
+
})
|
|
57
|
+
})
|
|
@@ -18,6 +18,7 @@ export const ChannelList = React.memo<ChannelListProps>(
|
|
|
18
18
|
onChannelSelect,
|
|
19
19
|
selectedChannel,
|
|
20
20
|
filters,
|
|
21
|
+
allowNewMessagesFromUnfilteredChannels = false,
|
|
21
22
|
sort = DEFAULT_SORT,
|
|
22
23
|
className,
|
|
23
24
|
customEmptyStateIndicator,
|
|
@@ -63,7 +64,9 @@ export const ChannelList = React.memo<ChannelListProps>(
|
|
|
63
64
|
filters={filters}
|
|
64
65
|
sort={sort}
|
|
65
66
|
options={{ limit: 30 }}
|
|
66
|
-
allowNewMessagesFromUnfilteredChannels={
|
|
67
|
+
allowNewMessagesFromUnfilteredChannels={
|
|
68
|
+
allowNewMessagesFromUnfilteredChannels
|
|
69
|
+
}
|
|
67
70
|
Preview={CustomChannelPreview}
|
|
68
71
|
EmptyStateIndicator={customEmptyStateIndicator}
|
|
69
72
|
/>
|
package/src/types.ts
CHANGED
|
@@ -68,6 +68,14 @@ export interface ChannelListProps {
|
|
|
68
68
|
participantLabel?: string
|
|
69
69
|
className?: string
|
|
70
70
|
filters: ChannelFilters
|
|
71
|
+
/**
|
|
72
|
+
* Controls whether new-message events can promote channels that are not
|
|
73
|
+
* already present in the current list.
|
|
74
|
+
*
|
|
75
|
+
* Defaults to `false` for backward compatibility with existing filtered
|
|
76
|
+
* ChannelList consumers.
|
|
77
|
+
*/
|
|
78
|
+
allowNewMessagesFromUnfilteredChannels?: boolean
|
|
71
79
|
/**
|
|
72
80
|
* Sort order for the channel list query.
|
|
73
81
|
* Defaults to `{ last_message_at: -1 }` (most recent first).
|