Skip to content

Commit 4b72783

Browse files
committed
Merge branch 'master' into fix/jump-to-first-unread-message-last-read-message-unknown
2 parents f0599dc + 62b828e commit 4b72783

File tree

325 files changed

+19343
-1244
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

325 files changed

+19343
-1244
lines changed

.github/workflows/e2e.yml

+13-8
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,32 @@ jobs:
66
e2e:
77
runs-on: ubuntu-latest
88
name: End-to-end tests
9+
concurrency:
10+
group: react-e2e
11+
cancel-in-progress: false
12+
env:
13+
PLAYWRIGHT_BROWSERS_PATH: ./pw-browsers
914
steps:
1015
- uses: actions/checkout@v3
1116

1217
- name: 💾 Cache Dependencies
1318
uses: actions/cache@v3
1419
with:
15-
path: ./node_modules
16-
key: ${{ runner.os }}-${{ matrix.node }}-modules-${{ hashFiles('**/yarn.lock') }}
20+
path: |
21+
./node_modules
22+
./pw-browsers
23+
key: ${{ runner.os }}-${{ matrix.node }}-modules-${{ hashFiles('./yarn.lock') }}
1724

1825
- name: 🔨 Install Dependencies
19-
run: yarn install --frozen-lockfile --ignore-engines --ignore-scripts
26+
run: |
27+
yarn install --frozen-lockfile --ignore-engines --ignore-scripts
28+
npx playwright install chromium
29+
npx playwright install-deps
2030
2131
- name: ⚗️ End-to-end tests
2232
run: |
23-
npx playwright install
24-
npx playwright install-deps
2533
yarn e2e-fixtures
26-
# running with --browser=all causes failures
2734
yarn e2e --browser=chromium
28-
yarn e2e --browser=webkit
29-
yarn e2e --browser=firefox
3035
env:
3136
E2E_JUMP_TO_MESSAGE_CHANNEL: jump-to-message
3237
E2E_ADD_MESSAGE_CHANNEL: add-message

.github/workflows/release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
- name: Install dependencies
6868
run: yarn install --frozen-lockfile --ignore-engines --ignore-scripts
6969
- name: Merge shared "@stream-io/stream-chat-css" docs
70-
run: bash scripts/merge-stream-chat-css-docs.sh node_modules/@stream-io/stream-chat-css/docs
70+
run: yarn docs:copy-css-docs
7171
- name: Push to stream-chat-docusaurus
7272
uses: GetStream/push-stream-chat-docusaurus-action@main
7373
with:

CHANGELOG.md

+25
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1+
## [11.11.0](https://github.com/GetStream/stream-chat-react/compare/v11.10.0...v11.11.0) (2024-03-01)
2+
3+
4+
### Bug Fixes
5+
6+
* cleanup ML types and defaults ([#2305](https://github.com/GetStream/stream-chat-react/issues/2305)) ([b3ed81d](https://github.com/GetStream/stream-chat-react/commit/b3ed81dd7a99ed32fb47c81a7b4e0b8e41f6d823))
7+
8+
9+
### Features
10+
11+
* introduce useCreateChatClient hook ([#1916](https://github.com/GetStream/stream-chat-react/issues/1916)) ([e086565](https://github.com/GetStream/stream-chat-react/commit/e08656592f635f25dc7f94bd1e6ec02c6d4c31d2)), closes [GetStream/stream-chat-react-issues#19](https://github.com/GetStream/stream-chat-react-issues/issues/19)
12+
13+
## [11.10.0](https://github.com/GetStream/stream-chat-react/compare/v11.9.0...v11.10.0) (2024-02-23)
14+
15+
16+
### Bug Fixes
17+
18+
* initial message load issues ([#2292](https://github.com/GetStream/stream-chat-react/issues/2292)) ([3685030](https://github.com/GetStream/stream-chat-react/commit/36850305435757090f28d63bed4306ec9d7481e1))
19+
20+
21+
### Features
22+
23+
* add customizable reaction details sorting ([#2290](https://github.com/GetStream/stream-chat-react/issues/2290)) ([652e3a5](https://github.com/GetStream/stream-chat-react/commit/652e3a53ebe38ca66766687b35f370582307d279)), closes [#2289](https://github.com/GetStream/stream-chat-react/issues/2289)
24+
* add customizable reactions sorting ([#2289](https://github.com/GetStream/stream-chat-react/issues/2289)) ([78c6107](https://github.com/GetStream/stream-chat-react/commit/78c6107e6437a1761f3b3e69f44c5c80979c88b1))
25+
126
## [11.9.0](https://github.com/GetStream/stream-chat-react/compare/v11.8.0...v11.9.0) (2024-02-21)
227

328

developers/DOCUMENTATION.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ If you are introducing changes impacting the API or behavior of the SDK parts, y
1010

1111

1212
```bash
13-
yarn docs-run
13+
yarn docs:run
1414
```
1515

1616
## Documentation patterns
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
+59-157
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,76 @@
11
---
22
id: getting_started
3-
sidebar_position: 2
43
title: Getting Started
54
---
65

7-
This section provides a high level overview of the library setup, core components, and how they fit together. It's a great
8-
starting point and you can follow along in your code editor. For a complete, step-by-step guide in terms setting up a React
9-
project or instructions on creating specific files, see our [React Chat tutorial](https://getstream.io/chat/react-chat/tutorial/).
6+
This section provides a high level overview of the library setup, core components, and how they fit together. It's a great starting point and you can follow along in your code editor. For a complete, step-by-step guide in terms setting up a React project or instructions on creating specific files, see our [React Chat tutorial](https://getstream.io/chat/react-chat/tutorial/).
107

118
## Your First App with Stream Chat React
129

1310
Before starting, make sure you have installed `stream-chat-react` (and `stream-chat`), as directed in the
1411
[Installation](./installation.mdx) section.
1512

16-
The below example is all the code you need to launch a fully functioning chat experience. The [`Chat`](../components/core-components/chat.mdx)
17-
and [`Channel`](../components/core-components/channel.mdx) components are React context providers that pass a variety of values to their
18-
children, including UI components, stateful data, and action handler functions.
13+
You'll also need to [register](https://getstream.io/chat/trial/) and create a free tier (for up to 25 MAU) Stream application to access credentials from which you'll be able to [generate a token](https://getstream.io/chat/docs/react/token_generator/) for a user which can access your chat application.
1914

20-
```jsx
21-
const App = () => (
22-
<Chat client={client}>
23-
<Channel channel={channel}>
24-
<Window>
25-
<ChannelHeader />
26-
<MessageList />
27-
<MessageInput />
28-
</Window>
29-
<Thread />
30-
</Channel>
31-
</Chat>
32-
);
33-
```
15+
The example below is all the code you'll need to launch a fully functioning chat experience. The [`Chat`](../components/core-components/chat.mdx) and [`Channel`](../components/core-components/channel.mdx) components are React context providers that pass a variety of values to their children, including UI components, stateful data, and action handler functions.
3416

35-
## Creating a Chat Client
17+
```jsx
18+
import {
19+
Chat,
20+
Channel,
21+
ChannelList,
22+
Window,
23+
ChannelHeader,
24+
MessageList,
25+
MessageInput,
26+
Thread,
27+
useCreateChatClient,
28+
} from 'stream-chat-react';
29+
import 'stream-chat-react/dist/css/v2/index.css';
3630

37-
To communicate with the Stream Chat API, create an instance of Stream Chat client with your API key and pass via props into the `Chat`
38-
component. To generate an API key, you can sign up for a [free 30-day trial](https://getstream.io/chat/trial/) on our website.
31+
const apiKey = 'your-api-key';
32+
const userId = 'user-id';
33+
const token = 'authentication-token';
3934

40-
Initialize the Stream Chat client:
35+
const filters = { members: { $in: [userId] }, type: 'messaging' };
36+
const options = { presence: true, state: true };
37+
const sort = { last_message_at: -1 };
4138

42-
```jsx
43-
import { StreamChat } from 'stream-chat';
39+
const App = () => {
40+
const client = useCreateChatClient({
41+
apiKey,
42+
tokenOrProvider: token,
43+
userData: { id: userId },
44+
});
4445

45-
const client = new StreamChat('your_api_key');
46+
if (!client) return <div>Loading...</div>;
4647

47-
<Chat client={client}>{/** children of Chat component*/}</Chat>;
48+
return (
49+
<Chat client={client}>
50+
<ChannelList sort={sort} filters={filters} options={options} />
51+
<Channel>
52+
<Window>
53+
<ChannelHeader />
54+
<MessageList />
55+
<MessageInput />
56+
</Window>
57+
<Thread />
58+
</Channel>
59+
</Chat>
60+
);
61+
};
4862
```
4963

50-
## Connecting a User
64+
## Chat Client & Connecting User
5165

52-
Tokens are used to authenticate a user. Typically, you send this token from your backend to your front end when a user logs in.
53-
See the [Tokens & Authentication](https://getstream.io/chat/docs/javascript/tokens_and_authentication/) documentation to learn more
54-
about creating tokens. For our purposes here, we will assume you have created and retrieved a `userToken`.
55-
56-
To connect a user, call the `connectUser` method on your client instance with the user object and `userToken` provided as arguments.
57-
Connect the user directly after instantiating the client to establish a websocket connection with the Stream Chat API. Once the connection
58-
has been opened, your client instance will begin receiving events from the API.
59-
60-
```jsx
61-
client.connectUser(
62-
{
63-
id: 'dave-matthews',
64-
name: 'Dave Matthews',
65-
},
66-
userToken,
67-
);
68-
```
66+
To communicate with the Stream Chat API the SDK requires a client with an established connection. The hook mentioned in the code above (`useCreateChatClient`) handles client instantiation, establishes proper connection and handles cleanups and disconnects for you. If you wish to have more control over how all of the previously mentioned is being handled see [Client and User](../guides/client-and-user.mdx) guide.
6967

7068
## Creating a Channel
7169

7270
Channels are at the core of Stream Chat. Within a channel you send/receive messages and interact with other users. Once a channel
7371
object has been initialized, the `Channel` component consumes the object and renders your chat app's functionality.
7472

75-
By default, the Stream Chat API provides support for five different [channel types](https://getstream.io/chat/docs/react/channel_features/)
73+
By default, the Stream Chat API provides support for five different [channel types](https://getstream.io/chat/docs/react/channel_features)
7674
of varying use cases. A channel type is required when creating a channel and dictates the available features and permissions.
7775
The defaults include:
7876

@@ -95,66 +93,44 @@ To create an instance of a channel, call the `channel` method on your client ins
9593

9694
```jsx
9795
const channel = client.channel('messaging', {
98-
image: 'dave.png',
99-
name: 'Create a Messaging Channel',
96+
image: 'https://cdn.com/image.png',
97+
name: 'Just Chatting',
10098
members: ['dave-matthews', 'trey-anastasio'],
10199
// option to add custom fields
102100
});
103101
```
104102

105-
## Setting Up the UI Components
103+
## Setting Up the Components
106104

107105
Now that we have a client instance, a connected user, and a channel, it's time to look at the core components involved in building
108106
a fully functioning chat application.
109107

110108
### Chat
111109

112-
The [`Chat`](../components/core-components/chat.mdx) component is a React Context provider that wraps the entire Stream Chat application. It provides the [`ChatContext`](../components/contexts/chat-context.mdx)
113-
to its children, which includes the `StreamChat` client instance. All other components within the library must be nested as children
114-
of `Chat` to maintain proper functionality.
110+
The [`Chat`](../components/core-components/chat.mdx) component is a React Context provider that wraps the entire Stream Chat application. It provides the [`ChatContext`](../components/contexts/chat-context.mdx) to its children, which includes the `StreamChat` client instance. All other components within the library must be nested as children of `Chat` to maintain proper functionality.
115111

116112
The client instance can be accessed with our custom context hook:
117113

118114
```jsx
115+
import { useChatContext } from 'stream-chat-react';
116+
117+
// ...
118+
119119
const { client } = useChatContext();
120120
```
121121

122122
### Channel
123123

124-
The [`Channel`](../components/core-components/channel.mdx) component is a React Context provider that wraps all of the logic, functionality, and UI for an individual chat channel.
125-
It provides five separate contexts to its children:
126-
127-
:::caution
128-
`EmojiContext` has been removed in version `11.0.0`, see related release guides ([Introducing new reactions](../release-guides/upgrade-to-v11.mdx#introducing-new-reactions), [Dropping support for built-in `EmojiPicker`](../release-guides/upgrade-to-v11.mdx#dropping-support-for-built-in-emojipicker) and [Dropping support for built-in `EmojiIndex`](../release-guides/upgrade-to-v11.mdx#dropping-support-for-built-in-emojiindex)) to adjust your integration to this new change.
129-
:::
124+
The [`Channel`](../components/core-components/channel.mdx) component is a React Context provider that wraps all of the logic, functionality, and UI for an individual chat channel. It provides five separate contexts to its children:
130125

131126
- [`ChannelStateContext`](../components/contexts/channel-state-context.mdx) - stateful data (ex: `messages` or `members`)
132127
- [`ChannelActionContext`](../components/contexts/channel-action-context.mdx) - action handlers (ex: `sendMessage` or `openThread`)
133128
- [`ComponentContext`](../components/contexts/component-context.mdx) - custom component UI overrides (ex: `Avatar` or `Message`)
134-
- [`EmojiContext`](../components/contexts/emoji-context.mdx) - emoji UI components and data (ex: `EmojiPicker` or `emojiConfig`) - removed in `11.0.0`
135129
- [`TypingContext`](../components/contexts/typing-context.mdx) - object of currently typing users (i.e., `typing`)
136130

137131
### ChannelList
138132

139-
The [`ChannelList`](../components/core-components/channel-list.mdx) component renders a list of channels and provides a preview for each. Though the `ChannelList` is essential in many chat apps,
140-
it isn't a required piece of the library. If a `ChannelList` component is used, a channel object should not be placed as a prop on the `Channel`
141-
component, as the `ChannelList` handles channel setting internally.
142-
143-
```jsx
144-
const App = () => (
145-
<Chat client={client}>
146-
<ChannelList />
147-
<Channel>
148-
<Window>
149-
<ChannelHeader />
150-
<MessageList />
151-
<MessageInput />
152-
</Window>
153-
<Thread />
154-
</Channel>
155-
</Chat>
156-
);
157-
```
133+
The [`ChannelList`](../components/core-components/channel-list.mdx) component renders a list of channels and provides a preview for each. Though the `ChannelList` is essential in many chat apps, it isn't a required piece of the library. If a `ChannelList` component is used, a channel object should not be placed as a prop on the `Channel` component, as the `ChannelList` handles channel setting internally.
158134

159135
### Window
160136

@@ -178,84 +154,10 @@ The [`Thread`](../components/core-components/thread.mdx) component renders a lis
178154

179155
### Emojis (picker & autocomplete)
180156

181-
The SDK is equipped with features designed to facilitate seamless integration, enabling developers to effortlessly incorporate emoji picker and emoji autocomplete (built on top of [`emoji-mart`](https://github.com/missive/emoji-mart)) functionalities for a comprehensive chat experience.
182-
183-
Starting from version `11.0.0`, these features are entirely optional, requiring integrators to opt-in manually. The decision was made in conjunction with enhanced architecture, aiming to reduce the overall size of the final bundles of our integrators.
157+
The SDK is equipped with features designed to facilitate seamless integration, enabling developers to effortlessly incorporate [emoji picker](../guides/customization/emoji-picker.mdx) and emoji autocomplete (built on top of [`emoji-mart`](https://github.com/missive/emoji-mart)) functionalities for a comprehensive chat experience.
184158

185-
Make sure to read ["Dropping support for built-in `EmojiPicker`"](../release-guides/upgrade-to-v11.mdx#dropping-support-for-built-in-emojipicker) and ["Dropping support for built-in `EmojiIndex`"](../release-guides/upgrade-to-v11.mdx#dropping-support-for-built-in-emojiindex) release guides for more information.
186-
187-
## Summary
188-
189-
In addition to the above referenced UI components, client instantiation, and user connection, you need little other code to get a fully functioning chat application up and running. See below for an example of the complete code.
159+
Make sure to read [_Dropping support for built-in `EmojiPicker`_](../release-guides/upgrade-to-v11.mdx#dropping-support-for-built-in-emojipicker) and [_Dropping support for built-in `EmojiIndex`_](../release-guides/upgrade-to-v11.mdx#dropping-support-for-built-in-emojiindex) release guides for more information.
190160

191161
:::note
192-
Remember our [Theming](../guides/theming/overview.mdx) and [Customizing Components](../guides/customization/overview.mdx) sections in our guides. They offer you a lot of flexibility when adopting our SDK.
162+
Read more about customization in our [Theming](../theming/introduction.mdx) and [Customizing Components](../guides/customization/overview.mdx) guides.
193163
:::
194-
195-
```tsx
196-
import React, { useEffect, useState } from 'react';
197-
import { StreamChat } from 'stream-chat';
198-
import {
199-
Chat,
200-
Channel,
201-
ChannelHeader,
202-
ChannelList,
203-
MessageList,
204-
MessageInput,
205-
Thread,
206-
Window,
207-
} from 'stream-chat-react';
208-
import 'stream-chat-react/dist/css/v2/index.css';
209-
210-
const filters = { type: 'messaging' };
211-
const options = { state: true, presence: true, limit: 10 };
212-
const sort = { last_message_at: -1 };
213-
214-
const App = () => {
215-
const [client, setClient] = useState(null);
216-
217-
useEffect(() => {
218-
const newClient = new StreamChat('your_api_key');
219-
220-
const handleConnectionChange = ({ online = false }) => {
221-
if (!online) return console.log('connection lost');
222-
setClient(newClient);
223-
};
224-
225-
newClient.on('connection.changed', handleConnectionChange);
226-
227-
newClient.connectUser(
228-
{
229-
id: 'dave-matthews',
230-
name: 'Dave Matthews',
231-
},
232-
'your_user_token',
233-
);
234-
235-
return () => {
236-
newClient.off('connection.changed', handleConnectionChange);
237-
newClient.disconnectUser().then(() => console.log('connection closed'));
238-
};
239-
}, []);
240-
241-
if (!client) return null;
242-
243-
return (
244-
<Chat client={client}>
245-
<ChannelList filters={filters} sort={sort} options={options} />
246-
<Channel>
247-
<Window>
248-
<ChannelHeader />
249-
<MessageList />
250-
<MessageInput />
251-
</Window>
252-
<Thread />
253-
</Channel>
254-
</Chat>
255-
);
256-
};
257-
258-
export default App;
259-
```
260-
261-
With a basic chat app up and running with our default UI, it's time to take a deep dive into each individual component in the library.

0 commit comments

Comments
 (0)