Skip to content

Commit 9599e9d

Browse files
authored
feat: add pagination tools to ChannelList context (#2742)
1 parent 33e5fc9 commit 9599e9d

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

src/components/ChannelList/ChannelList.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,9 @@ const UnMemoizedChannelList = (props: ChannelListProps) => {
381381
const showChannelList =
382382
(!searchActive && !searchIsActive) || additionalChannelSearchProps?.popupResults;
383383
return (
384-
<ChannelListContextProvider value={{ channels, setChannels }}>
384+
<ChannelListContextProvider
385+
value={{ channels, hasNextPage, loadNextPage, setChannels }}
386+
>
385387
<div className={className} ref={channelListRef}>
386388
{showChannelSearch &&
387389
(Search ? (

src/components/ChannelList/hooks/usePaginatedChannels.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,7 @@ export const usePaginatedChannels = (
135135
queryChannels('reload');
136136
}, [error, queryChannels, recoveryThrottleInterval]);
137137

138-
const loadNextPage = () => {
139-
queryChannels();
140-
};
138+
const loadNextPage = () => queryChannels();
141139

142140
useEffect(() => {
143141
if (client.recoverStateOnReconnect) return;

src/context/ChannelListContext.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ export type ChannelListContextValue = {
99
* Channels query is executed by default only by ChannelList component in the SDK.
1010
*/
1111
channels: Channel[];
12+
/**
13+
* Indicator for channel pagination to determine whether more items can be loaded
14+
*/
15+
hasNextPage: boolean;
16+
/**
17+
* Pagination function to load more channels
18+
*/
19+
loadNextPage(): Promise<void>;
1220
/**
1321
* Sets the list of Channel objects to be rendered by ChannelList component.
1422
*/

0 commit comments

Comments
 (0)