stream-chat-angular 4.47.2 → 4.48.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.47.2";
1
+ export declare const version = "4.48.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.47.2';
359
+ var version = '4.48.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.
@@ -653,7 +653,7 @@
653
653
  var _a;
654
654
  if (typeof e.total_unread_count !== 'undefined') {
655
655
  var user_1;
656
- this.userSubject.pipe(rxjs.take(1)).subscribe(function (u) {
656
+ this.userSubject.pipe(operators.take(1)).subscribe(function (u) {
657
657
  user_1 = u;
658
658
  });
659
659
  if (user_1 && user_1.total_unread_count !== e.total_unread_count) {
@@ -662,7 +662,7 @@
662
662
  }
663
663
  if (typeof e.unread_channels !== 'undefined') {
664
664
  var user_2;
665
- this.userSubject.pipe(rxjs.take(1)).subscribe(function (u) {
665
+ this.userSubject.pipe(operators.take(1)).subscribe(function (u) {
666
666
  user_2 = u;
667
667
  });
668
668
  if (user_2 && user_2.unread_channels !== e.unread_channels) {
@@ -671,7 +671,7 @@
671
671
  }
672
672
  if (typeof e.unread_count !== 'undefined') {
673
673
  var user_3;
674
- this.userSubject.pipe(rxjs.take(1)).subscribe(function (u) {
674
+ this.userSubject.pipe(operators.take(1)).subscribe(function (u) {
675
675
  user_3 = u;
676
676
  });
677
677
  if (user_3 && user_3.unread_count !== e.unread_count) {
@@ -1036,8 +1036,8 @@
1036
1036
  switch (_h.label) {
1037
1037
  case 0:
1038
1038
  this.filters = filters;
1039
- this.options = Object.assign({ offset: 0, limit: 25, state: true, presence: true, watch: true, message_limit: this.messagePageSize }, options);
1040
- this.sort = sort || { last_message_at: -1, updated_at: -1 };
1039
+ this.options = Object.assign({ limit: 25, state: true, presence: true, watch: true, message_limit: this.messagePageSize }, options);
1040
+ this.sort = sort || { last_message_at: -1 };
1041
1041
  this.shouldSetActiveChannel = shouldSetActiveChannel;
1042
1042
  this.clientEventsSubscription = this.chatClientService.events$.subscribe(function (notification) { return void _this.handleNotification(notification); });
1043
1043
  _h.label = 1;
@@ -1081,9 +1081,7 @@
1081
1081
  return __awaiter(this, void 0, void 0, function () {
1082
1082
  return __generator(this, function (_h) {
1083
1083
  switch (_h.label) {
1084
- case 0:
1085
- this.options.offset = this.channels.length;
1086
- return [4 /*yield*/, this.queryChannels(false)];
1084
+ case 0: return [4 /*yield*/, this.queryChannels(false)];
1087
1085
  case 1:
1088
1086
  _h.sent();
1089
1087
  return [2 /*return*/];
@@ -1566,9 +1564,7 @@
1566
1564
  _h.label = 1;
1567
1565
  case 1:
1568
1566
  _h.trys.push([1, 3, , 4]);
1569
- if (this.options) {
1570
- this.options.offset = 0;
1571
- }
1567
+ this.nextPageConfiguration = undefined;
1572
1568
  shoulSetActiveChannel = this.shouldSetActiveChannel &&
1573
1569
  !this.activeChannelSubject.getValue();
1574
1570
  return [4 /*yield*/, this.queryChannels(shoulSetActiveChannel || false, true)];
@@ -1811,6 +1807,26 @@
1811
1807
  });
1812
1808
  });
1813
1809
  };
1810
+ Object.defineProperty(ChannelService.prototype, "channels", {
1811
+ /**
1812
+ * The current list of channels
1813
+ */
1814
+ get: function () {
1815
+ return this.channelsSubject.getValue() || [];
1816
+ },
1817
+ enumerable: false,
1818
+ configurable: true
1819
+ });
1820
+ Object.defineProperty(ChannelService.prototype, "activeChannel", {
1821
+ /**
1822
+ * The current active channel
1823
+ */
1824
+ get: function () {
1825
+ return this.activeChannelSubject.getValue() || undefined;
1826
+ },
1827
+ enumerable: false,
1828
+ configurable: true
1829
+ });
1814
1830
  ChannelService.prototype.messageUpdated = function (event) {
1815
1831
  var _this = this;
1816
1832
  this.ngZone.run(function () {
@@ -1891,30 +1907,48 @@
1891
1907
  if (recoverState === void 0) { recoverState = false; }
1892
1908
  var _a, _b;
1893
1909
  return __awaiter(this, void 0, void 0, function () {
1894
- var channels, prevChannels, currentActiveChannel_1, error_6;
1910
+ var filters, options, channels, prevChannels_1, filteredChannels, currentActiveChannel_1, error_6;
1895
1911
  var _this = this;
1896
1912
  return __generator(this, function (_h) {
1897
1913
  switch (_h.label) {
1898
1914
  case 0:
1899
1915
  _h.trys.push([0, 2, , 3]);
1900
1916
  this.channelQueryStateSubject.next({ state: 'in-progress' });
1901
- return [4 /*yield*/, this.chatClientService.chatClient.queryChannels(this.filters, this.sort || {}, this.options)];
1917
+ filters = void 0;
1918
+ options = void 0;
1919
+ if (this.nextPageConfiguration) {
1920
+ if (this.nextPageConfiguration.type === 'filter') {
1921
+ filters = Object.assign(Object.assign({}, this.filters), this.nextPageConfiguration.paginationFilter);
1922
+ options = this.options;
1923
+ }
1924
+ else {
1925
+ options = Object.assign(Object.assign({}, this.options), { offset: this.nextPageConfiguration.offset });
1926
+ filters = this.filters;
1927
+ }
1928
+ }
1929
+ else {
1930
+ filters = this.filters;
1931
+ options = this.options;
1932
+ }
1933
+ return [4 /*yield*/, this.chatClientService.chatClient.queryChannels(filters, this.sort || {}, options)];
1902
1934
  case 1:
1903
1935
  channels = _h.sent();
1936
+ this.setNextPageConfiguration(channels);
1904
1937
  channels.forEach(function (c) { return _this.watchForChannelEvents(c); });
1905
- prevChannels = recoverState
1938
+ prevChannels_1 = recoverState
1906
1939
  ? []
1907
1940
  : this.channelsSubject.getValue() || [];
1908
- this.channelsSubject.next(__spreadArray(__spreadArray([], __read(prevChannels)), __read(channels)));
1941
+ filteredChannels = channels.filter(function (channel) { return !prevChannels_1.find(function (existingChannel) { return existingChannel.cid === channel.cid; }); });
1942
+ this.channelsSubject.next(__spreadArray(__spreadArray([], __read(prevChannels_1)), __read(filteredChannels)));
1909
1943
  currentActiveChannel_1 = this.activeChannelSubject.getValue();
1910
- if (channels.length > 0 &&
1944
+ if (filteredChannels.length > 0 &&
1911
1945
  !currentActiveChannel_1 &&
1912
1946
  shouldSetActiveChannel) {
1913
- this.setAsActiveChannel(channels[0]);
1947
+ this.setAsActiveChannel(filteredChannels[0]);
1914
1948
  currentActiveChannel_1 = this.activeChannelSubject.getValue();
1915
1949
  }
1916
1950
  if (recoverState &&
1917
- !channels.find(function (c) { return c.cid === (currentActiveChannel_1 === null || currentActiveChannel_1 === void 0 ? void 0 : currentActiveChannel_1.cid); })) {
1951
+ !filteredChannels.find(function (c) { return c.cid === (currentActiveChannel_1 === null || currentActiveChannel_1 === void 0 ? void 0 : currentActiveChannel_1.cid); })) {
1918
1952
  this.deselectActiveChannel();
1919
1953
  }
1920
1954
  this.hasMoreChannelsSubject.next(channels.length >= this.options.limit);
@@ -2082,13 +2116,6 @@
2082
2116
  }
2083
2117
  }
2084
2118
  };
2085
- Object.defineProperty(ChannelService.prototype, "channels", {
2086
- get: function () {
2087
- return this.channelsSubject.getValue() || [];
2088
- },
2089
- enumerable: false,
2090
- configurable: true
2091
- });
2092
2119
  Object.defineProperty(ChannelService.prototype, "canSendReadEvents", {
2093
2120
  get: function () {
2094
2121
  var _a;
@@ -2215,6 +2242,20 @@
2215
2242
  void channel.markRead();
2216
2243
  }
2217
2244
  };
2245
+ ChannelService.prototype.setNextPageConfiguration = function (channelQueryResult) {
2246
+ var _a;
2247
+ if (this.customPaginator) {
2248
+ this.nextPageConfiguration = this.customPaginator(channelQueryResult);
2249
+ }
2250
+ else {
2251
+ this.nextPageConfiguration = {
2252
+ type: 'offset',
2253
+ offset: (((_a = this.nextPageConfiguration) === null || _a === void 0 ? void 0 : _a.type) === 'offset'
2254
+ ? this.nextPageConfiguration.offset
2255
+ : 0) + channelQueryResult.length,
2256
+ };
2257
+ }
2258
+ };
2218
2259
  return ChannelService;
2219
2260
  }());
2220
2261
  ChannelService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.5", ngImport: i0__namespace, type: ChannelService, deps: [{ token: ChatClientService }, { token: i0__namespace.NgZone }, { token: NotificationService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });