stream-chat-angular 4.47.3 → 4.49.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.
Files changed (46) hide show
  1. package/assets/i18n/en.d.ts +2 -1
  2. package/assets/version.d.ts +1 -1
  3. package/bundles/stream-chat-angular.umd.js +114 -29
  4. package/bundles/stream-chat-angular.umd.js.map +1 -1
  5. package/esm2015/assets/i18n/en.js +4 -3
  6. package/esm2015/assets/version.js +2 -2
  7. package/esm2015/lib/attachment.service.js +21 -4
  8. package/esm2015/lib/channel.service.js +80 -16
  9. package/esm2015/lib/types.js +1 -1
  10. package/fesm2015/stream-chat-angular.js +103 -21
  11. package/fesm2015/stream-chat-angular.js.map +1 -1
  12. package/lib/channel.service.d.ts +19 -2
  13. package/lib/types.d.ts +15 -1
  14. package/package.json +1 -1
  15. package/src/assets/i18n/en.ts +5 -2
  16. package/src/assets/styles/css/index.css +1 -1
  17. package/src/assets/styles/scss/MessageInput.scss +6 -0
  18. package/src/assets/styles/scss/_base.scss +0 -41
  19. package/src/assets/styles/scss/index.scss +0 -1
  20. package/src/assets/styles/v2/css/emoji-mart.css +1 -0
  21. package/src/assets/styles/v2/css/emoji-replacement.css +1 -0
  22. package/src/assets/styles/v2/css/index.css +1 -1
  23. package/src/assets/styles/v2/css/index.layout.css +1 -1
  24. package/src/assets/styles/v2/scss/AttachmentPreviewList/AttachmentPreviewList-layout.scss +1 -0
  25. package/src/assets/styles/v2/scss/Autocomplete/Autocomplete-layout.scss +8 -0
  26. package/src/assets/styles/v2/scss/ChannelHeader/ChannelHeader-layout.scss +4 -0
  27. package/src/assets/styles/v2/scss/ChannelPreview/ChannelPreview-layout.scss +1 -0
  28. package/src/assets/styles/v2/scss/ChannelSearch/ChannelSearch-layout.scss +5 -0
  29. package/src/assets/styles/v2/scss/LinkPreview/LinkPreview-layout.scss +49 -0
  30. package/src/assets/styles/v2/scss/LinkPreview/LinkPreview-theme.scss +17 -0
  31. package/src/assets/styles/v2/scss/LinkPreview/index.scss +2 -0
  32. package/src/assets/styles/v2/scss/Message/Message-layout.scss +8 -0
  33. package/src/assets/styles/v2/scss/MessageInput/MessageInput-layout.scss +1 -1
  34. package/src/assets/styles/v2/scss/MessageList/MessageList-layout.scss +1 -0
  35. package/src/assets/styles/v2/scss/MessageList/VirtualizedMessageList-layout.scss +4 -0
  36. package/src/assets/styles/v2/scss/Notification/Notification-layout.scss +4 -0
  37. package/src/assets/styles/v2/scss/Thread/Thread-layout.scss +4 -0
  38. package/src/assets/styles/v2/scss/Tooltip/Tooltip-layout.scss +1 -0
  39. package/src/assets/styles/v2/scss/_emoji-replacement.scss +1 -0
  40. package/src/assets/styles/v2/scss/_utils.scss +5 -0
  41. package/src/assets/styles/v2/scss/index.layout.scss +1 -1
  42. package/src/assets/styles/v2/scss/index.scss +1 -1
  43. package/src/assets/version.ts +1 -1
  44. package/src/assets/styles/css/index.css.map +0 -1
  45. package/src/assets/styles/v2/css/index.css.map +0 -1
  46. package/src/assets/styles/v2/css/index.layout.css.map +0 -1
@@ -22,7 +22,8 @@ export declare const en: {
22
22
  'Error removing message pin': string;
23
23
  'Error unmuting a user ...': string;
24
24
  'Error uploading file': string;
25
- 'Error uploading image': string;
25
+ 'Error uploading file, maximum file size exceeded': string;
26
+ 'Error uploading file, extension not supported': string;
26
27
  'Error deleting attachment': string;
27
28
  'Error \u00B7 Unsent': string;
28
29
  'Error: {{ errorMessage }}': string;
@@ -1 +1 @@
1
- export declare const version = "4.47.3";
1
+ export declare const version = "4.49.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.3';
359
+ var version = '4.49.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.
@@ -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*/];
@@ -1276,6 +1274,7 @@
1276
1274
  case 1:
1277
1275
  uploadResults = _h.sent();
1278
1276
  uploadResults.forEach(function (uploadResult, i) {
1277
+ var _a, _b, _c, _d, _e, _f, _g;
1279
1278
  var file = uploads[i].file;
1280
1279
  var type = uploads[i].type;
1281
1280
  if (uploadResult.status === 'fulfilled') {
@@ -1289,7 +1288,32 @@
1289
1288
  });
1290
1289
  }
1291
1290
  else {
1292
- result.push({ file: file, type: type, state: 'error' });
1291
+ var reason = 'unknown';
1292
+ var extraData = void 0;
1293
+ /* eslint-disable-next-line @typescript-eslint/no-unsafe-assignment */
1294
+ var message =
1295
+ /* eslint-disable-next-line @typescript-eslint/no-unsafe-member-access */
1296
+ (_b = (_a = uploadResult.reason.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.message;
1297
+ /* eslint-disable-next-line @typescript-eslint/no-unsafe-assignment */
1298
+ var code =
1299
+ /* eslint-disable-next-line @typescript-eslint/no-unsafe-member-access */
1300
+ (_d = (_c = uploadResult.reason.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.code;
1301
+ if (code === 22) {
1302
+ reason = 'file-size';
1303
+ extraData = { param: ((_e = /\d+MB/.exec(message || '')) === null || _e === void 0 ? void 0 : _e[0]) || '100MB' };
1304
+ }
1305
+ else if (code === 4 &&
1306
+ ((_f = message === null || message === void 0 ? void 0 : message.toLowerCase()) === null || _f === void 0 ? void 0 : _f.includes('file extension'))) {
1307
+ reason = 'file-extension';
1308
+ extraData = { param: ((_g = /\.\w+/.exec(message)) === null || _g === void 0 ? void 0 : _g[0]) || '' };
1309
+ }
1310
+ result.push({
1311
+ file: file,
1312
+ type: type,
1313
+ state: 'error',
1314
+ errorReason: reason,
1315
+ errorExtraInfo: extraData ? [extraData] : undefined,
1316
+ });
1293
1317
  }
1294
1318
  });
1295
1319
  return [2 /*return*/, result];
@@ -1566,9 +1590,7 @@
1566
1590
  _h.label = 1;
1567
1591
  case 1:
1568
1592
  _h.trys.push([1, 3, , 4]);
1569
- if (this.options) {
1570
- this.options.offset = 0;
1571
- }
1593
+ this.nextPageConfiguration = undefined;
1572
1594
  shoulSetActiveChannel = this.shouldSetActiveChannel &&
1573
1595
  !this.activeChannelSubject.getValue();
1574
1596
  return [4 /*yield*/, this.queryChannels(shoulSetActiveChannel || false, true)];
@@ -1811,6 +1833,26 @@
1811
1833
  });
1812
1834
  });
1813
1835
  };
1836
+ Object.defineProperty(ChannelService.prototype, "channels", {
1837
+ /**
1838
+ * The current list of channels
1839
+ */
1840
+ get: function () {
1841
+ return this.channelsSubject.getValue() || [];
1842
+ },
1843
+ enumerable: false,
1844
+ configurable: true
1845
+ });
1846
+ Object.defineProperty(ChannelService.prototype, "activeChannel", {
1847
+ /**
1848
+ * The current active channel
1849
+ */
1850
+ get: function () {
1851
+ return this.activeChannelSubject.getValue() || undefined;
1852
+ },
1853
+ enumerable: false,
1854
+ configurable: true
1855
+ });
1814
1856
  ChannelService.prototype.messageUpdated = function (event) {
1815
1857
  var _this = this;
1816
1858
  this.ngZone.run(function () {
@@ -1891,30 +1933,48 @@
1891
1933
  if (recoverState === void 0) { recoverState = false; }
1892
1934
  var _a, _b;
1893
1935
  return __awaiter(this, void 0, void 0, function () {
1894
- var channels, prevChannels, currentActiveChannel_1, error_6;
1936
+ var filters, options, channels, prevChannels_1, filteredChannels, currentActiveChannel_1, error_6;
1895
1937
  var _this = this;
1896
1938
  return __generator(this, function (_h) {
1897
1939
  switch (_h.label) {
1898
1940
  case 0:
1899
1941
  _h.trys.push([0, 2, , 3]);
1900
1942
  this.channelQueryStateSubject.next({ state: 'in-progress' });
1901
- return [4 /*yield*/, this.chatClientService.chatClient.queryChannels(this.filters, this.sort || {}, this.options)];
1943
+ filters = void 0;
1944
+ options = void 0;
1945
+ if (this.nextPageConfiguration) {
1946
+ if (this.nextPageConfiguration.type === 'filter') {
1947
+ filters = Object.assign(Object.assign({}, this.filters), this.nextPageConfiguration.paginationFilter);
1948
+ options = this.options;
1949
+ }
1950
+ else {
1951
+ options = Object.assign(Object.assign({}, this.options), { offset: this.nextPageConfiguration.offset });
1952
+ filters = this.filters;
1953
+ }
1954
+ }
1955
+ else {
1956
+ filters = this.filters;
1957
+ options = this.options;
1958
+ }
1959
+ return [4 /*yield*/, this.chatClientService.chatClient.queryChannels(filters, this.sort || {}, options)];
1902
1960
  case 1:
1903
1961
  channels = _h.sent();
1962
+ this.setNextPageConfiguration(channels);
1904
1963
  channels.forEach(function (c) { return _this.watchForChannelEvents(c); });
1905
- prevChannels = recoverState
1964
+ prevChannels_1 = recoverState
1906
1965
  ? []
1907
1966
  : this.channelsSubject.getValue() || [];
1908
- this.channelsSubject.next(__spreadArray(__spreadArray([], __read(prevChannels)), __read(channels)));
1967
+ filteredChannels = channels.filter(function (channel) { return !prevChannels_1.find(function (existingChannel) { return existingChannel.cid === channel.cid; }); });
1968
+ this.channelsSubject.next(__spreadArray(__spreadArray([], __read(prevChannels_1)), __read(filteredChannels)));
1909
1969
  currentActiveChannel_1 = this.activeChannelSubject.getValue();
1910
- if (channels.length > 0 &&
1970
+ if (filteredChannels.length > 0 &&
1911
1971
  !currentActiveChannel_1 &&
1912
1972
  shouldSetActiveChannel) {
1913
- this.setAsActiveChannel(channels[0]);
1973
+ this.setAsActiveChannel(filteredChannels[0]);
1914
1974
  currentActiveChannel_1 = this.activeChannelSubject.getValue();
1915
1975
  }
1916
1976
  if (recoverState &&
1917
- !channels.find(function (c) { return c.cid === (currentActiveChannel_1 === null || currentActiveChannel_1 === void 0 ? void 0 : currentActiveChannel_1.cid); })) {
1977
+ !filteredChannels.find(function (c) { return c.cid === (currentActiveChannel_1 === null || currentActiveChannel_1 === void 0 ? void 0 : currentActiveChannel_1.cid); })) {
1918
1978
  this.deselectActiveChannel();
1919
1979
  }
1920
1980
  this.hasMoreChannelsSubject.next(channels.length >= this.options.limit);
@@ -2082,13 +2142,6 @@
2082
2142
  }
2083
2143
  }
2084
2144
  };
2085
- Object.defineProperty(ChannelService.prototype, "channels", {
2086
- get: function () {
2087
- return this.channelsSubject.getValue() || [];
2088
- },
2089
- enumerable: false,
2090
- configurable: true
2091
- });
2092
2145
  Object.defineProperty(ChannelService.prototype, "canSendReadEvents", {
2093
2146
  get: function () {
2094
2147
  var _a;
@@ -2215,6 +2268,20 @@
2215
2268
  void channel.markRead();
2216
2269
  }
2217
2270
  };
2271
+ ChannelService.prototype.setNextPageConfiguration = function (channelQueryResult) {
2272
+ var _a;
2273
+ if (this.customPaginator) {
2274
+ this.nextPageConfiguration = this.customPaginator(channelQueryResult);
2275
+ }
2276
+ else {
2277
+ this.nextPageConfiguration = {
2278
+ type: 'offset',
2279
+ offset: (((_a = this.nextPageConfiguration) === null || _a === void 0 ? void 0 : _a.type) === 'offset'
2280
+ ? this.nextPageConfiguration.offset
2281
+ : 0) + channelQueryResult.length,
2282
+ };
2283
+ }
2284
+ };
2218
2285
  return ChannelService;
2219
2286
  }());
2220
2287
  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 });
@@ -2616,6 +2683,7 @@
2616
2683
  result = _e.sent();
2617
2684
  attachmentUploads = this.attachmentUploadsSubject.getValue();
2618
2685
  result.forEach(function (r) {
2686
+ var _a, _b, _c, _d;
2619
2687
  var upload = attachmentUploads.find(function (upload) { return upload.file === r.file; });
2620
2688
  if (!upload) {
2621
2689
  if (r.url) {
@@ -2627,9 +2695,25 @@
2627
2695
  upload.url = r.url;
2628
2696
  upload.thumb_url = r.thumb_url;
2629
2697
  if (upload.state === 'error') {
2630
- _this.notificationService.addTemporaryNotification(upload.type === 'image'
2631
- ? 'streamChat.Error uploading image'
2632
- : 'streamChat.Error uploading file');
2698
+ upload.errorReason = r.errorReason;
2699
+ upload.errorExtraInfo = r.errorExtraInfo;
2700
+ var errorKey = void 0;
2701
+ var translateParams = { name: upload.file.name };
2702
+ switch (upload.errorReason) {
2703
+ case 'file-extension':
2704
+ errorKey =
2705
+ 'streamChat.Error uploading file, extension not supported';
2706
+ translateParams.ext = (_b = (_a = upload.errorExtraInfo) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.param;
2707
+ break;
2708
+ case 'file-size':
2709
+ errorKey =
2710
+ 'streamChat.Error uploading file, maximum file size exceeded';
2711
+ translateParams.limit = (_d = (_c = upload.errorExtraInfo) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.param;
2712
+ break;
2713
+ default:
2714
+ errorKey = 'streamChat.Error uploading file';
2715
+ }
2716
+ _this.notificationService.addTemporaryNotification(errorKey, 'error', undefined, translateParams);
2633
2717
  }
2634
2718
  });
2635
2719
  this.attachmentUploadInProgressCounterSubject.next(this.attachmentUploadInProgressCounterSubject.getValue() - 1);
@@ -2839,8 +2923,9 @@
2839
2923
  'Error pinning message': 'Error pinning message',
2840
2924
  'Error removing message pin': 'Error removing message pin',
2841
2925
  'Error unmuting a user ...': 'Error unmuting a user ...',
2842
- 'Error uploading file': 'Error uploading file',
2843
- 'Error uploading image': 'Error uploading image',
2926
+ 'Error uploading file': 'Error uploading file "{{ name }}"',
2927
+ 'Error uploading file, maximum file size exceeded': 'Error uploading "{{ name }}", maximum file size {{ limit }} exceeded',
2928
+ 'Error uploading file, extension not supported': 'Error uploading "{{ name }}", extension {{ ext }} not supported',
2844
2929
  'Error deleting attachment': 'Error deleting attachment',
2845
2930
  'Error · Unsent': "Message couldn't be sent",
2846
2931
  'Error: {{ errorMessage }}': 'Error: {{ errorMessage }}',