Skip to content

Commit

Permalink
fix: make initial message pagination state pesimistic (#1444)
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinCupela authored Jan 28, 2025
1 parent c9861fd commit 24c94a4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const DEFAULT_QUERY_CHANNELS_MESSAGE_LIST_PAGE_SIZE = 25;
export const DEFAULT_QUERY_CHANNEL_MESSAGE_LIST_PAGE_SIZE = 100;

export const DEFAULT_MESSAGE_SET_PAGINATION = { hasNext: true, hasPrev: true };
export const DEFAULT_MESSAGE_SET_PAGINATION = { hasNext: false, hasPrev: false };
8 changes: 4 additions & 4 deletions test/unit/channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -1272,7 +1272,7 @@ describe('Channel.query', async () => {
mock.restore();
});

it('should not update pagination for queried message set', async () => {
it('should update pagination for queried message set to prevent more pagination', async () => {
const client = await getClientWithUser();
const channel = client.channel('messaging', uuidv4());
const mockedChannelQueryResponse = {
Expand All @@ -1283,11 +1283,11 @@ describe('Channel.query', async () => {
mock.expects('post').returns(Promise.resolve(mockedChannelQueryResponse));
await channel.query();
expect(channel.state.messageSets.length).to.be.equal(1);
expect(channel.state.messageSets[0].pagination).to.eql({ hasNext: true, hasPrev: true });
expect(channel.state.messageSets[0].pagination).to.eql({ hasNext: false, hasPrev: true });
mock.restore();
});

it('should update pagination for queried message set to prevent more pagination', async () => {
it('should not update pagination for queried message set', async () => {
const client = await getClientWithUser();
const channel = client.channel('messaging', uuidv4());
const mockedChannelQueryResponse = {
Expand All @@ -1298,7 +1298,7 @@ describe('Channel.query', async () => {
mock.expects('post').returns(Promise.resolve(mockedChannelQueryResponse));
await channel.query();
expect(channel.state.messageSets.length).to.be.equal(1);
expect(channel.state.messageSets[0].pagination).to.eql({ hasNext: true, hasPrev: false });
expect(channel.state.messageSets[0].pagination).to.eql({ hasNext: false, hasPrev: false });
mock.restore();
});
});

0 comments on commit 24c94a4

Please sign in to comment.