@linktr.ee/messaging-react 4.4.4 → 4.4.5-rc-1788226564

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": "4.4.4",
3
+ "version": "4.4.5-rc-1788226564",
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": "^2.6.0",
54
- "@linktr.ee/messaging-taxonomy": "^0.11.0",
53
+ "@linktr.ee/messaging-core": "2.6.0-rc-1788226564",
54
+ "@linktr.ee/messaging-taxonomy": "0.11.0-rc-1788226564",
55
55
  "@phosphor-icons/react": "^2.1.10"
56
56
  },
57
57
  "devDependencies": {
@@ -49,6 +49,19 @@ describe('linkCardPropsFromStreamAttachment', () => {
49
49
  ).toBe('classic')
50
50
  })
51
51
 
52
+ it('drops the audio clip when artwork exists so the card keeps its link', () => {
53
+ expect(
54
+ linkCardPropsFromStreamAttachment({
55
+ type: 'audio',
56
+ og_scrape_url:
57
+ 'https://open.spotify.com/episode/61syKMXdpkEnkHr43ZsrG2',
58
+ asset_url: 'https://p.scdn.co/mp3-preview/abc123',
59
+ image_url: 'https://i.scdn.co/image/artwork.jpg',
60
+ mime_type: 'audio/mpeg',
61
+ }).sourceUrl
62
+ ).toBeUndefined()
63
+ })
64
+
52
65
  it('keeps the featured layout for a playable clip with no thumbnail so the player renders', () => {
53
66
  expect(
54
67
  linkCardPropsFromStreamAttachment({
@@ -266,6 +279,39 @@ describe('StreamAttachmentMessage', () => {
266
279
  )
267
280
  })
268
281
 
282
+ it('renders a scraped page typed audio by its og:audio preview as a link card', () => {
283
+ // Spotify episode: enrichment types it `audio` and puts the 30s clip in
284
+ // `asset_url`, but the shared thing is still a link (MES-1359).
285
+ renderWithProviders(
286
+ <StreamAttachmentMessage
287
+ groupPosition="single"
288
+ isMyMessage
289
+ message={message([
290
+ {
291
+ type: 'audio',
292
+ og_scrape_url:
293
+ 'https://open.spotify.com/episode/61syKMXdpkEnkHr43ZsrG2',
294
+ asset_url: 'https://p.scdn.co/mp3-preview/abc123',
295
+ image_url: 'https://i.scdn.co/image/artwork.jpg',
296
+ mime_type: 'audio/mpeg',
297
+ title: 'The Lazarus Heist S1: Trailer',
298
+ text: 'Cyber Hack · Episode',
299
+ },
300
+ ])}
301
+ />
302
+ )
303
+
304
+ expect(
305
+ screen.getByRole('link', { name: /lazarus heist/i })
306
+ ).toHaveAttribute(
307
+ 'href',
308
+ 'https://open.spotify.com/episode/61syKMXdpkEnkHr43ZsrG2'
309
+ )
310
+ expect(screen.getByRole('img', { name: /lazarus heist/i })).toBeVisible()
311
+ expect(screen.queryByTestId('audio-attachment')).toBeNull()
312
+ expect(screen.queryByTestId('card-thumbnail-audio')).toBeNull()
313
+ })
314
+
269
315
  it('renders the accompanying message text next to a media attachment', () => {
270
316
  renderWithProviders(
271
317
  <StreamAttachmentMessage
@@ -9,7 +9,10 @@ import {
9
9
 
10
10
  import { optimizeMessagingAttachmentUrl } from '../../utils/cdnImageUrl'
11
11
  import LinkAttachment from '../LinkAttachment'
12
- import { isPlayableMedia } from '../LinkAttachment/components/_shared/CardThumbnail'
12
+ import {
13
+ isPlayableAudio,
14
+ isPlayableMedia,
15
+ } from '../LinkAttachment/components/_shared/CardThumbnail'
13
16
  import { isLinkAttachment } from '../MediaMessage'
14
17
  import MessageAttachment from '../MessageAttachment'
15
18
  import type { BubbleGroupPosition } from '../MessageAttachment/types'
@@ -85,8 +88,13 @@ export function linkCardPropsFromStreamAttachment(a: Attachment) {
85
88
  const thumbnailUrl =
86
89
  trimToUndefined((a as { image_url?: string }).image_url) ??
87
90
  trimToUndefined((a as { thumb_url?: string }).thumb_url)
88
- const sourceUrl = trimToUndefined(a.asset_url)
89
91
  const mimeType = trimToUndefined(a.mime_type)
92
+ const assetUrl = trimToUndefined(a.asset_url)
93
+ // The audio hero replaces the artwork *and* the card's own link with a bare
94
+ // player, so a scraped page that has artwork (Spotify) keeps the artwork and
95
+ // stays navigable; a thumbnail-less clip still plays (MES-947).
96
+ const sourceUrl =
97
+ thumbnailUrl && isPlayableAudio(mimeType, assetUrl) ? undefined : assetUrl
90
98
 
91
99
  return {
92
100
  title: trimToUndefined((a as { title?: string }).title),
@@ -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
- * with no `asset_url`. A whitespace-only `og_scrape_url` is not a link.
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' || (!!a.og_scrape_url?.trim() && !a.asset_url)
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 false when og_scrape_url accompanies an asset_url (media, not a link)', () => {
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
- og_scrape_url: 'https://example.com',
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)