Skip to content

Commit

Permalink
fix: offset parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
szuperaz committed Nov 20, 2023
1 parent d947aec commit c655e6e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion projects/stream-chat-angular/src/lib/channel.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ describe('ChannelService', () => {
});

it('should use provided options params', async () => {
const options: ChannelOptions = { offset: 5 };
const options: ChannelOptions = { limit: 5 };
await init(undefined, undefined, options);

expect(mockChatClient.queryChannels).toHaveBeenCalledWith(
Expand Down Expand Up @@ -373,6 +373,10 @@ describe('ChannelService', () => {

it('should load more channels and filter duplicates', async () => {
await init();

// Check that offset is set properly after query
expect(service['options']?.offset).toEqual(service.channels.length);

mockChatClient.queryChannels.calls.reset();
const existingChannel = service.channels[0];
const newChannel = generateMockChannels(1)[0];
Expand Down
2 changes: 1 addition & 1 deletion projects/stream-chat-angular/src/lib/channel.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,6 @@ export class ChannelService<
* Loads the next page of channels. The page size can be set in the [query option](https://getstream.io/chat/docs/javascript/query_channels/?language=javascript#query-options) object.
*/
async loadMoreChannels() {
this.options!.offset = this.channels.length!;
await this.queryChannels(false);
}

Expand Down Expand Up @@ -1486,6 +1485,7 @@ export class ChannelService<
this.sort || {},
this.options
);
this.options!.offset = channels.length!;
channels.forEach((c) => this.watchForChannelEvents(c));
const prevChannels = recoverState
? []
Expand Down

0 comments on commit c655e6e

Please sign in to comment.