Skip to content

Commit be23e4e

Browse files
committed
feat: customPaginator is removed from ChannelService
BREAKING CHANGE: `channelService.customPaginator` is removed, provide a custom query if you want to control pagination logic
1 parent 390862d commit be23e4e

File tree

2 files changed

+0
-54
lines changed

2 files changed

+0
-54
lines changed

projects/stream-chat-angular/src/lib/channel.service.spec.ts

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -248,37 +248,6 @@ describe('ChannelService', () => {
248248
/* eslint-enable @typescript-eslint/no-unsafe-member-access */
249249
});
250250

251-
it('should set pagination options correctly if #customPaginator is provided', async () => {
252-
service.customPaginator = (
253-
channelQueryResult: Channel<DefaultStreamChatGenerics>[],
254-
) => {
255-
const lastChannel = channelQueryResult[channelQueryResult.length - 1];
256-
if (!lastChannel) {
257-
return {
258-
type: 'filter',
259-
paginationFilter: {},
260-
};
261-
} else {
262-
return {
263-
type: 'filter',
264-
paginationFilter: {
265-
cid: { $gte: lastChannel.cid },
266-
},
267-
};
268-
}
269-
};
270-
271-
await init();
272-
273-
// @ts-expect-error we know channelQuery exists, TS doesn't
274-
expect(service['channelQuery']?.['nextPageConfiguration']).toEqual({
275-
type: 'filter',
276-
paginationFilter: {
277-
cid: { $gte: jasmine.any(String) },
278-
},
279-
});
280-
});
281-
282251
it('should not set active channel if #shouldSetActiveChannel is false', async () => {
283252
const activeChannelSpy = jasmine.createSpy();
284253
service.activeChannel$.subscribe(activeChannelSpy);

projects/stream-chat-angular/src/lib/channel.service.ts

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ import {
3838
DefaultStreamChatGenerics,
3939
MessageInput,
4040
MessageReactionType,
41-
NextPageConfiguration,
4241
StreamMessage,
4342
} from './types';
4443
import { ChannelQuery } from './channel-query';
@@ -360,9 +359,6 @@ export class ChannelService<
360359
private channelQuery?:
361360
| ChannelQuery<T>
362361
| ((queryType: ChannelQueryType) => Promise<ChannelQueryResult<T>>);
363-
private _customPaginator:
364-
| ((channelQueryResult: Channel<T>[]) => NextPageConfiguration)
365-
| undefined;
366362

367363
private channelListSetter = (
368364
channels: Channel<T>[],
@@ -533,24 +529,6 @@ export class ChannelService<
533529
this._shouldMarkActiveChannelAsRead = shouldMarkActiveChannelAsRead;
534530
}
535531

536-
/**
537-
* By default the SDK uses an offset based pagination, you can change/extend this by providing your own custom paginator method.
538-
*
539-
* The method will be called with the result of the latest channel query.
540-
*
541-
* You can return either an offset, or a filter using the [`$lte`/`$gte` operator](/chat/docs/javascript/query_syntax_operators/). If you return a filter, it will be merged with the filter provided for the `init` method.
542-
*/
543-
set customPaginator(
544-
paginator:
545-
| ((channelQueryResult: Channel<T>[]) => NextPageConfiguration)
546-
| undefined,
547-
) {
548-
this._customPaginator = paginator;
549-
if (this.channelQuery && 'customPaginator' in this.channelQuery) {
550-
this.channelQuery.customPaginator = this._customPaginator;
551-
}
552-
}
553-
554532
/**
555533
* Sets the given `channel` as active and marks it as read.
556534
* If the channel wasn't previously part of the channel, it will be added to the beginning of the list.
@@ -745,7 +723,6 @@ export class ChannelService<
745723
...options,
746724
},
747725
);
748-
this.channelQuery.customPaginator = this._customPaginator;
749726

750727
return this._init({
751728
shouldSetActiveChannel,

0 commit comments

Comments
 (0)