Skip to content

Commit e9a3811

Browse files
committed
fix: remove ne filter from user/member query
1 parent d50d872 commit e9a3811

5 files changed

Lines changed: 27 additions & 8 deletions

File tree

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1857,7 +1857,13 @@ describe('ChannelService', () => {
18571857
await init();
18581858
const channel = generateMockChannels(1)[0];
18591859
channel.cid = 'new-channel';
1860-
spyOn(channel, 'queryMembers').and.callThrough();
1860+
spyOn(channel, 'queryMembers').and.resolveTo({
1861+
members: [
1862+
{ user_id: mockCurrentUser().id },
1863+
{ user_id: 'jack' },
1864+
] as unknown as ChannelMemberResponse<DefaultStreamChatGenerics>[],
1865+
duration: '0ms',
1866+
});
18611867
const users = Array.from({ length: 101 }, (_, i) => ({ id: `${i}` }));
18621868
channel.state.members = {} as any as Record<
18631869
string,

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,9 +1063,11 @@ export class ChannelService<
10631063
}
10641064
const result = await activeChannel.queryMembers({
10651065
name: { $autocomplete: searchTerm },
1066-
id: { $ne: this.chatClientService.chatClient.userID! },
10671066
} as UserFilters<T>); // TODO: find out why we need typecast here
1068-
return Object.values(result.members);
1067+
1068+
return result.members.filter(
1069+
(m) => m.user_id !== this.chatClientService.chatClient?.user?.id
1070+
);
10691071
}
10701072
}
10711073

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,15 @@ describe('ChatClientService', () => {
319319
expect(mockChatClient.flagMessage).toHaveBeenCalledWith('messageId');
320320
});
321321

322-
it('should query members', async () => {
323-
mockChatClient.queryUsers.and.returnValue({ users: [{}, {}] });
322+
it('should query users', async () => {
323+
mockChatClient.queryUsers.and.returnValue({
324+
users: [
325+
{
326+
id: mockCurrentUser().id,
327+
},
328+
{ id: 'zizi' },
329+
],
330+
});
324331
const result = await service.autocompleteUsers('zi');
325332

326333
expect(mockChatClient.queryUsers).toHaveBeenCalledWith(
@@ -332,7 +339,7 @@ describe('ChatClientService', () => {
332339
})
333340
);
334341

335-
expect(result.length).toBe(2);
342+
expect(result.length).toBe(1);
336343
});
337344

338345
it('should initialize pending invites', async () => {

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,8 @@ export class ChatClientService<
230230
{ id: { $autocomplete: searchTerm } },
231231
{ name: { $autocomplete: searchTerm } },
232232
],
233-
id: { $ne: this.chatClient.userID! },
234233
} as UserFilters<T>); // TODO: find out why we need this typecast
235-
return result.users;
234+
return result.users.filter((u) => u.id !== this.chatClient?.user?.id);
236235
}
237236

238237
private updatePendingInvites(e: Event<T>) {

projects/stream-chat-angular/src/lib/mocks/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,11 @@ export const generateMockChannels = (length = 25) => {
188188
id: 'jack',
189189
},
190190
},
191+
john: {
192+
user: {
193+
id: 'john',
194+
},
195+
},
191196
},
192197
}),
193198
getConfig: () => ({

0 commit comments

Comments
 (0)