Skip to content

Commit fae0b0e

Browse files
committed
fix: Remove unnecessary channel list emit from custom channel list setter
1 parent e4cd8fd commit fae0b0e

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ describe('ChannelService', () => {
766766
expect(channel.on).toHaveBeenCalledWith(jasmine.any(Function));
767767
}));
768768

769-
it(`shouldn't add channels duplicated if two notification event is received for the same channel`, fakeAsync(async () => {
769+
it(`shouldn't add channels twice if two notification events were received for the same channel`, fakeAsync(async () => {
770770
await init();
771771
const channel = generateMockChannels()[0];
772772
channel.cid = 'channel';

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -273,11 +273,8 @@ export class ChannelService<
273273
const deletedChannels = currentChannels.filter(
274274
(c) => !channels?.find((channel) => channel.cid === c.cid)
275275
);
276-
this.addChannelsFromNotification(newChannels as ChannelResponse<T>[]);
276+
void this.addChannelsFromNotification(newChannels as ChannelResponse<T>[]);
277277
this.removeChannelsFromChannelList(deletedChannels.map((c) => c.cid));
278-
if (!newChannels.length && !deletedChannels.length) {
279-
this.channelsSubject.next(channels as Channel<T>[]);
280-
}
281278
};
282279

283280
private messageListSetter = (messages: StreamMessage<T>[]) => {
@@ -866,13 +863,13 @@ export class ChannelService<
866863

867864
private handleNewMessageNotification(clientEvent: ClientEvent<T>) {
868865
if (clientEvent.event.channel) {
869-
this.addChannelsFromNotification([clientEvent.event.channel]);
866+
void this.addChannelsFromNotification([clientEvent.event.channel]);
870867
}
871868
}
872869

873870
private handleAddedToChannelNotification(clientEvent: ClientEvent<T>) {
874871
if (clientEvent.event.channel) {
875-
this.addChannelsFromNotification([clientEvent.event.channel]);
872+
void this.addChannelsFromNotification([clientEvent.event.channel]);
876873
}
877874
}
878875

0 commit comments

Comments
 (0)