Skip to content

Commit 2ef2fd3

Browse files
committed
Merge branch 'master' into feat/remove-legacy-style-components
# Conflicts: # src/components/MessageInput/MessageInputFlat.tsx # src/components/MessageInput/__tests__/MessageInput.test.js
2 parents bfc0f96 + f2ed479 commit 2ef2fd3

File tree

5 files changed

+68
-29
lines changed

5 files changed

+68
-29
lines changed

.github/workflows/release.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
name: Release from "${{ github.ref_name }}" branch
2525
runs-on: ubuntu-latest
2626
# GH does not allow to limit branches in the workflow_dispatch settings so this here is a safety measure
27-
if: ${{ !inputs.docs_only && (github.ref_name == 'master' || github.ref_name == 'rc' || github.ref_name == 'release-v9') }}
27+
if: ${{ !inputs.docs_only && (startsWith(github.ref_name, 'release') || startsWith(github.ref_name, 'master')) }}
2828
env:
2929
NODE_OPTIONS: --max_old_space_size=4096
3030
steps:
@@ -53,8 +53,8 @@ jobs:
5353
docs_release:
5454
name: Publish documentation from "${{ github.ref_name }}" branch to ${{ inputs.docs_env }}
5555
runs-on: ubuntu-latest
56-
# skip during dry runs, release to production only from master, release to staging from anywhere
57-
if: ${{ !inputs.dry_run && ((github.ref_name == 'master' && contains('production,staging', inputs.docs_env)) || (github.ref_name != 'master' && inputs.docs_env == 'staging')) }}
56+
# skip during dry runs, publish to production only from branches with names starting with "release", publish to staging from anywhere
57+
if: ${{ !inputs.dry_run && ((startsWith(github.ref_name, "release") && inputs.docs_env == "production") || inputs.docs_env == "staging") }}
5858
outputs:
5959
target-version: $${{ steps.target-version.outputs }}
6060
steps:

.releaserc.json

+14-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
{
22
"branches": [
3-
"main",
4-
"master",
53
{
6-
"name": "beta",
4+
"name": "master",
5+
"channel": "rc",
76
"prerelease": true
87
},
98
{
10-
"name": "rc",
11-
"prerelease": true
9+
"name": "release-v11",
10+
"channel": "latest"
11+
},
12+
{
13+
"name": "release-v10",
14+
"channel": "v10",
15+
"range": "10.x"
16+
},
17+
{
18+
"name": "release-v9",
19+
"channel": "v9",
20+
"range": "9.x"
1221
}
1322
],
1423
"plugins": [

developers/RELEASE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ At the moment these manual actions have to be taken to achieve a successfull rel
1717
2. make sure that the peer dependencies `@stream-io/stream-chat-css` and `stream-chat-js` are installed at their latest version (see `package.json`, `yarn.lock`) (if applicable)
1818
3. squash-merge required pull requests to `master` branch with appropriate message name, for example: `fix(scope): new feature`, if this feature is breaking, make sure to include `BREAKING CHANGE: <reason>` in the message footer
1919
4. navigate to ["Actions"](https://github.com/GetStream/stream-chat-react/actions) and in the left bar select the "Release" workflow
20-
5. click "Run workflow" and select the branch you want to release from then adjust the prompt options and click "Run workflow", note that allowed branches for __PACKAGE RELEASE__ are: `master`, `release-v9` and `rc`, there's _is no such limititation_ for the __DOCUMENTATION RELEASE__, extend the workflow condition and `.releaserc.json` as needed
20+
5. click "Run workflow" and select the branch you want to release from then adjust the prompt options and click "Run workflow", note that allowed branches for __PACKAGE RELEASE__ are: branch names starting with `release` and `master`, there _is no such limititation_ for the __DOCUMENTATION RELEASE__, extend the workflow condition and `.releaserc.json` as needed. The `master` branch is the release-candidate branch.
2121

2222
## Available release prompt options
2323

src/components/Channel/Channel.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1142,7 +1142,7 @@ const ChannelInner = <
11421142

11431143
const loadMoreThread = async (limit: number = DEFAULT_THREAD_PAGE_SIZE) => {
11441144
// FIXME: should prevent loading more, if state.thread.reply_count === channel.state.threads[parentID].length
1145-
if (state.threadLoadingMore || !state.thread) return;
1145+
if (state.threadLoadingMore || !state.thread || !state.threadHasMore) return;
11461146

11471147
dispatch({ type: 'startLoadingThread' });
11481148
const parentId = state.thread.id;

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

+49-19
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { MessageList } from '../../MessageList';
3030
import { Thread } from '../../Thread';
3131
import { MessageProvider } from '../../../context';
3232
import { MessageActionsBox } from '../../MessageActions';
33+
import { DEFAULT_THREAD_PAGE_SIZE } from '../../../constants/limits';
3334

3435
jest.mock('../../Loading', () => ({
3536
LoadingErrorIndicator: jest.fn(() => <div />),
@@ -558,39 +559,68 @@ describe('Channel', () => {
558559
await waitFor(() => expect(hasThread).toHaveBeenCalledWith(threadMessage.id));
559560
});
560561

561-
it('should be able to load more messages in a thread', async () => {
562+
it('should be able to load more messages in a thread until reaching the end', async () => {
562563
const { channel, chatClient } = await initClient();
563564
const getRepliesSpy = jest.spyOn(channel, 'getReplies');
564565
const threadMessage = messages[0];
565-
566-
const replies = [generateMessage({ parent_id: threadMessage.id })];
566+
const replies = Array.from({ length: DEFAULT_THREAD_PAGE_SIZE }, () =>
567+
generateMessage({ parent_id: threadMessage.id }),
568+
);
567569

568570
useMockedApis(chatClient, [threadRepliesApi(replies)]);
569571

570572
const hasThreadMessages = jest.fn();
571573

572-
await renderComponent(
573-
{ channel, chatClient },
574-
({ loadMoreThread, openThread, thread, threadMessages }) => {
575-
if (!thread) {
576-
// first, open a thread
577-
openThread(threadMessage, { preventDefault: () => null });
578-
} else if (!threadMessages.length) {
579-
// then, load more messages in the thread
580-
loadMoreThread();
581-
} else {
582-
// then, call our mock fn so we can verify what was passed as threadMessages
583-
hasThreadMessages(threadMessages);
584-
}
585-
},
574+
let callback = ({ loadMoreThread, openThread, thread, threadMessages }) => {
575+
if (!thread) {
576+
// first, open a thread
577+
openThread(threadMessage, { preventDefault: () => null });
578+
} else if (!threadMessages.length) {
579+
// then, load more messages in the thread
580+
loadMoreThread();
581+
} else {
582+
// then, call our mock fn so we can verify what was passed as threadMessages
583+
hasThreadMessages(threadMessages);
584+
}
585+
};
586+
const { rerender } = await render(
587+
<Chat client={chatClient}>
588+
<Channel channel={channel}>
589+
<CallbackEffectWithChannelContexts callback={callback} />
590+
</Channel>
591+
</Chat>,
586592
);
587593

588594
await waitFor(() => {
595+
expect(getRepliesSpy).toHaveBeenCalledTimes(1);
589596
expect(getRepliesSpy).toHaveBeenCalledWith(threadMessage.id, expect.any(Object));
590-
});
591-
await waitFor(() => {
592597
expect(hasThreadMessages).toHaveBeenCalledWith(replies);
593598
});
599+
600+
useMockedApis(chatClient, [threadRepliesApi([])]);
601+
callback = ({ loadMoreThread }) => {
602+
loadMoreThread();
603+
};
604+
await act(() => {
605+
rerender(
606+
<Chat client={chatClient}>
607+
<Channel channel={channel}>
608+
<CallbackEffectWithChannelContexts callback={callback} />
609+
</Channel>
610+
</Chat>,
611+
);
612+
});
613+
expect(getRepliesSpy).toHaveBeenCalledTimes(2);
614+
await act(() => {
615+
rerender(
616+
<Chat client={chatClient}>
617+
<Channel channel={channel}>
618+
<CallbackEffectWithChannelContexts callback={callback} />
619+
</Channel>
620+
</Chat>,
621+
);
622+
});
623+
expect(getRepliesSpy).toHaveBeenCalledTimes(2);
594624
});
595625

596626
it('should allow closing a thread after it has been opened', async () => {

0 commit comments

Comments
 (0)