@linktr.ee/messaging-react 1.6.6 → 1.7.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/dist/index.js +780 -661
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/ChannelList/index.tsx +53 -11
package/package.json
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import SelectPill from '@linktr.ee/component-library/InputSelectPill'
|
|
2
|
+
import SelectPillGroup from '@linktr.ee/component-library/InputSelectPillGroup'
|
|
1
3
|
import { NotePencilIcon } from '@phosphor-icons/react'
|
|
2
4
|
import classNames from 'classnames'
|
|
3
|
-
import React from 'react'
|
|
5
|
+
import React, { useState } from 'react'
|
|
4
6
|
import {
|
|
5
7
|
ChannelList as StreamChannelList,
|
|
6
8
|
useChatContext,
|
|
@@ -12,6 +14,11 @@ import { IconButton } from '../IconButton'
|
|
|
12
14
|
|
|
13
15
|
import CustomChannelPreview from './CustomChannelPreview'
|
|
14
16
|
|
|
17
|
+
enum ChannelFilter {
|
|
18
|
+
All,
|
|
19
|
+
Unread,
|
|
20
|
+
}
|
|
21
|
+
|
|
15
22
|
/**
|
|
16
23
|
* Channel list component with customizable header and actions
|
|
17
24
|
*/
|
|
@@ -50,17 +57,27 @@ export const ChannelList: React.FC<ChannelListProps> = ({
|
|
|
50
57
|
})
|
|
51
58
|
}
|
|
52
59
|
|
|
60
|
+
const [staticFilters, setStaticFilters] = useState<{
|
|
61
|
+
type: string
|
|
62
|
+
last_message_at: { $exists: boolean }
|
|
63
|
+
has_unread: boolean | undefined
|
|
64
|
+
}>({
|
|
65
|
+
type: 'messaging',
|
|
66
|
+
last_message_at: { $exists: true },
|
|
67
|
+
has_unread: undefined,
|
|
68
|
+
})
|
|
69
|
+
|
|
53
70
|
// Filter for messaging channels
|
|
54
71
|
const filters = React.useMemo(() => {
|
|
55
72
|
const userId = client.userID
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
73
|
+
|
|
74
|
+
const newFilters = {
|
|
75
|
+
...staticFilters,
|
|
76
|
+
...(userId && {
|
|
77
|
+
members: { $in: [userId] },
|
|
78
|
+
hidden: false,
|
|
79
|
+
}),
|
|
80
|
+
}
|
|
64
81
|
|
|
65
82
|
if (debug) {
|
|
66
83
|
console.log('📺 [ChannelList] 🔍 FILTERS MEMOIZED', {
|
|
@@ -71,7 +88,7 @@ export const ChannelList: React.FC<ChannelListProps> = ({
|
|
|
71
88
|
}
|
|
72
89
|
|
|
73
90
|
return newFilters
|
|
74
|
-
}, [client.userID, debug])
|
|
91
|
+
}, [client.userID, debug, staticFilters])
|
|
75
92
|
|
|
76
93
|
return (
|
|
77
94
|
<div
|
|
@@ -83,7 +100,32 @@ export const ChannelList: React.FC<ChannelListProps> = ({
|
|
|
83
100
|
{/* Header */}
|
|
84
101
|
<div className="px-4 py-4 border-b border-sand bg-chalk">
|
|
85
102
|
<div className="flex items-center justify-between gap-3 min-h-10 min-w-0">
|
|
86
|
-
<
|
|
103
|
+
<div>
|
|
104
|
+
<h2 className="text-lg font-semibold text-charcoal">
|
|
105
|
+
Conversations
|
|
106
|
+
</h2>
|
|
107
|
+
<SelectPillGroup>
|
|
108
|
+
<SelectPill
|
|
109
|
+
checked={!filters.has_unread}
|
|
110
|
+
name="All"
|
|
111
|
+
onChange={() =>
|
|
112
|
+
setStaticFilters((state) => ({
|
|
113
|
+
...state,
|
|
114
|
+
has_unread: undefined,
|
|
115
|
+
}))
|
|
116
|
+
}
|
|
117
|
+
value={ChannelFilter.All}
|
|
118
|
+
/>
|
|
119
|
+
<SelectPill
|
|
120
|
+
checked={filters.has_unread}
|
|
121
|
+
name="Unread"
|
|
122
|
+
onChange={() =>
|
|
123
|
+
setStaticFilters((state) => ({ ...state, has_unread: true }))
|
|
124
|
+
}
|
|
125
|
+
value={ChannelFilter.Unread}
|
|
126
|
+
/>
|
|
127
|
+
</SelectPillGroup>
|
|
128
|
+
</div>
|
|
87
129
|
<div className="flex items-center gap-2">
|
|
88
130
|
{showStartConversation && onStartConversation && (
|
|
89
131
|
<IconButton
|