@linktr.ee/messaging-react 2.2.0-rc-1778753733 → 2.2.2-rc-1779314025
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/{Card-EKxCn56j.js → Card-CAliTKdt.js} +3 -3
- package/dist/{Card-EKxCn56j.js.map → Card-CAliTKdt.js.map} +1 -1
- package/dist/Card-CRMpOj0f.cjs +2 -0
- package/dist/Card-CRMpOj0f.cjs.map +1 -0
- package/dist/{Card-ChR37pLZ.js → Card-Ca5PnHml.js} +2 -2
- package/dist/{Card-ChR37pLZ.js.map → Card-Ca5PnHml.js.map} +1 -1
- package/dist/{Card-BdTueeyk.js → Card-Dz2v3fXf.js} +2 -2
- package/dist/{Card-BdTueeyk.js.map → Card-Dz2v3fXf.js.map} +1 -1
- package/dist/Card-b41LWND_.cjs +2 -0
- package/dist/Card-b41LWND_.cjs.map +1 -0
- package/dist/Card-vEkarkVD.cjs +2 -0
- package/dist/Card-vEkarkVD.cjs.map +1 -0
- package/dist/{LockedThumbnail-B16qP3eH.js → LockedThumbnail-BGz0NIQh.js} +2 -2
- package/dist/{LockedThumbnail-B16qP3eH.js.map → LockedThumbnail-BGz0NIQh.js.map} +1 -1
- package/dist/LockedThumbnail-JuPkpHeX.cjs +2 -0
- package/dist/LockedThumbnail-JuPkpHeX.cjs.map +1 -0
- package/dist/index-CctUDJSJ.cjs +2 -0
- package/dist/index-CctUDJSJ.cjs.map +1 -0
- package/dist/{index-Dn7BC9xK.js → index-D55UTfgC.js} +1307 -1264
- package/dist/index-D55UTfgC.js.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +18 -16
- package/package.json +4 -3
- package/src/components/ChannelInfoDialog/ChannelInfoDialog.test.tsx +44 -0
- package/src/components/ChannelInfoDialog/index.tsx +5 -1
- package/src/components/ChannelList/CustomChannelPreview.test.tsx +35 -0
- package/src/components/ChannelList/CustomChannelPreview.tsx +2 -1
- package/src/components/ChannelView.test.tsx +65 -3
- package/src/components/ChannelView.tsx +53 -16
- package/src/index.ts +5 -0
- package/src/types.ts +9 -0
- package/src/utils/resolveParticipantDisplayName.test.ts +73 -0
- package/src/utils/resolveParticipantDisplayName.ts +40 -0
- package/dist/index-Dn7BC9xK.js.map +0 -1
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const UUID_REGEX =
|
|
2
|
+
/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i
|
|
3
|
+
|
|
4
|
+
export type ParticipantDisplayUser = {
|
|
5
|
+
id?: string
|
|
6
|
+
name?: string | null
|
|
7
|
+
username?: string | null
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function isUuidLike(value: string): boolean {
|
|
11
|
+
return UUID_REGEX.test(value.trim())
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function isUsableDisplayValue(
|
|
15
|
+
value: string | null | undefined,
|
|
16
|
+
userId?: string
|
|
17
|
+
): value is string {
|
|
18
|
+
const trimmed = value?.trim()
|
|
19
|
+
if (!trimmed) return false
|
|
20
|
+
if (userId && trimmed === userId) return false
|
|
21
|
+
return !isUuidLike(trimmed)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Resolves a human-readable participant label from Stream user fields.
|
|
26
|
+
* Never falls back to user.id. UUID-like names are treated as missing.
|
|
27
|
+
*/
|
|
28
|
+
export function resolveParticipantDisplayName(
|
|
29
|
+
user?: ParticipantDisplayUser | null
|
|
30
|
+
): string {
|
|
31
|
+
if (isUsableDisplayValue(user?.name, user?.id)) {
|
|
32
|
+
return user.name.trim()
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (isUsableDisplayValue(user?.username, user?.id)) {
|
|
36
|
+
return user.username.trim()
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return 'Unknown member'
|
|
40
|
+
}
|