stream-chat-react 13.6.3 → 13.6.5

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.
@@ -24,7 +24,7 @@ export const useChat = ({ client, defaultLanguage = 'en', i18nInstance, initialN
24
24
  useEffect(() => {
25
25
  if (!client)
26
26
  return;
27
- const version = "13.6.3";
27
+ const version = "13.6.5";
28
28
  const userAgent = client.getUserAgent();
29
29
  if (!userAgent.includes('stream-chat-react')) {
30
30
  // result looks like: 'stream-chat-react-2.3.2-stream-chat-javascript-client-browser-2.2.2'
@@ -10,8 +10,13 @@ const UnMemoizedMessageOptions = (props) => {
10
10
  const { ActionsIcon = DefaultActionsIcon, displayReplies = true, handleOpenThread: propHandleOpenThread, ReactionIcon = DefaultReactionIcon, theme = 'simple', ThreadIcon = DefaultThreadIcon, } = props;
11
11
  const { getMessageActions, handleOpenThread: contextHandleOpenThread, initialMessage, message, threadList, } = useMessageContext('MessageOptions');
12
12
  const { t } = useTranslationContext('MessageOptions');
13
- const messageActionsDialogIsOpen = useDialogIsOpen(`message-actions--${message.id}`);
14
- const reactionSelectorDialogIsOpen = useDialogIsOpen(`reaction-selector--${message.id}`);
13
+ // It is necessary to namespace the dialog IDs because a message with the same ID
14
+ // can appear in the main message list as well as in the thread message list.
15
+ // Without the namespace, the search for dialog would be performed by the message ID only
16
+ // which could return the dialog for a message in another message list (which would not be rendered).
17
+ const dialogIdNamespace = threadList ? '-thread-' : '';
18
+ const messageActionsDialogIsOpen = useDialogIsOpen(`message-actions${dialogIdNamespace}--${message.id}`);
19
+ const reactionSelectorDialogIsOpen = useDialogIsOpen(`reaction-selector${dialogIdNamespace}--${message.id}`);
15
20
  const handleOpenThread = propHandleOpenThread || contextHandleOpenThread;
16
21
  const messageActions = getMessageActions();
17
22
  const shouldShowReactions = messageActions.indexOf(MESSAGE_ACTIONS.react) > -1;
@@ -22,7 +22,8 @@ export const MessageActions = (props) => {
22
22
  const message = propMessage || contextMessage;
23
23
  const isMine = mine ? mine() : isMyMessage();
24
24
  const isMuted = useCallback(() => isUserMuted(message, mutes), [message, mutes]);
25
- const dialogId = `message-actions--${message.id}`;
25
+ const dialogIdNamespace = threadList ? '-thread-' : '';
26
+ const dialogId = `message-actions${dialogIdNamespace}--${message.id}`;
26
27
  const dialog = useDialog({ id: dialogId });
27
28
  const dialogIsOpen = useDialogIsOpen(dialogId);
28
29
  const messageActions = getMessageActions();
@@ -88,14 +88,17 @@ const useAttachmentSelectorActionsFiltered = (original) => {
88
88
  const { PollCreationDialog = DefaultPollCreationDialog, ShareLocationDialog = DefaultLocationDialog, } = useComponentContext();
89
89
  const { channelCapabilities } = useChannelStateContext();
90
90
  const messageComposer = useMessageComposer();
91
+ const channelConfig = messageComposer.channel.getConfig();
91
92
  return original
92
93
  .filter((action) => {
93
94
  if (action.type === 'uploadFile')
94
- return channelCapabilities['upload-file'];
95
+ return channelCapabilities['upload-file'] && channelConfig?.uploads;
95
96
  if (action.type === 'createPoll')
96
- return channelCapabilities['send-poll'] && !messageComposer.threadId;
97
+ return (channelCapabilities['send-poll'] &&
98
+ !messageComposer.threadId &&
99
+ channelConfig?.polls);
97
100
  if (action.type === 'addLocation') {
98
- return messageComposer.config.location.enabled && !messageComposer.threadId;
101
+ return channelConfig?.shared_locations && !messageComposer.threadId;
99
102
  }
100
103
  return true;
101
104
  })
@@ -8,10 +8,11 @@ import { useComponentContext, useMessageContext, useTranslationContext, } from '
8
8
  */
9
9
  export const ReactionSelectorWithButton = ({ ReactionIcon, }) => {
10
10
  const { t } = useTranslationContext('ReactionSelectorWithButton');
11
- const { isMyMessage, message } = useMessageContext('MessageOptions');
11
+ const { isMyMessage, message, threadList } = useMessageContext('MessageOptions');
12
12
  const { ReactionSelector = DefaultReactionSelector } = useComponentContext('MessageOptions');
13
13
  const buttonRef = useRef(null);
14
- const dialogId = `reaction-selector--${message.id}`;
14
+ const dialogIdNamespace = threadList ? '-thread-' : '';
15
+ const dialogId = `reaction-selector${dialogIdNamespace}--${message.id}`;
15
16
  const dialog = useDialog({ id: dialogId });
16
17
  const dialogIsOpen = useDialogIsOpen(dialogId);
17
18
  return (React.createElement(React.Fragment, null,
@@ -11516,10 +11516,11 @@ var ReactionSelectorWithButton = ({
11516
11516
  ReactionIcon: ReactionIcon2
11517
11517
  }) => {
11518
11518
  const { t } = useTranslationContext("ReactionSelectorWithButton");
11519
- const { isMyMessage, message } = useMessageContext("MessageOptions");
11519
+ const { isMyMessage, message, threadList } = useMessageContext("MessageOptions");
11520
11520
  const { ReactionSelector: ReactionSelector2 = ReactionSelector } = useComponentContext("MessageOptions");
11521
11521
  const buttonRef = (0, import_react35.useRef)(null);
11522
- const dialogId = `reaction-selector--${message.id}`;
11522
+ const dialogIdNamespace = threadList ? "-thread-" : "";
11523
+ const dialogId = `reaction-selector${dialogIdNamespace}--${message.id}`;
11523
11524
  const dialog = useDialog({ id: dialogId });
11524
11525
  const dialogIsOpen = useDialogIsOpen(dialogId);
11525
11526
  return /* @__PURE__ */ import_react35.default.createElement(import_react35.default.Fragment, null, /* @__PURE__ */ import_react35.default.createElement(