Skip to content

Commit aed3750

Browse files
committed
remove extra channel query
do not search empty query add changelog updates actions box to not show up if user has no available actions remove conditional 5.1.0
1 parent 480bd47 commit aed3750

File tree

9 files changed

+61
-18
lines changed

9 files changed

+61
-18
lines changed

docs/build/bundle.c41241d6.js renamed to docs/build/bundle.487833e0.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/build/bundle.c41241d6.js.LICENSE.txt renamed to docs/build/bundle.487833e0.js.LICENSE.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*! exports provided: 0, 128, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 142, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 158, 159, default */
22

3-
/*! exports provided: 1 reply, Attach files, Cancel, Channel Missing, Close, Close emoji picker, Commands matching, Connection failure, reconnecting now..., Delete, Delivered, Edit Message, Emoji matching, Empty message..., Error adding flag: Either the flag already exist or there is issue with network connection ..., Error connecting to chat, refresh the page to try again., Error muting a user ..., Error pinning message, Error removing message pin, Error unmuting a user ..., Error · Unsent, Error: {{ errorMessage }}, Flag, Message Failed · Click to try again, Message deleted, Message failed. Click to try again., Message has been successfully flagged, Message pinned, Mute, New, New Messages!, Nothing yet..., Only visible to you, Open emoji picker, People matching, Pick your emoji, Pin, Pinned by, Send, Sending..., Start of a new thread, This message was deleted..., Thread, Type your message, Unmute, Unpin, You have no channels currently, You've reached the maximum number of files, live, this content could not be displayed, {{ commaSeparatedUsers }} and {{ lastUser }} are typing..., {{ commaSeparatedUsers }} and {{ moreCount }} more, {{ commaSeparatedUsers }}, and {{ lastUser }}, {{ firstUser }} and {{ secondUser }}, {{ firstUser }} and {{ secondUser }} are typing..., {{ imageCount }} more, {{ memberCount }} members, {{ replyCount }} replies, {{ user }} has been muted, {{ user }} has been unmuted, {{ user }} is typing..., {{ watcherCount }} online, 🏙 Attachment..., default */
3+
/*! exports provided: 1 reply, Attach files, Cancel, Channel Missing, Close, Close emoji picker, Commands matching, Connection failure, reconnecting now..., Delete, Delivered, Edit Message, Emoji matching, Empty message..., Error adding flag: Either the flag already exist or there is issue with network connection ..., Error connecting to chat, refresh the page to try again., Error muting a user ..., Error pinning message, Error removing message pin, Error unmuting a user ..., Error · Unsent, Error: {{ errorMessage }}, Flag, Message Failed · Click to try again, Message Failed · Unauthorized, Message deleted, Message has been successfully flagged, Message pinned, Mute, New, New Messages!, Nothing yet..., Only visible to you, Open emoji picker, People matching, Pick your emoji, Pin, Pinned by, Send, Sending..., Start of a new thread, This message was deleted..., Thread, Type your message, Unmute, Unpin, You have no channels currently, You've reached the maximum number of files, live, this content could not be displayed, {{ commaSeparatedUsers }} and {{ lastUser }} are typing..., {{ commaSeparatedUsers }} and {{ moreCount }} more, {{ commaSeparatedUsers }}, and {{ lastUser }}, {{ firstUser }} and {{ secondUser }}, {{ firstUser }} and {{ secondUser }} are typing..., {{ imageCount }} more, {{ memberCount }} members, {{ replyCount }} replies, {{ user }} has been muted, {{ user }} has been unmuted, {{ user }} is typing..., {{ watcherCount }} online, 🏙 Attachment..., default */
44

55
/*! exports provided: ACORN_OPTIONS, default */
66

@@ -44,7 +44,7 @@
4444

4545
/*! exports provided: ChannelContext, ChannelProvider, useChannelContext, withChannelContext */
4646

47-
/*! exports provided: ChannelContext, ChannelProvider, useChannelContext, withChannelContext, ChatContext, ChatProvider, useChatContext, withChatContext, isDayjs, isDate, isNumberOrString, TranslationContext, TranslationProvider, useTranslationContext, withTranslationContext */
47+
/*! exports provided: ChannelContext, ChannelProvider, useChannelContext, withChannelContext, ChatContext, ChatProvider, useChatContext, withChatContext, isDayOrMoment, isDate, isNumberOrString, TranslationContext, TranslationProvider, useTranslationContext, withTranslationContext */
4848

4949
/*! exports provided: ChannelHeader */
5050

@@ -448,7 +448,7 @@
448448

449449
/*! exports provided: isBrowser, default */
450450

451-
/*! exports provided: isDayjs, isDate, isNumberOrString, TranslationContext, TranslationProvider, useTranslationContext, withTranslationContext */
451+
/*! exports provided: isDayOrMoment, isDate, isNumberOrString, TranslationContext, TranslationProvider, useTranslationContext, withTranslationContext */
452452

453453
/*! exports provided: isElement, isHTMLElement, isShadowRoot */
454454

@@ -628,7 +628,7 @@
628628

629629
/*! exports provided: v1, v3, v4, v5, NIL, version, validate, stringify, parse */
630630

631-
/*! exports provided: validateAndGetMessage, isUserMuted, MESSAGE_ACTIONS, defaultPinPermissions, getMessageActions, areMessagePropsEqual, areMessageUIPropsEqual, messageHasReactions, messageHasAttachments, getImages, getNonImageAttachments, getReadByTooltipText */
631+
/*! exports provided: validateAndGetMessage, isUserMuted, MESSAGE_ACTIONS, defaultPinPermissions, getMessageActions, showMessageActionsBox, areMessagePropsEqual, areMessageUIPropsEqual, messageHasReactions, messageHasAttachments, getImages, getNonImageAttachments, getReadByTooltipText */
632632

633633
/*! exports provided: walk, childKeys */
634634

docs/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
</head>
1010
<body>
1111
<div id="rsg-root"></div>
12-
<script src="build/bundle.c41241d6.js"></script>
12+
<script src="build/bundle.487833e0.js"></script>
1313
</body>
1414
</html>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "stream-chat-react",
3-
"version": "5.0.3",
3+
"version": "5.1.0",
44
"description": "React components to create chat conversations or livestream style chat",
55
"author": "GetStream",
66
"homepage": "https://getstream.io/chat/",

src/components/Message/MessageLivestream.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
ReactionIcon,
2121
ThreadIcon,
2222
} from './icons';
23-
import { areMessageUIPropsEqual } from './utils';
23+
import { areMessageUIPropsEqual, showMessageActionsBox } from './utils';
2424

2525
import { Attachment as DefaultAttachment } from '../Attachment';
2626
import { Avatar as DefaultAvatar } from '../Avatar';
@@ -356,6 +356,8 @@ const MessageLivestreamActions = <
356356
const messageDeletedAt = !!message.deleted_at;
357357
const messageWrapper = messageWrapperRef?.current;
358358

359+
const showActionsBox = showMessageActionsBox(getMessageActions());
360+
359361
useEffect(() => {
360362
if (messageWrapper) {
361363
messageWrapper.addEventListener('mouseleave', hideOptions);
@@ -425,12 +427,14 @@ const MessageLivestreamActions = <
425427
<ThreadIcon />
426428
</span>
427429
)}
428-
<MessageActions
429-
{...props}
430-
customWrapperClass={''}
431-
getMessageActions={getMessageActions}
432-
inline
433-
/>
430+
{showActionsBox && (
431+
<MessageActions
432+
{...props}
433+
customWrapperClass={''}
434+
getMessageActions={getMessageActions}
435+
inline
436+
/>
437+
)}
434438
</div>
435439
);
436440
};

src/components/Message/MessageSimple.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
getReadByTooltipText,
1313
messageHasAttachments,
1414
messageHasReactions,
15+
showMessageActionsBox,
1516
} from './utils';
1617

1718
import { Attachment as DefaultAttachment } from '../Attachment';
@@ -82,6 +83,7 @@ const MessageSimpleWithContext = <
8283
editing,
8384
EditMessageInput = DefaultEditMessageForm,
8485
formatDate,
86+
getMessageActions,
8587
handleAction,
8688
handleOpenThread,
8789
handleReaction,
@@ -109,6 +111,8 @@ const MessageSimpleWithContext = <
109111
? 'str-chat__message str-chat__message--me str-chat__message-simple str-chat__message-simple--me'
110112
: 'str-chat__message str-chat__message-simple';
111113

114+
const showActionsBox = showMessageActionsBox(getMessageActions());
115+
112116
if (message.type === 'message.read' || message.type === 'message.date') {
113117
return null;
114118
}
@@ -208,6 +212,7 @@ const MessageSimpleWithContext = <
208212
<MessageText
209213
{...props}
210214
customOptionProps={{
215+
displayActions: showActionsBox,
211216
handleOpenThread,
212217
messageWrapperRef,
213218
}}

src/components/Message/MessageTeam.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ import {
1111
ReactionIcon,
1212
ThreadIcon,
1313
} from './icons';
14-
import { areMessageUIPropsEqual, getReadByTooltipText } from './utils';
14+
import {
15+
areMessageUIPropsEqual,
16+
getReadByTooltipText,
17+
showMessageActionsBox,
18+
} from './utils';
1519

1620
import { Attachment as DefaultAttachment } from '../Attachment';
1721
import { Avatar as DefaultAvatar } from '../Avatar';
@@ -128,6 +132,8 @@ const MessageTeamWithContext = <
128132

129133
const channelConfig = propChannelConfig || channel?.getConfig();
130134

135+
const showActionsBox = showMessageActionsBox(getMessageActions());
136+
131137
const messageTextToRender =
132138
message.i18n?.[`${userLanguage}_text` as `${TranslationLanguages}_text`] ||
133139
message.text;
@@ -278,7 +284,7 @@ const MessageTeamWithContext = <
278284
<ThreadIcon />
279285
</span>
280286
)}
281-
{getMessageActions().length > 0 && (
287+
{showActionsBox && (
282288
<MessageActions
283289
addNotification={addNotification}
284290
customWrapperClass={''}

src/components/Message/__tests__/MessageLivestream.test.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,12 @@ async function renderMessageLivestream(
5353
userLanguage: 'en',
5454
}}
5555
>
56-
<MessageLivestream message={message} typing={false} {...props} />
56+
<MessageLivestream
57+
getMessageActions={() => []}
58+
message={message}
59+
typing={false}
60+
{...props}
61+
/>
5762
</TranslationContext.Provider>
5863
</ChannelContext.Provider>,
5964
);

src/components/Message/utils.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,29 @@ export const getMessageActions = (
205205
return messageActionsAfterPermission;
206206
};
207207

208+
export const showMessageActionsBox = (actions: MessageActionsArray) => {
209+
if (actions.length === 0) {
210+
return false;
211+
}
212+
213+
if (
214+
actions.length === 1 &&
215+
(actions.includes('react') || actions.includes('reply'))
216+
) {
217+
return false;
218+
}
219+
220+
if (
221+
actions.length === 2 &&
222+
actions.includes('react') &&
223+
actions.includes('reply')
224+
) {
225+
return false;
226+
}
227+
228+
return true;
229+
};
230+
208231
export const areMessagePropsEqual = <
209232
At extends DefaultAttachmentType = DefaultAttachmentType,
210233
Ch extends DefaultChannelType = DefaultChannelType,

0 commit comments

Comments
 (0)