stream-chat-angular 4.31.2 → 4.32.0

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 = "4.31.2";
1
+ export declare const version = "4.32.0";
@@ -356,7 +356,7 @@
356
356
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
357
357
  }
358
358
 
359
- var version = '4.31.2';
359
+ var version = '4.32.0';
360
360
 
361
361
  /**
362
362
  * The `NotificationService` can be used to add or remove notifications. By default the [`NotificationList`](../components/NotificationListComponent.mdx) component displays the currently active notifications.
@@ -462,8 +462,12 @@
462
462
  /**
463
463
  * 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.
464
464
  * @param apiKey
465
- * @param userOrId
466
- * @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
+ * @param userOrId you can emit this for anonymous logins
466
+ * @param userTokenOrProvider You can provide:<ul>
467
+ * <li> a token, </li>
468
+ * <li> the keyword 'guest' to connect as [guest user](https://getstream.io/chat/docs/javascript/authless_users/?language=javascript#guest-users) </li>
469
+ * <li> the keyword 'anonymous' to connect as [anonymous user](https://getstream.io/chat/docs/javascript/authless_users/?language=javascript#anonymous-users) </li>
470
+ * </ul>
467
471
  * @param clientOptions Setting to provide to the Stream client instance
468
472
  */
469
473
  ChatClientService.prototype.init = function (apiKey, userOrId, userTokenOrProvider, clientOptions) {
@@ -477,31 +481,28 @@
477
481
  this.chatClient = streamChat.StreamChat.getInstance(apiKey, clientOptions);
478
482
  this.chatClient.devToken;
479
483
  return [4 /*yield*/, this.ngZone.runOutsideAngular(function () { return __awaiter(_this, void 0, void 0, function () {
480
- var user, _d, error_1, sdkPrefix;
481
- return __generator(this, function (_e) {
482
- switch (_e.label) {
484
+ var _b, user, error_1, sdkPrefix;
485
+ var _this = this;
486
+ return __generator(this, function (_d) {
487
+ switch (_d.label) {
483
488
  case 0:
484
489
  user = typeof userOrId === 'string' ? { id: userOrId } : userOrId;
485
- _e.label = 1;
490
+ _d.label = 1;
486
491
  case 1:
487
- _e.trys.push([1, 6, , 7]);
488
- if (!(userTokenOrProvider === 'guest')) return [3 /*break*/, 3];
489
- return [4 /*yield*/, this.chatClient.setGuestUser(user)];
492
+ _d.trys.push([1, 3, , 4]);
493
+ return [4 /*yield*/, ((_b = {
494
+ guest: function () { return _this.chatClient.setGuestUser(user); },
495
+ anonymous: function () { return _this.chatClient.connectAnonymousUser(); },
496
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
497
+ }["" + userTokenOrProvider]) !== null && _b !== void 0 ? _b : (function () { return _this.chatClient.connectUser(user, userTokenOrProvider); }))()];
490
498
  case 2:
491
- _d = _e.sent();
492
- return [3 /*break*/, 5];
493
- case 3: return [4 /*yield*/, this.chatClient.connectUser(user, userTokenOrProvider)];
494
- case 4:
495
- _d = _e.sent();
496
- _e.label = 5;
497
- case 5:
498
- result = _d;
499
- return [3 /*break*/, 7];
500
- case 6:
501
- error_1 = _e.sent();
499
+ result = _d.sent();
500
+ return [3 /*break*/, 4];
501
+ case 3:
502
+ error_1 = _d.sent();
502
503
  this.notificationService.addPermanentNotification('streamChat.Error connecting to chat, refresh the page to try again.', 'error');
503
504
  throw error_1;
504
- case 7:
505
+ case 4:
505
506
  this.userSubject.next(this.chatClient.user);
506
507
  sdkPrefix = 'stream-chat-angular';
507
508
  if (!this.chatClient.getUserAgent().includes(sdkPrefix)) {