stream-chat-angular 4.5.3 → 4.6.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.5.3";
1
+ export declare const version = "4.6.0";
@@ -355,7 +355,7 @@
355
355
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
356
356
  }
357
357
 
358
- var version = '4.5.3';
358
+ var version = '4.6.0';
359
359
 
360
360
  /**
361
361
  * The `NotificationService` can be used to add or remove notifications. By default the [`NotificationList`](../components/NotificationListComponent.mdx) component displays the currently active notifications.
@@ -766,11 +766,6 @@
766
766
  }), operators.shareReplay());
767
767
  this.messageToQuote$ = this.messageToQuoteSubject.asObservable();
768
768
  this.jumpToMessage$ = this.jumpToMessageSubject.asObservable();
769
- this.chatClientService.connectionState$
770
- .pipe(operators.filter(function (s) { return s === 'online'; }))
771
- .subscribe(function () {
772
- void _this.setAsActiveParentMessage(undefined);
773
- });
774
769
  this.usersTypingInChannel$ =
775
770
  this.usersTypingInChannelSubject.asObservable();
776
771
  this.usersTypingInThread$ = this.usersTypingInThreadSubject.asObservable();
@@ -1455,13 +1450,17 @@
1455
1450
  return [2 /*return*/];
1456
1451
  }
1457
1452
  this.isStateRecoveryInProgress = true;
1458
- this.reset();
1459
1453
  _h.label = 1;
1460
1454
  case 1:
1461
1455
  _h.trys.push([1, 3, , 4]);
1462
- return [4 /*yield*/, this.init(this.filters, this.sort, this.options, this.shouldSetActiveChannel)];
1456
+ if (this.options) {
1457
+ this.options.offset = 0;
1458
+ }
1459
+ return [4 /*yield*/, this.queryChannels(false, true)];
1463
1460
  case 2:
1464
1461
  _h.sent();
1462
+ // Thread messages are not refetched so active thread gets deselected to avoid displaying stale messages
1463
+ void this.setAsActiveParentMessage(undefined);
1465
1464
  this.isStateRecoveryInProgress = false;
1466
1465
  return [3 /*break*/, 4];
1467
1466
  case 3:
@@ -1716,25 +1715,33 @@
1716
1715
  this.activeChannelSubscriptions.forEach(function (s) { return s.unsubscribe(); });
1717
1716
  this.activeChannelSubscriptions = [];
1718
1717
  };
1719
- ChannelService.prototype.queryChannels = function (shouldSetActiveChannel) {
1718
+ ChannelService.prototype.queryChannels = function (shouldSetActiveChannel, recoverState) {
1719
+ if (recoverState === void 0) { recoverState = false; }
1720
1720
  return __awaiter(this, void 0, void 0, function () {
1721
- var channels, prevChannels, error_6;
1721
+ var channels, prevChannels, currentActiveChannel_1, error_6;
1722
1722
  var _this = this;
1723
1723
  return __generator(this, function (_h) {
1724
1724
  switch (_h.label) {
1725
1725
  case 0:
1726
1726
  _h.trys.push([0, 2, , 3]);
1727
- return [4 /*yield*/, this.chatClientService.chatClient.queryChannels(this.filters, this.sort, this.options)];
1727
+ return [4 /*yield*/, this.chatClientService.chatClient.queryChannels(this.filters, this.sort || {}, this.options)];
1728
1728
  case 1:
1729
1729
  channels = _h.sent();
1730
1730
  channels.forEach(function (c) { return _this.watchForChannelEvents(c); });
1731
- prevChannels = this.channelsSubject.getValue() || [];
1731
+ prevChannels = recoverState
1732
+ ? []
1733
+ : this.channelsSubject.getValue() || [];
1732
1734
  this.channelsSubject.next(__spreadArray(__spreadArray([], __read(prevChannels)), __read(channels)));
1735
+ currentActiveChannel_1 = this.activeChannelSubject.getValue();
1733
1736
  if (channels.length > 0 &&
1734
- !this.activeChannelSubject.getValue() &&
1737
+ !currentActiveChannel_1 &&
1735
1738
  shouldSetActiveChannel) {
1736
1739
  this.setAsActiveChannel(channels[0]);
1737
1740
  }
1741
+ if (recoverState &&
1742
+ !channels.find(function (c) { return c.cid === (currentActiveChannel_1 === null || currentActiveChannel_1 === void 0 ? void 0 : currentActiveChannel_1.cid); })) {
1743
+ this.deselectActiveChannel();
1744
+ }
1738
1745
  this.hasMoreChannelsSubject.next(channels.length >= this.options.limit);
1739
1746
  return [2 /*return*/, channels];
1740
1747
  case 2: