Skip to content

Commit ecd1394

Browse files
authored
Merge branch 'master' into emoji-fonts
2 parents f4d8f98 + 80e3216 commit ecd1394

27 files changed

+193
-127
lines changed

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,27 @@
11
# Changelog
22

33

4+
## [5.1.0](https://github.com/GetStream/stream-chat-react/releases/tag/v5.1.0) 2021-03-30
5+
6+
### Feature
7+
8+
- Add type support for Moment.js date objects [#809](https://github.com/GetStream/stream-chat-react/pull/809)
9+
- Add i18n translation support for `ChannelPreview` [#810](https://github.com/GetStream/stream-chat-react/pull/810)
10+
- Allow `addNotification` function to be called anywhere within `Channel` [#811](https://github.com/GetStream/stream-chat-react/pull/811)
11+
- Hide `MessageActions` if no actions exist [#816](https://github.com/GetStream/stream-chat-react/pull/816)
12+
13+
### Chore
14+
15+
- Refactor failed message UI component [#811](https://github.com/GetStream/stream-chat-react/pull/811)
16+
- Remove extra `watchers` query [#817](https://github.com/GetStream/stream-chat-react/pull/817)
17+
- Prevent `queryUsers` from searching a null value [#817](https://github.com/GetStream/stream-chat-react/pull/817)
18+
19+
## [5.0.3](https://github.com/GetStream/stream-chat-react/releases/tag/v5.0.3) 2021-03-24
20+
21+
### Feature
22+
23+
- Add customization options for `renderText` function [#807](https://github.com/GetStream/stream-chat-react/pull/807)
24+
425
## [5.0.2](https://github.com/GetStream/stream-chat-react/releases/tag/v5.0.2) 2021-03-23
526

627
### Bug

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/Channel/Channel.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,7 @@ const ChannelInner = <
474474
try {
475475
queryResponse = await channel.query({
476476
messages: { id_lt: oldestID, limit: perPage },
477+
watchers: { limit: perPage },
477478
});
478479
} catch (e) {
479480
console.warn('message pagination request failed with error', e);
@@ -572,10 +573,14 @@ const ChannelInner = <
572573
status: 'received',
573574
});
574575
}
575-
} catch (e) {
576-
// set the message to failed..
576+
} catch (error) {
577+
// error response isn't usable so needs to be stringified then parsed
578+
const stringError = JSON.stringify(error);
579+
const parsedError = stringError ? JSON.parse(stringError) : {};
580+
577581
updateMessage({
578582
...message,
583+
errorStatusCode: (parsedError.status as number) || undefined,
579584
status: 'failed',
580585
});
581586
}
@@ -644,6 +649,7 @@ const ChannelInner = <
644649
// set the message status to sending
645650
updateMessage({
646651
...message,
652+
errorStatusCode: undefined,
647653
status: 'sending',
648654
});
649655

src/components/Channel/__tests__/Channel.test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,9 @@ describe('Channel', () => {
407407
id_lt: messages[0].id,
408408
limit,
409409
},
410+
watchers: {
411+
limit,
412+
},
410413
}),
411414
);
412415

src/components/ChatAutoComplete/ChatAutoComplete.tsx

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useCallback, useEffect, useMemo, useState } from 'react';
1+
import React, { useCallback, useMemo, useState } from 'react';
22
import debounce from 'lodash.debounce';
33

44
import { AutoCompleteTextarea } from '../AutoCompleteTextarea';
@@ -244,7 +244,7 @@ const UnMemoizedChatAutoComplete = <
244244
value,
245245
} = props;
246246

247-
const { channel, emojiConfig, thread } = useChannelContext<
247+
const { channel, emojiConfig } = useChannelContext<
248248
At,
249249
Ch,
250250
Co,
@@ -257,18 +257,6 @@ const UnMemoizedChatAutoComplete = <
257257

258258
const [searching, setSearching] = useState(false);
259259

260-
useEffect(() => {
261-
const getWatchers = async () => {
262-
await channel?.watch({
263-
watchers: { limit: 100, offset: 0 },
264-
});
265-
};
266-
267-
if (!thread) {
268-
getWatchers();
269-
}
270-
}, []);
271-
272260
const members = channel?.state?.members;
273261
const watchers = channel?.state?.watchers;
274262
const { emojiData, EmojiIndex } = emojiConfig || {};
@@ -341,7 +329,7 @@ const UnMemoizedChatAutoComplete = <
341329
query: string,
342330
onReady: (users: UserResponse<Us>[]) => void,
343331
) => {
344-
if (searching) return;
332+
if (!query || searching) return;
345333
setSearching(true);
346334

347335
try {

src/components/DateSeparator/DateSeparator.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const UnMemoizedDateSeparator = (props: DateSeparatorProps) => {
3939
<hr className='str-chat__date-separator-line' />
4040
)}
4141
<div className='str-chat__date-separator-date'>
42-
{unread ? t('New') : formattedDate}
42+
{unread ? `${t('New')} - ${formattedDate}` : formattedDate}
4343
</div>
4444
{(position === 'left' || position === 'center') && (
4545
<hr className='str-chat__date-separator-line' />

src/components/DateSeparator/__tests__/DateSeparator.test.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ Dayjs.extend(calendar);
1212

1313
afterEach(cleanup); // eslint-disable-line
1414

15-
// this changes every time tests are run,
16-
// but by mocking the actual renderers tests are still deterministic
17-
const now = new Date();
15+
const now = new Date('2020-03-30T22:57:47.173Z');
1816

1917
const withContext = (props) => {
2018
const t = jest.fn((key) => key);
@@ -41,7 +39,7 @@ describe('DateSeparator', () => {
4139
const { Component, t } = withContext({ date: now, unread: true });
4240
const { queryByText } = render(Component);
4341

44-
expect(queryByText('New')).toBeInTheDocument();
42+
expect(queryByText('New - 03/30/2020')).toBeInTheDocument();
4543
expect(t).toHaveBeenCalledWith('New');
4644
});
4745

@@ -58,7 +56,7 @@ describe('DateSeparator', () => {
5856
<div
5957
className="str-chat__date-separator-date"
6058
>
61-
New
59+
New - 03/30/2020
6260
</div>
6361
</div>
6462
`);

0 commit comments

Comments
 (0)