Skip to content

Commit 6d550d4

Browse files
committed
fix: temporarily bring back limits
1 parent 3e43a2f commit 6d550d4

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

examples/SampleApp/src/screens/ChannelListScreen.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ const options = {
6767
presence: true,
6868
state: true,
6969
watch: true,
70+
message_limit: 25,
7071
};
7172

7273
const HeaderNetworkDownIndicator = () => null;

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,10 @@ describe('useMessageListPagination', () => {
161161

162162
await waitFor(() => {
163163
expect(queryFn).toHaveBeenCalledWith({
164-
messages: { id_lt: messages[0].id },
165-
watchers: {},
164+
messages: { id_lt: messages[0].id, limit: 10 },
165+
watchers: {
166+
limit: 10,
167+
},
166168
});
167169
expect(result.current.state.hasMore).toBe(true);
168170
expect(result.current.state.messages.length).toBe(40);
@@ -252,8 +254,8 @@ describe('useMessageListPagination', () => {
252254

253255
await waitFor(() => {
254256
expect(queryFn).toHaveBeenCalledWith({
255-
messages: { id_gt: messages[messages.length - 1].id },
256-
watchers: {},
257+
messages: { id_gt: messages[messages.length - 1].id, limit: 10 },
258+
watchers: { limit: 10 },
257259
});
258260
expect(result.current.state.hasMore).toBe(true);
259261
expect(result.current.state.messages.length).toBe(40);

package/src/components/Channel/hooks/useMessageListPagination.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export const useMessageListPagination = ({ channel }: { channel: Channel }) => {
7474
/**
7575
* This function loads more messages before the first message in current channel state.
7676
*/
77-
const loadMore = useStableCallback(async (limit?: number) => {
77+
const loadMore = useStableCallback(async (limit: number = 10) => {
7878
if (!channel.state.messagePagination.hasPrev) {
7979
return;
8080
}
@@ -103,7 +103,7 @@ export const useMessageListPagination = ({ channel }: { channel: Channel }) => {
103103
/**
104104
* This function loads more messages after the most recent message in current channel state.
105105
*/
106-
const loadMoreRecent = useStableCallback(async (limit?: number) => {
106+
const loadMoreRecent = useStableCallback(async (limit: number = 10) => {
107107
if (!channel.state.messagePagination.hasNext) {
108108
return;
109109
}

0 commit comments

Comments
 (0)