stream-chat-angular 2.20.2 → 2.21.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 = "2.20.2";
1
+ export declare const version = "2.21.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 = '2.20.2';
357
+ var version = '2.21.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.
@@ -760,6 +760,21 @@
760
760
  this.activeThreadMessagesSubject.next([]);
761
761
  this.messageToQuoteSubject.next(undefined);
762
762
  };
763
+ /**
764
+ * Deselects the currently active (if any) channel
765
+ */
766
+ ChannelService.prototype.deselectActiveChannel = function () {
767
+ var activeChannel = this.activeChannelSubject.getValue();
768
+ if (!activeChannel) {
769
+ return;
770
+ }
771
+ this.activeChannelMessagesSubject.next([]);
772
+ this.activeChannelSubject.next(undefined);
773
+ this.activeParentMessageIdSubject.next(undefined);
774
+ this.activeThreadMessagesSubject.next([]);
775
+ this.latestMessageDateByUserByChannelsSubject.next({});
776
+ this.selectMessageToQuote(undefined);
777
+ };
763
778
  /**
764
779
  * Sets the given `message` as an active parent message. If `undefined` is provided, it will deleselect the current parent message.
765
780
  * @param message
@@ -855,9 +870,13 @@
855
870
  * @param filters
856
871
  * @param sort
857
872
  * @param options
873
+ * @param shouldSetActiveChannel Decides if the first channel in the result should be made as an active channel, or no channel should be marked as active
874
+ * @returns the list of channels found by the query
858
875
  */
859
- ChannelService.prototype.init = function (filters, sort, options) {
876
+ ChannelService.prototype.init = function (filters, sort, options, shouldSetActiveChannel) {
877
+ if (shouldSetActiveChannel === void 0) { shouldSetActiveChannel = true; }
860
878
  return __awaiter(this, void 0, void 0, function () {
879
+ var result;
861
880
  var _this = this;
862
881
  return __generator(this, function (_h) {
863
882
  switch (_h.label) {
@@ -872,11 +891,11 @@
872
891
  message_limit: this.messagePageSize,
873
892
  };
874
893
  this.sort = sort || { last_message_at: -1, updated_at: -1 };
875
- return [4 /*yield*/, this.queryChannels()];
894
+ return [4 /*yield*/, this.queryChannels(shouldSetActiveChannel)];
876
895
  case 1:
877
- _h.sent();
896
+ result = _h.sent();
878
897
  this.chatClientService.notification$.subscribe(function (notification) { return void _this.handleNotification(notification); });
879
- return [2 /*return*/];
898
+ return [2 /*return*/, result];
880
899
  }
881
900
  });
882
901
  });
@@ -885,13 +904,8 @@
885
904
  * Resets the `activeChannel$`, `channels$` and `activeChannelMessages$` Observables. Useful when disconnecting a chat user, use in combination with [`disconnectUser`](./ChatClientService.mdx/#disconnectuser).
886
905
  */
887
906
  ChannelService.prototype.reset = function () {
888
- this.activeChannelMessagesSubject.next([]);
889
- this.activeChannelSubject.next(undefined);
890
- this.activeParentMessageIdSubject.next(undefined);
891
- this.activeThreadMessagesSubject.next([]);
907
+ this.deselectActiveChannel();
892
908
  this.channelsSubject.next(undefined);
893
- this.latestMessageDateByUserByChannelsSubject.next({});
894
- this.selectMessageToQuote(undefined);
895
909
  };
896
910
  /**
897
911
  * Loads the next page of channels. The page size can be set in the [query option](https://getstream.io/chat/docs/javascript/query_channels/?language=javascript#query-options) object.
@@ -902,7 +916,7 @@
902
916
  switch (_h.label) {
903
917
  case 0:
904
918
  this.options.offset = this.channels.length;
905
- return [4 /*yield*/, this.queryChannels()];
919
+ return [4 /*yield*/, this.queryChannels(false)];
906
920
  case 1:
907
921
  _h.sent();
908
922
  return [2 /*return*/];
@@ -1432,7 +1446,7 @@
1432
1446
  this.activeChannelSubscriptions.forEach(function (s) { return s.unsubscribe(); });
1433
1447
  this.activeChannelSubscriptions = [];
1434
1448
  };
1435
- ChannelService.prototype.queryChannels = function () {
1449
+ ChannelService.prototype.queryChannels = function (shouldSetActiveChannel) {
1436
1450
  return __awaiter(this, void 0, void 0, function () {
1437
1451
  var channels, prevChannels, error_2;
1438
1452
  var _this = this;
@@ -1446,15 +1460,17 @@
1446
1460
  channels.forEach(function (c) { return _this.watchForChannelEvents(c); });
1447
1461
  prevChannels = this.channelsSubject.getValue() || [];
1448
1462
  this.channelsSubject.next(__spreadArray(__spreadArray([], __read(prevChannels)), __read(channels)));
1449
- if (channels.length > 0 && !this.activeChannelSubject.getValue()) {
1463
+ if (channels.length > 0 &&
1464
+ !this.activeChannelSubject.getValue() &&
1465
+ shouldSetActiveChannel) {
1450
1466
  this.setAsActiveChannel(channels[0]);
1451
1467
  }
1452
1468
  this.hasMoreChannelsSubject.next(channels.length >= this.options.limit);
1453
- return [3 /*break*/, 3];
1469
+ return [2 /*return*/, channels];
1454
1470
  case 2:
1455
1471
  error_2 = _h.sent();
1456
1472
  this.channelsSubject.error(error_2);
1457
- return [3 /*break*/, 3];
1473
+ throw error_2;
1458
1474
  case 3: return [2 /*return*/];
1459
1475
  }
1460
1476
  });