Skip to content
Merged

v8 #1456

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
ff6513d
Update CHANGELOG.md
ambaldwin Feb 10, 2022
0d97fc6
feat: support choosing a giphy version
petyosi Feb 15, 2022
c683771
docs: prop and context value
petyosi Feb 16, 2022
5b88fff
refactor: typescript generics into single generic as stream-chat@6.0.0
khushal87 Feb 17, 2022
94e9e58
fix: broken tests around mutes in useChat.ts
khushal87 Feb 17, 2022
bb6c3c3
fixes #1349 Issue - display thread send button if upload preview (#1352)
zacheryconverse Feb 17, 2022
85258fb
Merge pull request #1374 from GetStream/fixed-giphy-height
petyosi Feb 18, 2022
f7dd258
docs: added single generic refactoring documentation
khushal87 Feb 18, 2022
dac8bda
fix: docs and package.json stream-chat dependency
khushal87 Feb 18, 2022
fcad45d
chore: fix merge conflicts
khushal87 Feb 18, 2022
57472be
chore: guard for older attachments
petyosi Feb 22, 2022
3f97c98
Fixes issue 1376 (#1380)
zacheryconverse Feb 22, 2022
d2f28af
fix: improve performance of vml
petyosi Feb 23, 2022
2b13594
fix: remove obsolete polyfill
petyosi Feb 23, 2022
c9897f4
feat: onBlur prop for ChatAutoComplete
petyosi Feb 23, 2022
fbb73b4
refactor: use svg icon in str-chat__header-hamburger button
MartinCupela Feb 23, 2022
680bdc4
docs: livestream best practices
petyosi Feb 24, 2022
cee850d
docs: incorporate PR feedback
petyosi Feb 25, 2022
9a6c54c
Merge pull request #1391 from GetStream/improve-vml-config
petyosi Feb 25, 2022
14010f6
Merge pull request #1389 from GetStream/chat-autocomplete-on-blur
petyosi Feb 25, 2022
d9b194d
Merge pull request #1388 from GetStream/remove-custom-event-polyfill
petyosi Feb 25, 2022
653aef3
fix: name from StreamChatType to StreamChatGenerics
khushal87 Feb 27, 2022
6e26757
chore: resolve merge conflicts
khushal87 Feb 27, 2022
0651fe6
Merge pull request #1377 from GetStream/khushal87-single-generic
khushal87 Feb 28, 2022
c81308a
refactor: allow to pass custom placeholder to the ChannelSearch compo…
MartinCupela Feb 28, 2022
db03eb5
Merge remote-tracking branch 'origin/develop' into allow-custom-place…
MartinCupela Feb 28, 2022
e01af0d
fix: typo + import order
MartinCupela Feb 28, 2022
9dcedec
docs: document addition of MenuIcon prop to ChannelHeader
MartinCupela Feb 28, 2022
cf3abb6
Merge remote-tracking branch 'origin/develop' into chat-header-hambur…
MartinCupela Feb 28, 2022
0b90624
test: MenuIcon is displayed in ChannelHeader
MartinCupela Feb 28, 2022
a3a0eb6
Merge pull request #1393 from GetStream/livestream-help-article
petyosi Feb 28, 2022
cf31526
style: separate import groups
MartinCupela Feb 28, 2022
6c90681
refactor: allow for no placeholder in ChannelSearch
MartinCupela Feb 28, 2022
4b20bf7
Update README.md
ambaldwin Feb 28, 2022
e9a6a31
chore: update to channel search and message ui component docs
ambaldwin Feb 28, 2022
d08afb8
chore: update wording of search docs update
ambaldwin Feb 28, 2022
a0171c3
chore: A template for Feature
petyosi Mar 3, 2022
1968a1e
Merge pull request #1402 from GetStream/docs-updates
ambaldwin Mar 3, 2022
c103ed2
refactor: avoid registering mouseleave hiding event for MessageAction…
MartinCupela Mar 4, 2022
9793546
test: MessageActions used inside MessageSimple is hidden only on mous…
MartinCupela Mar 4, 2022
85c540c
docs: purpose of messageWrapperRef in MessageActions & MessageOptions…
MartinCupela Mar 4, 2022
daeebab
docs: fix typos
MartinCupela Mar 7, 2022
ae5d92a
Merge pull request #1392 from GetStream/chat-header-hamburger-fix
MartinCupela Mar 7, 2022
d4dfe50
Merge remote-tracking branch 'origin/develop' into allow-custom-place…
MartinCupela Mar 7, 2022
5f415e7
Merge remote-tracking branch 'origin/allow-custom-placeholder-Channel…
MartinCupela Mar 7, 2022
818c67b
Merge pull request #1400 from GetStream/allow-custom-placeholder-Chan…
MartinCupela Mar 7, 2022
f37b193
fix: make scrollToLatestMessageOnFocus smarter
petyosi Mar 7, 2022
4f9d220
chore: remove unnecessary effect dependency
petyosi Mar 7, 2022
14ac526
refactor: use fixed_height as the default image size from giphy
santhoshvai Mar 8, 2022
fead574
fix: update docs to the correct default value used
santhoshvai Mar 8, 2022
9170b9f
fix: incorrect removal of the documentation of giphyVersion prop
santhoshvai Mar 8, 2022
096f839
fix: incorrect ordering of channel props
santhoshvai Mar 8, 2022
ee02da2
Merge pull request #1440 from GetStream/fix-giphy-usage-inconsistencies
santhoshvai Mar 8, 2022
4b7f3d1
refactor: register click and keyup listeners for hideOptions only if …
MartinCupela Mar 10, 2022
ae9da2c
docs: do not explain the purpose of messageWrapperRef
MartinCupela Mar 10, 2022
f75464f
Merge pull request #1439 from GetStream/improve-focus-latest-message
petyosi Mar 10, 2022
bfe7a5b
test: register click and keyup listeners only once a messsage actions…
MartinCupela Mar 10, 2022
0701050
refactor: don't hide message actions dialog on hover away
MartinCupela Mar 10, 2022
7b22a05
fix: typescript issues due to stream-chat@6.0.0 (#1446)
khushal87 Mar 15, 2022
8ebbf29
fix: moved UploadsPreview outside textarea wrapper (#1454)
arnautov-anton Mar 17, 2022
30b79d6
fix: maintain correct reference to values inside doMarkReadRequest (#…
zacheryconverse Mar 17, 2022
516336b
chore: upgrade stream-chat to latest
petyosi Mar 17, 2022
d488e04
chore: upgrade virtuoso
petyosi Mar 17, 2022
7f1eb22
chore: remove duplicate type
petyosi Mar 17, 2022
3d951f2
fix: translation warning
petyosi Mar 17, 2022
450fc31
chore: fix snapshot
petyosi Mar 17, 2022
46ffef9
feat: reduce generics to a single map
petyosi Mar 17, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: Feature request
about: Describe a new feature
title: ''
labels: feature
assignees: ''

---

**Motivation**
A clear and concise description of what the problem/opportunity is. Ex. I'm always frustrated when [...]

**Proposed solution**
A clear and concise description of what you want to happen.

**Acceptance Criteria**
A set of predefined requirements that must be met to mark a user story complete.
33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,38 @@
# Changelog

## [7.0.0](https://github.com/GetStream/stream-chat-react/releases/tag/v7.0.0) 2022-02-10

### ⚠️ BREAKING CHANGES ⚠️

- Replace stale `react-images` dependency with `react-image-gallery`, removed `ModalImage` [#1318](https://github.com/GetStream/stream-chat-react/pull/1318)
- Add support for accessibility through the use of semantic HTML, ARIA attributes. Updates include changing HTML elements to different types as necessary [#1314](https://github.com/GetStream/stream-chat-react/pull/1314) and [#1294](https://github.com/GetStream/stream-chat-react/pull/1294)

### Feature

* Add support for `QuotedMessages` in a `Thread` [#1356](https://github.com/GetStream/stream-chat-react/pull/1356)
* Add `wordReplace` prop to `ChatAutoComplete` to override default behavior [#1347](https://github.com/GetStream/stream-chat-react/pull/1347)

### Chore

* Fix small documentation typo [#1312](https://github.com/GetStream/stream-chat-react/pull/1312)
* Improve compatibility with NextJS [#1315](https://github.com/GetStream/stream-chat-react/pull/1315)
* Use the `Avatar` from the `ComponentContext` in `QuotedMessagePreview` [#1311](https://github.com/GetStream/stream-chat-react/pull/1311)
* Set `ImagePreviewer` to disabled if multiple uploads is not allowed [#1330](https://github.com/GetStream/stream-chat-react/pull/1330)
* Export `QuotedMessagePreview` component [#1339](https://github.com/GetStream/stream-chat-react/pull/1339)
* Add guide on how to build a custom list with channel members and have real time updates of their online status [#1350](https://github.com/GetStream/stream-chat-react/pull/1350)
* Support URLs with encoded components [#1353](https://github.com/GetStream/stream-chat-react/pull/1353)
* Remove UNSAFE warning from `AutoCompleteTextarea` [#1354](https://github.com/GetStream/stream-chat-react/pull/1354)
* Add current text to `openMentionsList` method [#1360](https://github.com/GetStream/stream-chat-react/pull/1360)
* Update to `Window`'s `hideOnThread` prop to handle via CSS [#1363](https://github.com/GetStream/stream-chat-react/pull/1363)
* Upgrade stream-chat-css dependency to v2.2.1 [#1365](https://github.com/GetStream/stream-chat-react/pull/1365)

### Bug

* Fix the logic for the `VirtualizedMessageList`'s `firstOfGroup` prop [#1338](https://github.com/GetStream/stream-chat-react/pull/1338)
* Fix bug where on `channel.updated` event `own_capabilities` and `hidden` values are lost [#1346](https://github.com/GetStream/stream-chat-react/pull/1346)
* Add a fix so quotes (aka replies) are not still available in message options when quotes are disabled in configuration [#1364](https://github.com/GetStream/stream-chat-react/pull/1364)


## [6.12.2](https://github.com/GetStream/stream-chat-react/releases/tag/v6.12.2) 2021-12-09

### Feature
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ import './App.css';

## Internationalization

Our library supports auto-translation for various user languages. Please read our internationalization [documentation](https://github.com/GetStream/stream-chat-react/wiki/Internationalization-(i18n)) for further details and setup guidance.
Our library supports auto-translation for various user languages. Please read our internationalization [documentation](https://getstream.io/chat/docs/sdk/react/customization/translations/) for further details and setup guidance.

## Contributing

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions docusaurus/docs/React/contexts/channel-state-context.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ Error object (if any) in loading the `channel`, otherwise null.
| ------ |
| object |

### giphyVersion

The giphy version to use when displaying giphies.

| Type |
| --------------------------------------------------------------------------------------------------------------------------------------------------- |
| `'original' | 'fixed_height' | 'fixed_height_still' | 'fixed_height_downsampled' | 'fixed_width' | 'fixed_width_still' | 'fixed_width_downsampled'` |

### hasMore

If the channel has more messages to paginate through.
Expand Down
8 changes: 8 additions & 0 deletions docusaurus/docs/React/core-components/channel.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,14 @@ Custom UI component to render a Giphy preview in the `VirtualizedMessageList`.
| --------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| component | [GiphyPreviewMessage](https://github.com/GetStream/stream-chat-react/blob/master/src/components/MessageList/GiphyPreviewMessage.tsx) |

### giphyVersion

The Giphy version to render - check the keys of the [Image Object](https://developers.giphy.com/docs/api/schema#image-object) for possible values.

| Type | Default |
| --------- | -------------- |
| string | 'fixed_height' |

### HeaderComponent

Custom UI component to render at the top of the `MessageList`.
Expand Down
33 changes: 32 additions & 1 deletion docusaurus/docs/React/custom-code-examples/channel-search.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import CustomChannelSearch from '../assets/CustomChannelSearch.png';
## How-to Guide for Customizing ChannelSearch

In this example, we will customize the [`ChannelSearch`](../core-components/channel-list.mdx#channelsearch) component. Though this component can be used standalone, we will do our customization when it's established in the `ChannelList`. Here is a guide that outlines how to
override the default `DropdownContainer` and `SearchResultItem` components, as well as use several other useful props.
override the default `DropdownContainer`, `SearchResultItem`, and `SearchResultsHeader` components, as well as use several other useful props.

:::note
A complete override of this component is possible by utilizing the [`ChannelSearch`](../core-components/channel-list.mdx#channelsearch) prop on `ChannelList`.
Expand Down Expand Up @@ -308,3 +308,34 @@ const additionalProps = {
### Result:

<img src={CustomChannelSearch} alt='Custom Channel Search UI Component for Chat' width='700' />

### The searchFunction Prop:

By default the `ChannelSearch` component searches just for users. Use the `searchForChannels` prop to also search for channels.

To override the search method, completely use the `searchFunction` prop. This prop is useful, say, when you want to search just for channels
and for only channels that the current logged in user is a member of. See the example below for this.

```jsx
const customSearchFunction = async (props: ChannelSearchFunctionParams, event: { target: { value: SetStateAction<string>; }; }) => {
const { setResults, setResultsOpen, setSearching, setQuery } = props;
const { client } = useChatContext();

const filters = {
name: { $autocomplete: event.target.value },
members: { $in: client.userID }
}

setSearching(true);
setQuery(event.target.value);
const channels = await chatClient.queryChannels(filters);
setResults(channels);
setResultsOpen(true);
setSearching(false);
};

<ChannelList
showChannelSearch
additionalChannelSearchProps={{searchFunction: customSearchFunction}}
/>
```
80 changes: 80 additions & 0 deletions docusaurus/docs/React/custom-code-examples/livestream-setup.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
id: livestream-setup
sidebar_position: 22
title: Livestream Best Practices
---
import MarginInspector from '../assets/margin-inspector.png'
import MessageHeight from '../assets/message-height.png'

Livestream chat UI poses several hard technological challenges since users can spend a few hours watching a certain event. For that period, the chat UI should be able to handle a constant stream of messages, reactions, and media attachments.

The React SDK offers a special component for that purpose - the `VirtualizedMessageList`. The component renders only the messages visible in the viewport and dynamically updates its contents as the user scrolls.
This decreases browser memory usage and does not degrade the performance of the page even if the user receives thousands of messages in a single session.

In this article, we will go through the best practices and tweaks for configuring the `VirtualizedMessageList` to ensure a smooth user experience during a high message traffic.

## Get Started

The `VirtualizedMessageList` is mostly compatible with the non-virtualized `MessageList`, although not all properties are the same. The simplest configuration and placement are the same:

```tsx
<Chat client={client}>
<ChannelList />
<Channel>
<VirtualizedMessageList />
<MessageInput />
</Channel>
</Chat>
```

With this configuration, the virtualized list will look identical to the non-virtualized version. With the next few steps, we can configure the component for maximum performance.

## Disable the automatic scroll to bottom transition

By default, the `VirtualizedMessageList` will scroll down to display new messages using the `"smooth"` scroll behavior ([MDN link](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollTo#examples)). This works well for moderately busy chat rooms but can be unwieldy in chats with more than 2-3 incoming messages per second. A safer, snappier option is `"auto"`. With that setting, the list scrolls to the latest received message instantly.

```tsx
<VirtualizedMessageList stickToBottomScrollBehavior="auto" />
```

## Specify the default item height

The `VirtualizedMessageList` supports items with varying heights and automatically keeps track of the rendered item sizes, while estimating the not-yet-rendered sizes based on latest message during load. To optimize this further and minimize potential recalculations, set the `defaultItemHeight` to the height of your usual one-line message (If in doubt, use the developer tools inspector to determine the sizing).

<img src={MessageHeight} alt='Message Height' width='700' />

The element above is `58px` tall, so let's put that at the `defaultItemHeight` prop value:

```tsx
<VirtualizedMessageList defaultItemHeight={58} />
```

## Avoid vertical CSS margins
If the custom Message component has vertical margins that affect its height, the message list might behave erratically (blinking, rendering white areas, etc).

This could be a potential pitfall if you're using a custom message component. The `VirtualizedMessageList` uses `getBoundingClientRect` ([MDN](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect)) on the outermost message element.
This method does not measure CSS margins, which are tricky to measure in the first place [due to collapsing](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Box_Model/Mastering_margin_collapsing).
If the custom Message component has vertical margins that affect its height, the message list might behave erratically (blinking, rendering white areas, etc).

Use your DOM inspector and look for any orange gaps between the message elements. See the screenshot below for example of headings with margins:

<img src={MarginInspector} alt='Margin Inspector' width='700' />

## Choose the right Giphy size

This practice is not unique to the virtualized message list but might help you build a more compact chat timeline and reduce the overall traffic for your users. By default, the Giphy attachments [use the original Giphy version image](https://developers.giphy.com/docs/api/schema#image-object). You can override that by setting the `giphyVersion` property of the `Channel` Component to a smaller one - use the keys [from the Giphy documentation](https://developers.giphy.com/docs/api/schema#image-object).

```tsx
<Chat client={client}>
<ChannelList />
<Channel giphyVersion="fixed_height_small">
<VirtualizedMessageList />
<MessageInput />
</Channel>
</Chat>
```

## Design reactions so that they don't change the message size

One final best practice: make sure that adding reactions to the message does not increase the message height if you're using a custom `Message` component. Good examples for such design would be the chat boxes of Twitch and Telegram.
Avoiding that will make the message list appear more stable and less jumpy during high traffic.
150 changes: 150 additions & 0 deletions docusaurus/docs/React/customization/message-ui.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,156 @@ export const CustomMessage = () => {
};
```

CustomMessage.scss:

```css
.str-chat__li {
margin: 0px;
padding: 15px;
position: relative;

&:hover {
background: rgba(0, 0, 0, 0.03);
.str-chat__message-text-inner {
background: rgba(0, 0, 0, 0);
}
}
}

.message-wrapper {
display: flex;

&-content {
display: flex;
flex-direction: column;
align-items: flex-start;
width: 100%;
}
}

.message-header {
display: flex;

&-name {
font-family: Helvetica Neue, sans-serif;
font-weight: 500;
font-size: 11px;
line-height: 120%;
color: #858688;
}

&-timestamp {
font-family: Helvetica Neue, sans-serif;
font-size: 11px;
line-height: 120%;
color: #858688;
margin-left: 6px;
}
}

.str-chat__li:hover .str-chat__message-simple__actions {
position: absolute;
top: -14px;
right: 20px;
display: flex;
align-items: center;
justify-content: space-between;
height: 24px;
border-radius: 100px;
background: white;
border: 1px solid #e0e0e0;
box-shadow: 0 2px 1px 0 rgba(0, 0, 0, 0.07);
z-index: 1;
padding: 0 4px 0;

&__action--reactions {
display: flex;
}

&__action--options {
display: flex;
}

&__action--thread {
display: flex;
}
}

.str-chat__message-simple__actions {
margin-top: 0;
}

.str-chat__message-actions-box {
top: initial;
left: -100px;
border-radius: 16px 16px 0 16px;
}

.str-chat__message-text {
display: flex;
width: 100%;
}

.str-chat__message-text-inner {
position: relative;
flex: 1;
display: block;
min-height: 32px;
font-size: 15px;
color: black;
border-radius: 0;
border: 0px;
margin-left: 0;

p {
font-family: Helvetica Neue, sans-serif;
font-size: 15px;
line-height: 18px;
color: #000000;
margin-bottom: 0;
}
}

.str-chat__message-replies-count-button {
font-family: Helvetica Neue, sans-serif;
font-weight: bold;
font-size: 13px;
text-align: right;
color: #4e1d9d;
}

.str-chat__simple-reactions-list {
border-radius: 10px;
}

.str-chat__reaction-selector {
max-height: 40px;
top: -58px;
right: 20px;
border-radius: 20px;
background: white;
box-shadow: 0px 3px 8px rgba(0, 0, 0, 0.15);
border: 1px solid #bed5e4;
}

.str-chat__message-reactions-list-item__count {
color: #000000;
}

.str-chat__message-simple-status {
right: 22px;
}

.quoted-message-inner {
margin-top: 10px;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.str-chat__li .quoted-message.mine .quoted-message-inner {
background: #ebebeb;
}
```

#### The Result:

<img src={CustomMessage} alt='Custom Message UI Component for Chat' width='700' />
Loading