stream-chat-angular 3.7.2 → 3.8.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 = "3.7.2";
1
+ export declare const version = "3.8.0";
@@ -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.2';
357
+ var version = '3.8.0';
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,14 +474,22 @@
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;
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
494
  this.chatClient.setUserAgent("stream-chat-angular-" + version + "-" + this.chatClient.getUserAgent());
487
495
  return [2 /*return*/];
@@ -1437,13 +1445,21 @@
1437
1445
  ChannelService.prototype.messageUpdated = function (event) {
1438
1446
  var _this = this;
1439
1447
  this.ngZone.run(function () {
1448
+ var _a;
1440
1449
  var isThreadReply = event.message && event.message.parent_id;
1450
+ var channel = _this.activeChannelSubject.getValue();
1451
+ if (!channel) {
1452
+ return;
1453
+ }
1454
+ // Get messages from state as message order could change, and message could've been deleted
1441
1455
  var messages = isThreadReply
1442
- ? _this.activeThreadMessagesSubject.getValue()
1443
- : _this.activeChannelMessagesSubject.getValue();
1444
- var messageIndex = messages.findIndex(function (m) { var _a; return m.id === ((_a = event.message) === null || _a === void 0 ? void 0 : _a.id); });
1445
- if (messageIndex !== -1 && event.message) {
1446
- messages[messageIndex] = event.message;
1456
+ ? channel.state.threads[((_a = event === null || event === void 0 ? void 0 : event.message) === null || _a === void 0 ? void 0 : _a.parent_id) || '']
1457
+ : channel.state.messages;
1458
+ if (!messages) {
1459
+ return;
1460
+ }
1461
+ var messageIndex = messages.findIndex(function (m) { var _a; return m.id === ((_a = event === null || event === void 0 ? void 0 : event.message) === null || _a === void 0 ? void 0 : _a.id); });
1462
+ if (messageIndex !== -1) {
1447
1463
  isThreadReply
1448
1464
  ? _this.activeThreadMessagesSubject.next(__spreadArray([], __read(messages)))
1449
1465
  : _this.activeChannelMessagesSubject.next(__spreadArray([], __read(messages)));
@@ -4309,10 +4325,10 @@
4309
4325
  this.visibleMessageActionsCount = 0;
4310
4326
  this.messageTextParts = [];
4311
4327
  this.subscriptions = [];
4312
- this.user = this.chatClientService.chatClient.user;
4313
4328
  }
4314
4329
  MessageComponent.prototype.ngOnInit = function () {
4315
4330
  var _this = this;
4331
+ this.subscriptions.push(this.chatClientService.user$.subscribe(function (u) { return (_this.user = u); }));
4316
4332
  this.subscriptions.push(this.customTemplatesService.mentionTemplate$.subscribe(function (template) { return (_this.mentionTemplate = template); }));
4317
4333
  this.subscriptions.push(this.customTemplatesService.attachmentListTemplate$.subscribe(function (template) { return (_this.attachmentListTemplate = template); }));
4318
4334
  this.subscriptions.push(this.customTemplatesService.messageActionsBoxTemplate$.subscribe(function (template) { return (_this.messageActionsBoxTemplate = template); }));