stream-chat-react 12.5.1 → 12.6.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.
Files changed (41) hide show
  1. package/dist/assets/icons/stream-chat-icons.eot +0 -0
  2. package/dist/assets/icons/stream-chat-icons.svg +2 -2
  3. package/dist/assets/icons/stream-chat-icons.ttf +0 -0
  4. package/dist/assets/icons/stream-chat-icons.woff +0 -0
  5. package/dist/assets/icons/stream-chat-icons.woff2 +0 -0
  6. package/dist/components/Avatar/Avatar.d.ts +3 -3
  7. package/dist/components/Avatar/ChannelAvatar.d.ts +5 -0
  8. package/dist/components/Avatar/ChannelAvatar.js +8 -0
  9. package/dist/components/Avatar/GroupAvatar.d.ts +8 -0
  10. package/dist/components/Avatar/GroupAvatar.js +6 -0
  11. package/dist/components/Avatar/index.d.ts +2 -0
  12. package/dist/components/Avatar/index.js +2 -0
  13. package/dist/components/ChannelHeader/ChannelHeader.d.ts +3 -3
  14. package/dist/components/ChannelHeader/ChannelHeader.js +2 -2
  15. package/dist/components/ChannelList/ChannelList.d.ts +3 -3
  16. package/dist/components/ChannelList/ChannelList.js +1 -1
  17. package/dist/components/ChannelPreview/ChannelPreview.d.ts +6 -3
  18. package/dist/components/ChannelPreview/ChannelPreview.js +4 -2
  19. package/dist/components/ChannelPreview/ChannelPreviewMessenger.js +2 -2
  20. package/dist/components/ChannelPreview/hooks/useChannelPreviewInfo.d.ts +1 -0
  21. package/dist/components/ChannelPreview/hooks/useChannelPreviewInfo.js +10 -6
  22. package/dist/components/ChannelPreview/utils.d.ts +5 -0
  23. package/dist/components/ChannelPreview/utils.js +15 -0
  24. package/dist/components/ChatAutoComplete/ChatAutoComplete.d.ts +2 -2
  25. package/dist/components/Message/utils.d.ts +1 -1
  26. package/dist/components/Message/utils.js +2 -1
  27. package/dist/css/v2/index.css +2 -2
  28. package/dist/css/v2/index.layout.css +2 -2
  29. package/dist/experimental/index.browser.cjs.map +1 -1
  30. package/dist/experimental/index.node.cjs.map +1 -1
  31. package/dist/index.browser.cjs +1450 -1375
  32. package/dist/index.browser.cjs.map +4 -4
  33. package/dist/index.node.cjs +1366 -1288
  34. package/dist/index.node.cjs.map +4 -4
  35. package/dist/scss/v2/AttachmentList/AttachmentList-layout.scss +28 -2
  36. package/dist/scss/v2/AttachmentList/AttachmentList-theme.scss +9 -1
  37. package/dist/scss/v2/Avatar/Avatar-layout.scss +48 -0
  38. package/dist/scss/v2/Avatar/Avatar-theme.scss +5 -0
  39. package/dist/scss/v2/Icon/Icon-layout.scss +1 -1
  40. package/dist/types/types.d.ts +1 -0
  41. package/package.json +4 -4
@@ -26,8 +26,6 @@
26
26
 
27
27
  <glyph glyph-name="delivered" unicode="&#xe809;" d="M375 175l-175 175-58-58 233-234 500 500-58 59-442-442z" horiz-adv-x="1000" />
28
28
 
29
- <glyph glyph-name="play" unicode="&#xe80a;" d="M271 642v-584l458 292-458 292z" horiz-adv-x="1000" />
30
-
31
29
  <glyph glyph-name="reaction" unicode="&#xe80b;" d="M500 767c-230 0-417-187-417-417 0-230 187-417 417-417 230 0 417 187 417 417 0 230-187 417-417 417z m0-750c-184 0-333 149-333 333 0 184 149 333 333 333 184 0 333-149 333-333 0-184-149-333-333-333z m146 375c34 0 62 28 62 62 0 35-28 63-62 63-35 0-63-28-63-63 0-34 28-62 63-62z m-292 0c35 0 63 28 63 62 0 35-28 63-63 63-34 0-62-28-62-63 0-34 28-62 62-62z m146-271c97 0 180 61 213 146h-426c33-85 116-146 213-146z" horiz-adv-x="1000" />
32
30
 
33
31
  <glyph glyph-name="error" unicode="&#xe80c;" d="M500 767c-230 0-417-187-417-417 0-230 187-417 417-417 230 0 417 187 417 417 0 230-187 417-417 417z m42-625h-84v83h84v-83z m0 166h-84v250h84v-250z" horiz-adv-x="1000" />
@@ -45,6 +43,8 @@
45
43
  <glyph glyph-name="mic" unicode="&#xe812;" d="M350 225c83 0 150 67 150 150v300c0 83-67 150-150 150-83 0-150-67-150-150v-300c0-83 67-150 150-150z m250 150c0-138-112-250-250-250-138 0-250 112-250 250h-100c0-176 131-321 300-346v-154h100v154c170 25 300 170 300 346h-100z" horiz-adv-x="700" />
46
44
 
47
45
  <glyph glyph-name="bin" unicode="&#xe813;" d="M250 58c0-45 38-83 83-83h334c46 0 83 38 83 83v417c0 46-37 83-83 83h-334c-45 0-83-37-83-83v-417z m500 625h-104l-30 30c-7 7-18 12-29 12h-174c-11 0-22-5-29-12l-30-30h-104c-23 0-42-18-42-41 0-23 19-42 42-42h500c23 0 42 19 42 42 0 23-19 41-42 41z" horiz-adv-x="1000" />
46
+
47
+ <glyph glyph-name="play" unicode="&#xe814;" d="M398 640c-28 19-65-1-65-34v-511c0-34 37-54 65-35l383 255c25 17 25 53 0 70l-383 255z" horiz-adv-x="1000" />
48
48
  </font>
49
49
  </defs>
50
50
  </svg>
@@ -2,15 +2,15 @@ import React from 'react';
2
2
  import type { UserResponse } from 'stream-chat';
3
3
  import type { DefaultStreamChatGenerics } from '../../types/types';
4
4
  export type AvatarProps<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = {
5
- /** Custom class that will be merged with the default class */
5
+ /** Custom root element class that will be merged with the default class */
6
6
  className?: string;
7
7
  /** Image URL or default is an image of the first initial of the name if there is one */
8
8
  image?: string | null;
9
9
  /** Name of the image, used for title tag fallback */
10
10
  name?: string;
11
- /** click event handler */
11
+ /** click event handler attached to the component root element */
12
12
  onClick?: (event: React.BaseSyntheticEvent) => void;
13
- /** mouseOver event handler */
13
+ /** mouseOver event handler attached to the component root element */
14
14
  onMouseOver?: (event: React.BaseSyntheticEvent) => void;
15
15
  /** The entire user object for the chat user displayed in the component */
16
16
  user?: UserResponse<StreamChatGenerics>;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { AvatarProps, GroupAvatarProps } from './index';
3
+ import type { DefaultStreamChatGenerics } from '../../types';
4
+ export type ChannelAvatarProps<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = Partial<GroupAvatarProps> & AvatarProps<StreamChatGenerics>;
5
+ export declare const ChannelAvatar: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>({ groupChannelDisplayInfo, image, name, user, ...sharedProps }: ChannelAvatarProps<StreamChatGenerics>) => React.JSX.Element;
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { Avatar, GroupAvatar } from './index';
3
+ export const ChannelAvatar = ({ groupChannelDisplayInfo, image, name, user, ...sharedProps }) => {
4
+ if (groupChannelDisplayInfo) {
5
+ return React.createElement(GroupAvatar, { groupChannelDisplayInfo: groupChannelDisplayInfo, ...sharedProps });
6
+ }
7
+ return React.createElement(Avatar, { image: image, name: name, user: user, ...sharedProps });
8
+ };
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { AvatarProps } from './Avatar';
3
+ import { GroupChannelDisplayInfo } from '../ChannelPreview';
4
+ export type GroupAvatarProps = Pick<AvatarProps, 'className' | 'onClick' | 'onMouseOver'> & {
5
+ /** Mapping of image URLs to names which initials will be used as fallbacks in case image assets fail to load. */
6
+ groupChannelDisplayInfo: GroupChannelDisplayInfo;
7
+ };
8
+ export declare const GroupAvatar: ({ className, groupChannelDisplayInfo, onClick, onMouseOver, }: GroupAvatarProps) => React.JSX.Element;
@@ -0,0 +1,6 @@
1
+ import clsx from 'clsx';
2
+ import React from 'react';
3
+ import { Avatar } from './Avatar';
4
+ export const GroupAvatar = ({ className, groupChannelDisplayInfo, onClick, onMouseOver, }) => (React.createElement("div", { className: clsx(`str-chat__avatar-group`, { 'str-chat__avatar-group--three-part': groupChannelDisplayInfo.length === 3 }, className), "data-testid": 'group-avatar', onClick: onClick, onMouseOver: onMouseOver, role: 'button' }, groupChannelDisplayInfo.slice(0, 4).map(({ image, name }, i) => (React.createElement(Avatar, { className: clsx({
5
+ 'str-chat__avatar--single': groupChannelDisplayInfo.length === 3 && i === 0,
6
+ }), image: image, key: `${name}-${image}-${i}`, name: name })))));
@@ -1 +1,3 @@
1
1
  export * from './Avatar';
2
+ export * from './ChannelAvatar';
3
+ export * from './GroupAvatar';
@@ -1 +1,3 @@
1
1
  export * from './Avatar';
2
+ export * from './ChannelAvatar';
3
+ export * from './GroupAvatar';
@@ -1,9 +1,9 @@
1
1
  import React from 'react';
2
- import { AvatarProps } from '../Avatar';
2
+ import { ChannelAvatarProps } from '../Avatar';
3
3
  import type { DefaultStreamChatGenerics } from '../../types/types';
4
4
  export type ChannelHeaderProps = {
5
- /** UI component to display a user's avatar, defaults to and accepts same props as: [Avatar](https://github.com/GetStream/stream-chat-react/blob/master/src/components/Avatar/Avatar.tsx) */
6
- Avatar?: React.ComponentType<AvatarProps>;
5
+ /** UI component to display an avatar, defaults to [Avatar](https://github.com/GetStream/stream-chat-react/blob/master/src/components/Avatar/Avatar.tsx) component and accepts the same props as: [ChannelAvatar](https://github.com/GetStream/stream-chat-react/blob/master/src/components/Avatar/ChannelAvatar.tsx) */
6
+ Avatar?: React.ComponentType<ChannelAvatarProps>;
7
7
  /** Manually set the image to render, defaults to the Channel image */
8
8
  image?: string;
9
9
  /** Show a little indicator that the Channel is live right now */
@@ -13,7 +13,7 @@ export const ChannelHeader = (props) => {
13
13
  const { channel, watcher_count } = useChannelStateContext('ChannelHeader');
14
14
  const { openMobileNav } = useChatContext('ChannelHeader');
15
15
  const { t } = useTranslationContext('ChannelHeader');
16
- const { displayImage, displayTitle } = useChannelPreviewInfo({
16
+ const { displayImage, displayTitle, groupChannelDisplayInfo } = useChannelPreviewInfo({
17
17
  channel,
18
18
  overrideImage,
19
19
  overrideTitle,
@@ -22,7 +22,7 @@ export const ChannelHeader = (props) => {
22
22
  return (React.createElement("div", { className: 'str-chat__channel-header' },
23
23
  React.createElement("button", { "aria-label": t('aria/Menu'), className: 'str-chat__header-hamburger', onClick: openMobileNav },
24
24
  React.createElement(MenuIcon, null)),
25
- React.createElement(Avatar, { className: 'str-chat__avatar--channel-header', image: displayImage, name: displayTitle }),
25
+ React.createElement(Avatar, { className: 'str-chat__avatar--channel-header', groupChannelDisplayInfo: groupChannelDisplayInfo, image: displayImage, name: displayTitle }),
26
26
  React.createElement("div", { className: 'str-chat__channel-header-end' },
27
27
  React.createElement("p", { className: 'str-chat__channel-header-title' },
28
28
  displayTitle,
@@ -1,12 +1,12 @@
1
1
  import React from 'react';
2
2
  import { ChannelListMessengerProps } from './ChannelListMessenger';
3
3
  import { CustomQueryChannelsFn } from './hooks/usePaginatedChannels';
4
- import { AvatarProps } from '../Avatar/Avatar';
5
4
  import { ChannelPreviewUIComponentProps } from '../ChannelPreview/ChannelPreview';
6
5
  import { ChannelSearchProps } from '../ChannelSearch/ChannelSearch';
7
6
  import { EmptyStateIndicatorProps } from '../EmptyStateIndicator';
8
7
  import { LoadMorePaginatorProps } from '../LoadMore/LoadMorePaginator';
9
8
  import type { Channel, ChannelFilters, ChannelOptions, ChannelSort, Event } from 'stream-chat';
9
+ import type { ChannelAvatarProps } from '../Avatar';
10
10
  import type { TranslationContextValue } from '../../context/TranslationContext';
11
11
  import type { DefaultStreamChatGenerics, PaginatorProps } from '../../types/types';
12
12
  export type ChannelListProps<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = {
@@ -19,8 +19,8 @@ export type ChannelListProps<StreamChatGenerics extends DefaultStreamChatGeneric
19
19
  * to false, which will prevent channels not in the list from incrementing the list. The default is true.
20
20
  */
21
21
  allowNewMessagesFromUnfilteredChannels?: boolean;
22
- /** Custom UI component to display user avatar, defaults to and accepts same props as: [Avatar](https://github.com/GetStream/stream-chat-react/blob/master/src/components/Avatar/Avatar.tsx) */
23
- Avatar?: React.ComponentType<AvatarProps>;
22
+ /** UI component to display an avatar, defaults to [Avatar](https://github.com/GetStream/stream-chat-react/blob/master/src/components/Avatar/Avatar.tsx) component and accepts the same props as: [ChannelAvatar](https://github.com/GetStream/stream-chat-react/blob/master/src/components/Avatar/ChannelAvatar.tsx) */
23
+ Avatar?: React.ComponentType<ChannelAvatarProps>;
24
24
  /** Optional function to filter channels prior to loading in the DOM. Do not use any complex or async logic that would delay the loading of the ChannelList. We recommend using a pure function with array methods like filter/sort/reduce. */
25
25
  channelRenderFilterFn?: (channels: Array<Channel<StreamChatGenerics>>) => Array<Channel<StreamChatGenerics>>;
26
26
  /** Custom UI component to display search results, defaults to and accepts same props as: [ChannelSearch](https://github.com/GetStream/stream-chat-react/blob/master/src/components/ChannelSearch/ChannelSearch.tsx) */
@@ -15,7 +15,7 @@ import { useNotificationRemovedFromChannelListener } from './hooks/useNotificati
15
15
  import { usePaginatedChannels } from './hooks/usePaginatedChannels';
16
16
  import { useUserPresenceChangedListener } from './hooks/useUserPresenceChangedListener';
17
17
  import { MAX_QUERY_CHANNELS_LIMIT, moveChannelUp } from './utils';
18
- import { Avatar as DefaultAvatar } from '../Avatar/Avatar';
18
+ import { Avatar as DefaultAvatar } from '../Avatar';
19
19
  import { ChannelPreview } from '../ChannelPreview/ChannelPreview';
20
20
  import { ChannelSearch as DefaultChannelSearch, } from '../ChannelSearch/ChannelSearch';
21
21
  import { EmptyStateIndicator as DefaultEmptyStateIndicator, } from '../EmptyStateIndicator';
@@ -2,7 +2,8 @@ import React from 'react';
2
2
  import { ChatContextValue } from '../../context/ChatContext';
3
3
  import { MessageDeliveryStatus } from './hooks/useMessageDeliveryStatus';
4
4
  import type { Channel } from 'stream-chat';
5
- import type { AvatarProps } from '../Avatar/Avatar';
5
+ import type { ChannelAvatarProps } from '../Avatar/ChannelAvatar';
6
+ import type { GroupChannelDisplayInfo } from './utils';
6
7
  import type { StreamMessage } from '../../context/ChannelStateContext';
7
8
  import type { TranslationContextValue } from '../../context/TranslationContext';
8
9
  import type { DefaultStreamChatGenerics } from '../../types/types';
@@ -13,6 +14,8 @@ export type ChannelPreviewUIComponentProps<StreamChatGenerics extends DefaultStr
13
14
  displayImage?: string;
14
15
  /** Title of Channel to display */
15
16
  displayTitle?: string;
17
+ /** Title of Channel to display */
18
+ groupChannelDisplayInfo?: GroupChannelDisplayInfo;
16
19
  /** The last message received in a channel */
17
20
  lastMessage?: StreamMessage<StreamChatGenerics>;
18
21
  /** @deprecated Use latestMessagePreview prop instead. */
@@ -29,8 +32,8 @@ export type ChannelPreviewProps<StreamChatGenerics extends DefaultStreamChatGene
29
32
  channel: Channel<StreamChatGenerics>;
30
33
  /** Current selected channel object */
31
34
  activeChannel?: Channel<StreamChatGenerics>;
32
- /** Custom UI component to display user avatar, defaults to and accepts same props as: [Avatar](https://github.com/GetStream/stream-chat-react/blob/master/src/components/Avatar/Avatar.tsx) */
33
- Avatar?: React.ComponentType<AvatarProps>;
35
+ /** UI component to display an avatar, defaults to [Avatar](https://github.com/GetStream/stream-chat-react/blob/master/src/components/Avatar/Avatar.tsx) component and accepts the same props as: [ChannelAvatar](https://github.com/GetStream/stream-chat-react/blob/master/src/components/Avatar/ChannelAvatar.tsx) */
36
+ Avatar?: React.ComponentType<ChannelAvatarProps<StreamChatGenerics>>;
34
37
  /** Forces the update of preview component on channel update */
35
38
  channelUpdateCount?: number;
36
39
  /** Custom class for the channel preview root */
@@ -11,7 +11,9 @@ export const ChannelPreview = (props) => {
11
11
  const { channel, Preview = ChannelPreviewMessenger, channelUpdateCount, getLatestMessagePreview = defaultGetLatestMessagePreview, } = props;
12
12
  const { channel: activeChannel, client, setActiveChannel } = useChatContext('ChannelPreview');
13
13
  const { t, userLanguage } = useTranslationContext('ChannelPreview');
14
- const { displayImage, displayTitle } = useChannelPreviewInfo({ channel });
14
+ const { displayImage, displayTitle, groupChannelDisplayInfo } = useChannelPreviewInfo({
15
+ channel,
16
+ });
15
17
  const [lastMessage, setLastMessage] = useState(channel.state.messages[channel.state.messages.length - 1]);
16
18
  const [unread, setUnread] = useState(0);
17
19
  const { messageDeliveryStatus } = useMessageDeliveryStatus({
@@ -74,5 +76,5 @@ export const ChannelPreview = (props) => {
74
76
  if (!Preview)
75
77
  return null;
76
78
  const latestMessagePreview = getLatestMessagePreview(channel, t, userLanguage);
77
- return (React.createElement(Preview, { ...props, active: isActive, displayImage: displayImage, displayTitle: displayTitle, lastMessage: lastMessage, latestMessage: latestMessagePreview, latestMessagePreview: latestMessagePreview, messageDeliveryStatus: messageDeliveryStatus, setActiveChannel: setActiveChannel, unread: unread }));
79
+ return (React.createElement(Preview, { ...props, active: isActive, displayImage: displayImage, displayTitle: displayTitle, groupChannelDisplayInfo: groupChannelDisplayInfo, lastMessage: lastMessage, latestMessage: latestMessagePreview, latestMessagePreview: latestMessagePreview, messageDeliveryStatus: messageDeliveryStatus, setActiveChannel: setActiveChannel, unread: unread }));
78
80
  };
@@ -2,7 +2,7 @@ import React, { useRef } from 'react';
2
2
  import clsx from 'clsx';
3
3
  import { Avatar as DefaultAvatar } from '../Avatar';
4
4
  const UnMemoizedChannelPreviewMessenger = (props) => {
5
- const { active, Avatar = DefaultAvatar, channel, className: customClassName = '', displayImage, displayTitle, latestMessagePreview, onSelect: customOnSelectChannel, setActiveChannel, unread, watchers, } = props;
5
+ const { active, Avatar = DefaultAvatar, channel, className: customClassName = '', displayImage, displayTitle, groupChannelDisplayInfo, latestMessagePreview, onSelect: customOnSelectChannel, setActiveChannel, unread, watchers, } = props;
6
6
  const channelPreviewButton = useRef(null);
7
7
  const avatarName = displayTitle || channel.state.messages[channel.state.messages.length - 1]?.user?.id;
8
8
  const onSelectChannel = (e) => {
@@ -18,7 +18,7 @@ const UnMemoizedChannelPreviewMessenger = (props) => {
18
18
  };
19
19
  return (React.createElement("button", { "aria-label": `Select Channel: ${displayTitle || ''}`, "aria-selected": active, className: clsx(`str-chat__channel-preview-messenger str-chat__channel-preview`, active && 'str-chat__channel-preview-messenger--active', unread && unread >= 1 && 'str-chat__channel-preview-messenger--unread', customClassName), "data-testid": 'channel-preview-button', onClick: onSelectChannel, ref: channelPreviewButton, role: 'option' },
20
20
  React.createElement("div", { className: 'str-chat__channel-preview-messenger--left' },
21
- React.createElement(Avatar, { className: 'str-chat__avatar--channel-preview', image: displayImage, name: avatarName })),
21
+ React.createElement(Avatar, { className: 'str-chat__avatar--channel-preview', groupChannelDisplayInfo: groupChannelDisplayInfo, image: displayImage, name: avatarName })),
22
22
  React.createElement("div", { className: 'str-chat__channel-preview-end' },
23
23
  React.createElement("div", { className: 'str-chat__channel-preview-end-first-row' },
24
24
  React.createElement("div", { className: 'str-chat__channel-preview-messenger--name' },
@@ -10,4 +10,5 @@ export type ChannelPreviewInfoParams<StreamChatGenerics extends DefaultStreamCha
10
10
  export declare const useChannelPreviewInfo: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>(props: ChannelPreviewInfoParams<StreamChatGenerics>) => {
11
11
  displayImage: string | undefined;
12
12
  displayTitle: string | undefined;
13
+ groupChannelDisplayInfo: import("../utils").GroupChannelDisplayInfo | undefined;
13
14
  };
@@ -1,28 +1,32 @@
1
1
  import { useEffect, useState } from 'react';
2
- import { getDisplayImage, getDisplayTitle } from '../utils';
2
+ import { getDisplayImage, getDisplayTitle, getGroupChannelDisplayInfo } from '../utils';
3
3
  import { useChatContext } from '../../../context';
4
4
  export const useChannelPreviewInfo = (props) => {
5
5
  const { channel, overrideImage, overrideTitle } = props;
6
6
  const { client } = useChatContext('useChannelPreviewInfo');
7
7
  const [displayTitle, setDisplayTitle] = useState(() => overrideTitle || getDisplayTitle(channel, client.user));
8
8
  const [displayImage, setDisplayImage] = useState(() => overrideImage || getDisplayImage(channel, client.user));
9
+ const [groupChannelDisplayInfo, setGroupDisplayChannelInfo] = useState(() => getGroupChannelDisplayInfo(channel));
9
10
  useEffect(() => {
10
11
  if (overrideTitle && overrideImage)
11
12
  return;
12
- const updateTitles = () => {
13
+ const updateInfo = () => {
13
14
  if (!overrideTitle)
14
15
  setDisplayTitle(getDisplayTitle(channel, client.user));
15
- if (!overrideImage)
16
+ if (!overrideImage) {
16
17
  setDisplayImage(getDisplayImage(channel, client.user));
18
+ setGroupDisplayChannelInfo(getGroupChannelDisplayInfo(channel));
19
+ }
17
20
  };
18
- updateTitles();
19
- client.on('user.updated', updateTitles);
21
+ updateInfo();
22
+ client.on('user.updated', updateInfo);
20
23
  return () => {
21
- client.off('user.updated', updateTitles);
24
+ client.off('user.updated', updateInfo);
22
25
  };
23
26
  }, [channel, channel.data, client, overrideImage, overrideTitle]);
24
27
  return {
25
28
  displayImage: overrideImage || displayImage,
26
29
  displayTitle: overrideTitle || displayTitle,
30
+ groupChannelDisplayInfo,
27
31
  };
28
32
  };
@@ -4,5 +4,10 @@ import type { TranslationContextValue } from '../../context/TranslationContext';
4
4
  import type { DefaultStreamChatGenerics } from '../../types/types';
5
5
  export declare const renderPreviewText: (text: string) => React.JSX.Element;
6
6
  export declare const getLatestMessagePreview: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>(channel: Channel<StreamChatGenerics>, t: TranslationContextValue['t'], userLanguage?: TranslationContextValue['userLanguage']) => string | JSX.Element;
7
+ export type GroupChannelDisplayInfo = {
8
+ image?: string;
9
+ name?: string;
10
+ }[];
11
+ export declare const getGroupChannelDisplayInfo: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>(channel: Channel<StreamChatGenerics>) => GroupChannelDisplayInfo | undefined;
7
12
  export declare const getDisplayTitle: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>(channel: Channel<StreamChatGenerics>, currentUser?: UserResponse<StreamChatGenerics>) => string | undefined;
8
13
  export declare const getDisplayImage: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>(channel: Channel<StreamChatGenerics>, currentUser?: UserResponse<StreamChatGenerics>) => string | undefined;
@@ -57,6 +57,21 @@ export const getLatestMessagePreview = (channel, t, userLanguage = 'en') => {
57
57
  }
58
58
  return t('Empty message...');
59
59
  };
60
+ export const getGroupChannelDisplayInfo = (channel) => {
61
+ const members = Object.values(channel.state.members);
62
+ if (members.length <= 2)
63
+ return;
64
+ const info = [];
65
+ for (let i = 0; i < members.length; i++) {
66
+ const { user } = members[i];
67
+ if (!user?.name && !user?.image)
68
+ continue;
69
+ info.push({ image: user.image, name: user.name });
70
+ if (info.length === 4)
71
+ break;
72
+ }
73
+ return info;
74
+ };
60
75
  const getChannelDisplayInfo = (info, channel, currentUser) => {
61
76
  if (channel.data?.[info])
62
77
  return channel.data[info];
@@ -2,11 +2,11 @@ import React from 'react';
2
2
  import type { CommandResponse, UserResponse } from 'stream-chat';
3
3
  import type { TriggerSettings } from '../MessageInput/DefaultTriggerProvider';
4
4
  import type { CustomTrigger, DefaultStreamChatGenerics, UnknownType } from '../../types/types';
5
- import type { EmojiSearchIndex } from '../MessageInput';
5
+ import { EmojiSearchIndex, EmojiSearchIndexResult } from '../MessageInput';
6
6
  type ObjectUnion<T> = T[keyof T];
7
7
  export type SuggestionCommand<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = CommandResponse<StreamChatGenerics>;
8
8
  export type SuggestionUser<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = UserResponse<StreamChatGenerics>;
9
- export type SuggestionEmoji<T extends UnknownType = UnknownType> = Awaited<ReturnType<EmojiSearchIndex<T>['search']>>;
9
+ export type SuggestionEmoji<T extends UnknownType = UnknownType> = EmojiSearchIndexResult & T;
10
10
  export type SuggestionItem<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics, T extends UnknownType = UnknownType> = SuggestionUser<StreamChatGenerics> | SuggestionCommand<StreamChatGenerics> | SuggestionEmoji<T>;
11
11
  export type SuggestionItemProps<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics, T extends UnknownType = UnknownType> = {
12
12
  className: string;
@@ -76,5 +76,5 @@ export interface TooltipUsernameMapper {
76
76
  export declare const mapToUserNameOrId: TooltipUsernameMapper;
77
77
  export declare const getReadByTooltipText: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>(users: UserResponse<StreamChatGenerics>[], t: TFunction, client: StreamChat<StreamChatGenerics>, tooltipUserNameMapper: TooltipUsernameMapper) => string;
78
78
  export declare const isOnlyEmojis: (text?: string) => boolean;
79
- export declare const isMessageBounced: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>(message: Pick<StreamMessage<StreamChatGenerics>, 'type' | 'moderation_details'>) => boolean;
79
+ export declare const isMessageBounced: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>(message: Pick<StreamMessage<StreamChatGenerics>, 'type' | 'moderation' | 'moderation_details'>) => boolean;
80
80
  export declare const isMessageEdited: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>(message: Pick<StreamMessage<StreamChatGenerics>, 'message_text_updated_at'>) => boolean;
@@ -308,5 +308,6 @@ export const isOnlyEmojis = (text) => {
308
308
  return !noSpace;
309
309
  };
310
310
  export const isMessageBounced = (message) => message.type === 'error' &&
311
- message.moderation_details?.action === 'MESSAGE_RESPONSE_ACTION_BOUNCE';
311
+ (message.moderation_details?.action === 'MESSAGE_RESPONSE_ACTION_BOUNCE' ||
312
+ message.moderation?.action === 'bounce');
312
313
  export const isMessageEdited = (message) => !!message.message_text_updated_at;