@linktr.ee/messaging-react 4.4.4 → 4.4.5-rc-1788226184
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.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/CustomMessage/StreamAttachmentMessage.test.tsx +31 -0
- package/src/components/MediaMessage/index.tsx +5 -3
- package/src/components/MediaMessage/isLinkAttachment.test.ts +14 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@linktr.ee/messaging-react",
|
|
3
|
-
"version": "4.4.
|
|
3
|
+
"version": "4.4.5-rc-1788226184",
|
|
4
4
|
"description": "React messaging components built on messaging-core for web applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
"chromatic:local": "yarn storybook:build && chromatic"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@linktr.ee/messaging-core": "
|
|
54
|
-
"@linktr.ee/messaging-taxonomy": "
|
|
53
|
+
"@linktr.ee/messaging-core": "2.6.0-rc-1788226184",
|
|
54
|
+
"@linktr.ee/messaging-taxonomy": "0.11.0-rc-1788226184",
|
|
55
55
|
"@phosphor-icons/react": "^2.1.10"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
@@ -266,6 +266,37 @@ describe('StreamAttachmentMessage', () => {
|
|
|
266
266
|
)
|
|
267
267
|
})
|
|
268
268
|
|
|
269
|
+
it('renders a scraped page typed audio by its og:audio preview as a link card', () => {
|
|
270
|
+
// Spotify episode: enrichment types it `audio` and puts the 30s clip in
|
|
271
|
+
// `asset_url`, but the shared thing is still a link (MES-1359).
|
|
272
|
+
renderWithProviders(
|
|
273
|
+
<StreamAttachmentMessage
|
|
274
|
+
groupPosition="single"
|
|
275
|
+
isMyMessage
|
|
276
|
+
message={message([
|
|
277
|
+
{
|
|
278
|
+
type: 'audio',
|
|
279
|
+
og_scrape_url:
|
|
280
|
+
'https://open.spotify.com/episode/61syKMXdpkEnkHr43ZsrG2',
|
|
281
|
+
asset_url: 'https://p.scdn.co/mp3-preview/abc123',
|
|
282
|
+
image_url: 'https://i.scdn.co/image/artwork.jpg',
|
|
283
|
+
title: 'The Lazarus Heist S1: Trailer',
|
|
284
|
+
text: 'Cyber Hack · Episode',
|
|
285
|
+
},
|
|
286
|
+
])}
|
|
287
|
+
/>
|
|
288
|
+
)
|
|
289
|
+
|
|
290
|
+
expect(
|
|
291
|
+
screen.getByRole('link', { name: /lazarus heist/i })
|
|
292
|
+
).toHaveAttribute(
|
|
293
|
+
'href',
|
|
294
|
+
'https://open.spotify.com/episode/61syKMXdpkEnkHr43ZsrG2'
|
|
295
|
+
)
|
|
296
|
+
expect(screen.getByRole('img', { name: /lazarus heist/i })).toBeVisible()
|
|
297
|
+
expect(screen.queryByTestId('audio-attachment')).toBeNull()
|
|
298
|
+
})
|
|
299
|
+
|
|
269
300
|
it('renders the accompanying message text next to a media attachment', () => {
|
|
270
301
|
renderWithProviders(
|
|
271
302
|
<StreamAttachmentMessage
|
|
@@ -2,9 +2,11 @@ import type { Attachment } from 'stream-chat'
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* True when an attachment is a link preview (OG card) rather than media:
|
|
5
|
-
* either Stream's native `link` type, or a non-empty (trimmed) `og_scrape_url
|
|
6
|
-
*
|
|
5
|
+
* either Stream's native `link` type, or a non-empty (trimmed) `og_scrape_url`.
|
|
6
|
+
* A whitespace-only `og_scrape_url` is not a link. Only enrichment sets
|
|
7
|
+
* `og_scrape_url`, so it stays authoritative even when the scrape also filled
|
|
8
|
+
* `asset_url` with a preview clip (Spotify).
|
|
7
9
|
*/
|
|
8
10
|
export function isLinkAttachment(a: Attachment): boolean {
|
|
9
|
-
return a.type === 'link' ||
|
|
11
|
+
return a.type === 'link' || !!a.og_scrape_url?.trim()
|
|
10
12
|
}
|
|
@@ -18,10 +18,22 @@ describe('isLinkAttachment', () => {
|
|
|
18
18
|
expect(isLinkAttachment({ og_scrape_url: ' ' } as Attachment)).toBe(false)
|
|
19
19
|
})
|
|
20
20
|
|
|
21
|
-
it('is
|
|
21
|
+
it('is true for a scraped page whose og:audio preview typed it as audio', () => {
|
|
22
|
+
// Spotify: the clip lands in `asset_url`, but it's still a link (MES-1359).
|
|
22
23
|
expect(
|
|
23
24
|
isLinkAttachment({
|
|
24
|
-
|
|
25
|
+
type: 'audio',
|
|
26
|
+
og_scrape_url:
|
|
27
|
+
'https://open.spotify.com/episode/61syKMXdpkEnkHr43ZsrG2',
|
|
28
|
+
asset_url: 'https://p.scdn.co/mp3-preview/abc123',
|
|
29
|
+
} as Attachment)
|
|
30
|
+
).toBe(true)
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
it('is false for uploaded media, which never carries an og_scrape_url', () => {
|
|
34
|
+
expect(
|
|
35
|
+
isLinkAttachment({
|
|
36
|
+
type: 'video',
|
|
25
37
|
asset_url: 'https://cdn.example.com/file.mp4',
|
|
26
38
|
} as Attachment)
|
|
27
39
|
).toBe(false)
|