@linktr.ee/messaging-react 3.6.2-rc-1783311170 → 3.6.2-rc-1783314663

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.
Files changed (34) hide show
  1. package/dist/{Card-DnEyeR_d.js → Card-Byosl29s.js} +3 -3
  2. package/dist/{Card-DnEyeR_d.js.map → Card-Byosl29s.js.map} +1 -1
  3. package/dist/{Card-CK1jw1VU.cjs → Card-CLfoYI1R.cjs} +2 -2
  4. package/dist/{Card-CK1jw1VU.cjs.map → Card-CLfoYI1R.cjs.map} +1 -1
  5. package/dist/{Card-CSwQT3wz.cjs → Card-CSkWY9mH.cjs} +2 -2
  6. package/dist/{Card-CSwQT3wz.cjs.map → Card-CSkWY9mH.cjs.map} +1 -1
  7. package/dist/{Card-CJh6R76n.js → Card-CqEKHw9S.js} +2 -2
  8. package/dist/{Card-CJh6R76n.js.map → Card-CqEKHw9S.js.map} +1 -1
  9. package/dist/{Card-DUoHKAuh.js → Card-ILtY9lfF.js} +2 -2
  10. package/dist/{Card-DUoHKAuh.js.map → Card-ILtY9lfF.js.map} +1 -1
  11. package/dist/{Card-DQtg7wWP.cjs → Card-UN0QRlxk.cjs} +2 -2
  12. package/dist/{Card-DQtg7wWP.cjs.map → Card-UN0QRlxk.cjs.map} +1 -1
  13. package/dist/{LockedThumbnail-C_F2Sw-9.js → LockedThumbnail-BKI_6JUF.js} +2 -2
  14. package/dist/{LockedThumbnail-C_F2Sw-9.js.map → LockedThumbnail-BKI_6JUF.js.map} +1 -1
  15. package/dist/{LockedThumbnail-BZLpmTpY.cjs → LockedThumbnail-DZ6C2xsr.cjs} +2 -2
  16. package/dist/{LockedThumbnail-BZLpmTpY.cjs.map → LockedThumbnail-DZ6C2xsr.cjs.map} +1 -1
  17. package/dist/assets/index.css +1 -1
  18. package/dist/{index-DcEVHNS3.js → index-DPwo1avm.js} +682 -688
  19. package/dist/index-DPwo1avm.js.map +1 -0
  20. package/dist/index-Q0FmgUJF.cjs +2 -0
  21. package/dist/index-Q0FmgUJF.cjs.map +1 -0
  22. package/dist/index.cjs +1 -1
  23. package/dist/index.js +1 -1
  24. package/package.json +2 -2
  25. package/src/components/CustomMessage/CustomMessage.stories.tsx +18 -11
  26. package/src/components/CustomMessage/MessageDeliveryStatus.test.tsx +60 -0
  27. package/src/components/CustomMessage/MessageDeliveryStatus.tsx +43 -0
  28. package/src/components/CustomMessage/index.tsx +2 -9
  29. package/src/styles.css +16 -25
  30. package/dist/index-DcEVHNS3.js.map +0 -1
  31. package/dist/index-LP0PQJxl.cjs +0 -2
  32. package/dist/index-LP0PQJxl.cjs.map +0 -1
  33. package/src/components/CustomMessage/SentMessageDeliveryStatus.test.tsx +0 -83
  34. package/src/components/CustomMessage/SentMessageDeliveryStatus.tsx +0 -67
@@ -1,83 +0,0 @@
1
- import React from 'react'
2
- import { useMessageContext } from 'stream-chat-react'
3
- import { beforeEach, describe, expect, it, vi } from 'vitest'
4
-
5
- import { renderWithProviders, screen, within } from '../../test/utils'
6
-
7
- import { SentMessageDeliveryStatus } from './SentMessageDeliveryStatus'
8
-
9
- // stream-chat-react's `MessageStatus` owns the outer gating (own message, not
10
- // error, not in a thread) and the state machine — Stream's tested code. What
11
- // this component owns is the "Delivered" label wired into the terminal slots
12
- // (sent/delivered/read), its "last own message" self-gate, and suppressing
13
- // the sending spinner. Mock `MessageStatus` to render the slots it was handed,
14
- // and `useMessageContext` to feed the label's self-gate.
15
- vi.mock('stream-chat-react', () => ({
16
- useMessageContext: vi.fn(),
17
- MessageStatus: ({
18
- MessageSentStatus,
19
- MessageDeliveredStatus,
20
- MessageReadStatus,
21
- MessageSendingStatus,
22
- }: Record<string, React.ComponentType>) => (
23
- <div>
24
- <div data-testid="sent-slot">
25
- <MessageSentStatus />
26
- </div>
27
- <div data-testid="delivered-slot">
28
- <MessageDeliveredStatus />
29
- </div>
30
- <div data-testid="read-slot">
31
- <MessageReadStatus />
32
- </div>
33
- <div data-testid="sending-slot">
34
- <MessageSendingStatus />
35
- </div>
36
- </div>
37
- ),
38
- }))
39
-
40
- const mockedUseMessageContext = vi.mocked(useMessageContext)
41
-
42
- const TERMINAL_SLOTS = ['sent-slot', 'delivered-slot', 'read-slot'] as const
43
-
44
- describe('SentMessageDeliveryStatus', () => {
45
- beforeEach(() => {
46
- mockedUseMessageContext.mockReturnValue({
47
- lastOwnMessage: { id: 'message-1' },
48
- message: { id: 'message-1' },
49
- } as never)
50
- })
51
-
52
- it('renders "Delivered" in every terminal slot for the last own message', () => {
53
- // delivered/read fire ahead of sent in receipt channels, so all three
54
- // must show the label — never Stream's default delivered icon / read
55
- // avatars.
56
- renderWithProviders(<SentMessageDeliveryStatus />)
57
-
58
- for (const slot of TERMINAL_SLOTS) {
59
- expect(
60
- within(screen.getByTestId(slot)).getByText('Delivered')
61
- ).toBeInTheDocument()
62
- }
63
- })
64
-
65
- it('renders nothing in the terminal slots when it is not the last own message', () => {
66
- mockedUseMessageContext.mockReturnValue({
67
- lastOwnMessage: { id: 'message-2' },
68
- message: { id: 'message-1' },
69
- } as never)
70
-
71
- renderWithProviders(<SentMessageDeliveryStatus />)
72
-
73
- for (const slot of TERMINAL_SLOTS) {
74
- expect(screen.getByTestId(slot)).toBeEmptyDOMElement()
75
- }
76
- })
77
-
78
- it('always suppresses the sending spinner', () => {
79
- renderWithProviders(<SentMessageDeliveryStatus />)
80
-
81
- expect(screen.getByTestId('sending-slot')).toBeEmptyDOMElement()
82
- })
83
- })
@@ -1,67 +0,0 @@
1
- import { ChecksIcon } from '@phosphor-icons/react'
2
- import { MessageStatus, useMessageContext } from 'stream-chat-react'
3
-
4
- /**
5
- * "✓✓ Delivered" label, wired into *every* terminal `MessageStatus` state
6
- * (sent / delivered / read).
7
- *
8
- * `MessageStatus` picks its `delivered` and `read` branches ahead of `sent`
9
- * whenever Stream has `deliveredTo` / `readBy` for the message — and, unlike
10
- * `sent`, those branches are *not* gated to the last own message. So in a
11
- * channel that has receipts we must (a) replace Stream's default delivered
12
- * icon / read avatars with our label — otherwise the required "Delivered"
13
- * label disappears and an out-of-scope read receipt would show — and (b)
14
- * re-apply the "last own message only" gate ourselves, since the
15
- * delivered/read branches would otherwise render on every read own message.
16
- *
17
- * Rendered inside stream's `.str-chat__message-status` span, which supplies
18
- * the flex layout; icon and copy are styled via that span in `styles.css`.
19
- */
20
- const DeliveredStatus = () => {
21
- const { lastOwnMessage, message } = useMessageContext(
22
- 'SentMessageDeliveryStatus'
23
- )
24
-
25
- if (lastOwnMessage?.id !== message.id) {
26
- return null
27
- }
28
-
29
- return (
30
- <>
31
- <ChecksIcon weight="bold" aria-hidden="true" />
32
- <span data-testid="sent-message-delivery-status">Delivered</span>
33
- </>
34
- )
35
- }
36
-
37
- /** Suppresses a MessageStatus slot we don't want to render. */
38
- const NoStatus = () => null
39
-
40
- /**
41
- * Delivery status beneath the viewer's most recent sent message (MES-1036):
42
- * a right-aligned "✓✓ Delivered" that appears once Stream confirms the
43
- * message is stored and updates live.
44
- *
45
- * Built on stream-chat-react's `MessageStatus`, which owns the gating we want
46
- * — own message, not an error, and not inside a thread — plus the
47
- * sending/sent/delivered/read state machine.
48
- *
49
- * Scope is "Delivered" only (no Sending / Read). Stream's `sent` state maps
50
- * to "Delivered" for a backend-confirmed (`status === 'received'`) last own
51
- * message; its `delivered`/`read` states (only populated in channels with
52
- * per-recipient receipts) also render the same "Delivered" label via
53
- * {@link DeliveredStatus} so we never surface a read receipt. The sending
54
- * spinner is suppressed.
55
- *
56
- * `DeliveredStatus` reads `lastOwnMessage` from the message context, so
57
- * `CustomMessage`'s memo comparator must re-render when it changes (see
58
- * `index.tsx`) for the label to hop to a newer message.
59
- */
60
- export const SentMessageDeliveryStatus = () => (
61
- <MessageStatus
62
- MessageSentStatus={DeliveredStatus}
63
- MessageDeliveredStatus={DeliveredStatus}
64
- MessageReadStatus={DeliveredStatus}
65
- MessageSendingStatus={NoStatus}
66
- />
67
- )