Skip to content

Commit

Permalink
Merge pull request #618 from GetStream/v5-disable-channel-invites
Browse files Browse the repository at this point in the history
V5 disable channel invites
  • Loading branch information
szuperaz authored Jun 17, 2024
2 parents f79becb + 85a44fe commit e1e81b4
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
10 changes: 10 additions & 0 deletions docusaurus/angular_versioned_docs/version-5/basics/upgrade-v4.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,16 @@ To allow better customization for loading indicator, the `size` input has been r

With this change the `size` input is no longer supported on the [`LoadingIndicatorPlaceholderComponent`](../../components/LoadingIndicatorPlaceholderComponent), [`LoadingIndicatorComponent`](../../components/LoadingIndicatorComponent), and the [`loadingIndicatorTemplate$`](../../services/CustomTemplatesService/#loadingindicatortemplate). The `loadingIndicatorTemplate$` now accepts `TemplateRef<void>` instead of `TemplateRef<LoadingIndicatorContext>`

### Channel invites

Keeping track of pending channel invites is no longer automatic. If you want to enable this behavior you need to initialize the [`ChatClientService`](../services/ChatClientService.mdx) with the following flag:

```typescript
this.chatService.init("<API key>", "<user>", "<token provider>", {
trackPendingChannelInvites: true,
});
```

## Other changes

### Unused packages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,14 @@ Add a reference to the template in your `app.component.ts`:

#### Displaying the invitations

The [`ChatClientService`](../services/ChatClientService.mdx) can keep track of pending invites, to enable this you have to initialize the service with the following flag:

```typescript
this.chatService.init("<API key>", "<user>", "<token provider>", {
trackPendingChannelInvites: true,
});
```

The `pendingInvites$` Observable on the [`ChatClientService`](../services/ChatClientService.mdx) can notify us about the pending invitations of the current user. Let's subscribe to this Observable and [display the invites](../services/NotificationService.mdx) in the `ngOnInit` method of the `app.component.ts`

```typescript
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,9 @@ describe('ChatClientService', () => {
const invitesSpy = jasmine.createSpy();
service.pendingInvites$.subscribe(invitesSpy);
invitesSpy.calls.reset();
await service.init(apiKey, userId, userToken);
await service.init(apiKey, userId, userToken, {
trackPendingChannelInvites: true,
});

expect(mockChatClient.queryChannels).toHaveBeenCalledWith({
invite: 'pending',
Expand All @@ -312,7 +314,10 @@ describe('ChatClientService', () => {
expect(invitesSpy).toHaveBeenCalledWith(channelsWithPendingInvites);
});

it('should emit pending invitations of user', () => {
it('should emit pending invitations of user', async () => {
await service.init(apiKey, userId, userToken, {
trackPendingChannelInvites: true,
});
const invitesSpy = jasmine.createSpy();
service.pendingInvites$.subscribe(invitesSpy);
const event1 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export class ChatClientService<
clientOptions?: StreamChatOptions & { trackPendingChannelInvites?: boolean }
): ConnectAPIResponse<T> {
this.trackPendingChannelInvites =
clientOptions?.trackPendingChannelInvites !== false;
clientOptions?.trackPendingChannelInvites === true;
this.chatClient = StreamChat.getInstance<T>(apiKey, clientOptions);
this.chatClient.recoverStateOnReconnect = false;
this.chatClient.devToken;
Expand Down

0 comments on commit e1e81b4

Please sign in to comment.