Skip to content

Commit

Permalink
Merge pull request #2124 from GetStream/develop
Browse files Browse the repository at this point in the history
v10.14.0
  • Loading branch information
MartinCupela authored Oct 11, 2023
2 parents 838d577 + 5d87d9d commit d3fc68c
Show file tree
Hide file tree
Showing 5 changed files with 398 additions and 92 deletions.
4 changes: 4 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
{
"name": "beta",
"prerelease": true
},
{
"name": "rc",
"prerelease": true
}
],
"plugins": [
Expand Down
33 changes: 33 additions & 0 deletions docusaurus/docs/React/components/core-components/channel-list.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,39 @@ Custom UI component to display the channel preview in the list.
| --------- | ---------------------------------------------------------------------------------------------------- |
| component | <GHComponentLink text='ChannelPreviewMessenger' path='/ChannelPreview/ChannelPreviewMessenger.tsx'/> |

### recoveryThrottleIntervalMs

Custom interval during which the recovery channel list queries will be prevented. This is to avoid firing unnecessary queries during internet connection fluctuation. Recovery channel query is triggered upon internet connection recovery and leads to complete channel list reload with pagination offset 0. The minimum throttle interval is 2000ms. The default throttle interval is 5000ms.

The channel list recovery mechanism described here (applying `recoveryThrottleIntervalMs`) **is activated only if the `StreamChat` client's channel list recovery mechanism is disabled**. The `StreamChat` recovery mechanism can be disabled when initiating the client instance through the `options` parameter:

```typescript jsx
import { StreamChat } from 'stream-chat';
import { ChannelList, Chat } from 'stream-chat-react';

// ... get apiKey, filters, sort, options

const client = new StreamChat(apiKey, {recoverStateOnReconnect: false});
const App = () => (
<Chat client={client} >
{/** ... */}
<ChannelList
filters={filters}
sort={sort}
options={options}
recoveryThrottleIntervalMs={3000}
{/** other props... */}
/>
{/** ... */}
</Chat>
);

```

| Type | Default |
|--------|---------|
| number | 5000 |

### renderChannels

Function to override the default behavior when rendering channels, so this function is called instead of rendering the Preview directly.
Expand Down
9 changes: 9 additions & 0 deletions src/components/ChannelList/ChannelList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@ export type ChannelListProps<
Paginator?: React.ComponentType<PaginatorProps | LoadMorePaginatorProps>;
/** Custom UI component to display the channel preview in the list, defaults to and accepts same props as: [ChannelPreviewMessenger](https://github.com/GetStream/stream-chat-react/blob/master/src/components/ChannelPreview/ChannelPreviewMessenger.tsx) */
Preview?: React.ComponentType<ChannelPreviewUIComponentProps<StreamChatGenerics>>;
/**
* Custom interval during which the recovery channel list queries will be prevented.
* This is to avoid firing unnecessary queries during internet connection fluctuation.
* Recovery channel query is triggered upon `connection.recovered` and leads to complete channel list reload with pagination offset 0.
* The minimum throttle interval is 2000ms. The default throttle interval is 5000ms.
*/
recoveryThrottleIntervalMs?: number;
/** Function to override the default behavior when rendering channels, so this function is called instead of rendering the Preview directly */
renderChannels?: (
channels: Channel<StreamChatGenerics>[],
Expand Down Expand Up @@ -167,6 +174,7 @@ const UnMemoizedChannelList = <
options,
Paginator = LoadMorePaginator,
Preview,
recoveryThrottleIntervalMs,
renderChannels,
sendChannelsToList = false,
setActiveChannelOnMount = true,
Expand Down Expand Up @@ -256,6 +264,7 @@ const UnMemoizedChannelList = <
sort || DEFAULT_SORT,
options || DEFAULT_OPTIONS,
activeChannelHandler,
recoveryThrottleIntervalMs,
);

const loadedChannels = channelRenderFilterFn ? channelRenderFilterFn(channels) : channels;
Expand Down
Loading

0 comments on commit d3fc68c

Please sign in to comment.