stream-chat-angular 3.7.4 → 3.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- export declare const version = "3.7.4";
1
+ export declare const version = "3.8.2";
@@ -354,7 +354,7 @@
354
354
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
355
355
  }
356
356
 
357
- var version = '3.7.4';
357
+ var version = '3.8.2';
358
358
 
359
359
  /**
360
360
  * The `NotificationService` can be used to add or remove notifications. By default the [`NotificationList`](../components/NotificationListComponent.mdx) component displays the currently active notifications.
@@ -461,7 +461,7 @@
461
461
  * Creates a [`StreamChat`](https://github.com/GetStream/stream-chat-js/blob/668b3e5521339f4e14fc657834531b4c8bf8176b/src/client.ts#L124) instance using the provided `apiKey`, and connects a user with the given meta data and token. More info about [connecting users](https://getstream.io/chat/docs/javascript/init_and_users/?language=javascript) can be found in the platform documentation.
462
462
  * @param apiKey
463
463
  * @param userOrId
464
- * @param userTokenOrProvider
464
+ * @param userTokenOrProvider You can provide a token, or the keyword 'guest' to connect as [guest user](https://getstream.io/chat/docs/javascript/authless_users/?language=javascript#guest-users)
465
465
  */
466
466
  ChatClientService.prototype.init = function (apiKey, userOrId, userTokenOrProvider) {
467
467
  var _a;
@@ -474,16 +474,27 @@
474
474
  this.chatClient = streamChat.StreamChat.getInstance(apiKey);
475
475
  this.chatClient.devToken;
476
476
  return [4 /*yield*/, this.ngZone.runOutsideAngular(function () { return __awaiter(_this, void 0, void 0, function () {
477
- var user;
478
- return __generator(this, function (_d) {
479
- switch (_d.label) {
477
+ var user, _d, sdkPrefix;
478
+ return __generator(this, function (_e) {
479
+ switch (_e.label) {
480
480
  case 0:
481
481
  user = typeof userOrId === 'string' ? { id: userOrId } : userOrId;
482
- return [4 /*yield*/, this.chatClient.connectUser(user, userTokenOrProvider)];
482
+ if (!(userTokenOrProvider === 'guest')) return [3 /*break*/, 2];
483
+ return [4 /*yield*/, this.chatClient.setGuestUser(user)];
483
484
  case 1:
484
- result = _d.sent();
485
+ _d = _e.sent();
486
+ return [3 /*break*/, 4];
487
+ case 2: return [4 /*yield*/, this.chatClient.connectUser(user, userTokenOrProvider)];
488
+ case 3:
489
+ _d = _e.sent();
490
+ _e.label = 4;
491
+ case 4:
492
+ result = _d;
485
493
  this.userSubject.next(this.chatClient.user);
486
- this.chatClient.setUserAgent("stream-chat-angular-" + version + "-" + this.chatClient.getUserAgent());
494
+ sdkPrefix = 'stream-chat-angular';
495
+ if (!this.chatClient.getUserAgent().includes(sdkPrefix)) {
496
+ this.chatClient.setUserAgent(sdkPrefix + "-" + version + "-" + this.chatClient.getUserAgent());
497
+ }
487
498
  return [2 /*return*/];
488
499
  }
489
500
  });
@@ -683,11 +694,8 @@
683
694
  var currentChannels = _this.channelsSubject.getValue() || [];
684
695
  var newChannels = channels.filter(function (c) { return !currentChannels.find(function (channel) { return channel.cid === c.cid; }); });
685
696
  var deletedChannels = currentChannels.filter(function (c) { return !(channels === null || channels === void 0 ? void 0 : channels.find(function (channel) { return channel.cid === c.cid; })); });
686
- _this.addChannelsFromNotification(newChannels);
697
+ void _this.addChannelsFromNotification(newChannels);
687
698
  _this.removeChannelsFromChannelList(deletedChannels.map(function (c) { return c.cid; }));
688
- if (!newChannels.length && !deletedChannels.length) {
689
- _this.channelsSubject.next(channels);
690
- }
691
699
  };
692
700
  this.messageListSetter = function (messages) {
693
701
  _this.activeChannelMessagesSubject.next(messages);
@@ -1326,24 +1334,41 @@
1326
1334
  };
1327
1335
  ChannelService.prototype.handleNewMessageNotification = function (clientEvent) {
1328
1336
  if (clientEvent.event.channel) {
1329
- this.addChannelsFromNotification([clientEvent.event.channel]);
1337
+ void this.addChannelsFromNotification([clientEvent.event.channel]);
1330
1338
  }
1331
1339
  };
1332
1340
  ChannelService.prototype.handleAddedToChannelNotification = function (clientEvent) {
1333
1341
  if (clientEvent.event.channel) {
1334
- this.addChannelsFromNotification([clientEvent.event.channel]);
1342
+ void this.addChannelsFromNotification([clientEvent.event.channel]);
1335
1343
  }
1336
1344
  };
1337
1345
  ChannelService.prototype.addChannelsFromNotification = function (channelResponses) {
1338
- var _this = this;
1339
- var newChannels = [];
1340
- channelResponses.forEach(function (channelResponse) {
1341
- var channel = _this.chatClientService.chatClient.channel(channelResponse.type, channelResponse.id);
1342
- void channel.watch();
1343
- _this.watchForChannelEvents(channel);
1344
- newChannels.push(channel);
1346
+ return __awaiter(this, void 0, void 0, function () {
1347
+ var newChannels, watchRequests, currentChannels;
1348
+ var _this = this;
1349
+ return __generator(this, function (_h) {
1350
+ switch (_h.label) {
1351
+ case 0:
1352
+ newChannels = [];
1353
+ watchRequests = [];
1354
+ channelResponses.forEach(function (channelResponse) {
1355
+ var channel = _this.chatClientService.chatClient.channel(channelResponse.type, channelResponse.id);
1356
+ watchRequests.push(channel.watch());
1357
+ newChannels.push(channel);
1358
+ });
1359
+ return [4 /*yield*/, Promise.all(watchRequests)];
1360
+ case 1:
1361
+ _h.sent();
1362
+ currentChannels = this.channelsSubject.getValue() || [];
1363
+ newChannels = newChannels.filter(function (newChannel) { return !currentChannels.find(function (c) { return c.cid === newChannel.cid; }); });
1364
+ if (newChannels.length > 0) {
1365
+ newChannels.forEach(function (c) { return _this.watchForChannelEvents(c); });
1366
+ this.channelsSubject.next(__spreadArray(__spreadArray([], __read(newChannels)), __read(currentChannels)));
1367
+ }
1368
+ return [2 /*return*/];
1369
+ }
1370
+ });
1345
1371
  });
1346
- this.channelsSubject.next(__spreadArray(__spreadArray([], __read(newChannels)), __read((this.channelsSubject.getValue() || []))));
1347
1372
  };
1348
1373
  ChannelService.prototype.removeChannelsFromChannelList = function (cids) {
1349
1374
  var _a;