stream-chat-angular 4.2.0 → 4.4.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.2.0";
1
+ export declare const version = "4.4.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.2.0';
358
+ var version = '4.4.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.
@@ -2363,7 +2363,8 @@
2363
2363
  attachment.thumb_url ||
2364
2364
  attachment.image_url ||
2365
2365
  ''));
2366
- var _b = this.getSizingRestrictions(url, element), sizeRestriction = _b.sizeRestriction, height = _b.height;
2366
+ var displayWarning = location === 'gallery' || location === 'single';
2367
+ var _b = this.getSizingRestrictions(url, element, displayWarning), sizeRestriction = _b.sizeRestriction, height = _b.height;
2367
2368
  if (sizeRestriction) {
2368
2369
  // Apply 2x for retina displays
2369
2370
  sizeRestriction.height *= 2;
@@ -2389,7 +2390,8 @@
2389
2390
  var thumbUrl = undefined;
2390
2391
  if (attachment.thumb_url && this.shouldGenerateVideoThumbnail) {
2391
2392
  var url = new URL(attachment.thumb_url);
2392
- var _b = this.getSizingRestrictions(url, element), sizeRestriction = _b.sizeRestriction, height = _b.height;
2393
+ var displayWarning = true;
2394
+ var _b = this.getSizingRestrictions(url, element, displayWarning), sizeRestriction = _b.sizeRestriction, height = _b.height;
2393
2395
  if (sizeRestriction) {
2394
2396
  sizeRestriction.height *= 2;
2395
2397
  sizeRestriction.width *= 2;
@@ -2443,7 +2445,8 @@
2443
2445
  url.searchParams.set('h', sizeRestriction.height.toString());
2444
2446
  url.searchParams.set('w', sizeRestriction.width.toString());
2445
2447
  };
2446
- AttachmentConfigurationService.prototype.getSizingRestrictions = function (url, htmlElement) {
2448
+ AttachmentConfigurationService.prototype.getSizingRestrictions = function (url, htmlElement, displayWarning) {
2449
+ if (displayWarning === void 0) { displayWarning = false; }
2447
2450
  var urlParams = url.searchParams;
2448
2451
  var originalHeight = Number(urlParams.get('oh')) || 1;
2449
2452
  var originalWidth = Number(urlParams.get('ow')) || 1;
@@ -2466,6 +2469,9 @@
2466
2469
  }
2467
2470
  else {
2468
2471
  sizeRestriction = undefined;
2472
+ if (displayWarning) {
2473
+ console.warn("Invalid value set for height/max-height and/or max-width for HTML element, this can cause scrolling issues inside the message list, more info https://getstream.io/chat/docs/sdk/angular/components/AttachmentListComponent/#image-and-video-sizing");
2474
+ }
2469
2475
  }
2470
2476
  return { sizeRestriction: sizeRestriction, height: height };
2471
2477
  };
@@ -2634,8 +2640,7 @@
2634
2640
  }
2635
2641
  Object.defineProperty(AvatarComponent.prototype, "initials", {
2636
2642
  get: function () {
2637
- var _this = this;
2638
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
2643
+ var _a, _b, _c, _d, _e;
2639
2644
  var result = '';
2640
2645
  if (this.type === 'user') {
2641
2646
  result = ((_a = this.name) === null || _a === void 0 ? void 0 : _a.toString()) || '';
@@ -2645,9 +2650,9 @@
2645
2650
  result = (_e = (_d = this.channel) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.name;
2646
2651
  }
2647
2652
  else {
2648
- var otherMembers = Object.values(((_g = (_f = this.channel) === null || _f === void 0 ? void 0 : _f.state) === null || _g === void 0 ? void 0 : _g.members) || {}).filter(function (m) { var _a; return m.user_id !== ((_a = _this.chatClientService.chatClient.user) === null || _a === void 0 ? void 0 : _a.id); });
2649
- if (otherMembers.length === 1) {
2650
- result = ((_h = otherMembers[0].user) === null || _h === void 0 ? void 0 : _h.name) || ((_j = otherMembers[0].user) === null || _j === void 0 ? void 0 : _j.id) || '';
2653
+ var otherMember = this.getOtherMemberIfOneToOneChannel();
2654
+ if (otherMember) {
2655
+ result = otherMember.name || otherMember.id || '';
2651
2656
  }
2652
2657
  else {
2653
2658
  result = '#';
@@ -2659,10 +2664,39 @@
2659
2664
  enumerable: false,
2660
2665
  configurable: true
2661
2666
  });
2667
+ Object.defineProperty(AvatarComponent.prototype, "fallbackChannelImage", {
2668
+ get: function () {
2669
+ if (this.type !== 'channel') {
2670
+ return undefined;
2671
+ }
2672
+ else {
2673
+ var otherMember = this.getOtherMemberIfOneToOneChannel();
2674
+ if (otherMember) {
2675
+ return otherMember.image;
2676
+ }
2677
+ else {
2678
+ return undefined;
2679
+ }
2680
+ }
2681
+ },
2682
+ enumerable: false,
2683
+ configurable: true
2684
+ });
2685
+ AvatarComponent.prototype.getOtherMemberIfOneToOneChannel = function () {
2686
+ var _this = this;
2687
+ var _a, _b;
2688
+ var otherMembers = Object.values(((_b = (_a = this.channel) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.members) || {}).filter(function (m) { var _a; return m.user_id !== ((_a = _this.chatClientService.chatClient.user) === null || _a === void 0 ? void 0 : _a.id); });
2689
+ if (otherMembers.length === 1) {
2690
+ return otherMembers[0].user;
2691
+ }
2692
+ else {
2693
+ return undefined;
2694
+ }
2695
+ };
2662
2696
  return AvatarComponent;
2663
2697
  }());
2664
2698
  AvatarComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.5", ngImport: i0__namespace, type: AvatarComponent, deps: [{ token: ChatClientService }], target: i0__namespace.ɵɵFactoryTarget.Component });
2665
- AvatarComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.5", type: AvatarComponent, selector: "stream-avatar", inputs: { name: "name", imageUrl: "imageUrl", size: "size", location: "location", channel: "channel", user: "user", type: "type" }, ngImport: i0__namespace, template: "<div\n class=\"str-chat__avatar str-chat__avatar--circle stream-chat__avatar--{{\n location\n }}\"\n title=\"{{ name }}\"\n [style]=\"{\n flexBasis: 'calc(var(--str-chat__spacing-px, 1px) * ' + size + ')',\n fontSize: 'calc(var(--str-chat__spacing-px, 1px) * ' + size / 2 + ')',\n height: 'calc(var(--str-chat__spacing-px, 1px) * ' + size + ')',\n lineHeight: 'calc(var(--str-chat__spacing-px, 1px) * ' + size + ')',\n width: 'calc(var(--str-chat__spacing-px, 1px) * ' + size + ')'\n }\"\n>\n <img\n *ngIf=\"imageUrl && !isError; else fallback\"\n class=\"str-chat__avatar-image str-chat__avatar-image{{\n isLoaded ? ' str-chat__avatar-image--loaded' : ''\n }}\"\n src=\"{{ imageUrl }}\"\n alt=\"{{ initials }}\"\n data-testid=\"avatar-img\"\n (load)=\"isLoaded = true\"\n (error)=\"isError = true\"\n [style]=\"{\n flexBasis: 'calc(var(--str-chat__spacing-px, 1px) * ' + size + ')',\n height: 'calc(var(--str-chat__spacing-px, 1px) * ' + size + ')',\n objectFit: 'cover',\n width: 'calc(var(--str-chat__spacing-px, 1px) * ' + size + ')'\n }\"\n />\n <ng-template #fallback>\n <div data-testid=\"fallback-img\" class=\"str-chat__avatar-fallback\">\n {{ initials }}\n </div>\n </ng-template>\n</div>\n", styles: [""], directives: [{ type: i4__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
2699
+ AvatarComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.5", type: AvatarComponent, selector: "stream-avatar", inputs: { name: "name", imageUrl: "imageUrl", size: "size", location: "location", channel: "channel", user: "user", type: "type" }, ngImport: i0__namespace, template: "<div\n class=\"str-chat__avatar str-chat__avatar--circle stream-chat__avatar--{{\n location\n }}\"\n title=\"{{ name }}\"\n [style]=\"{\n flexBasis: 'calc(var(--str-chat__spacing-px, 1px) * ' + size + ')',\n fontSize: 'calc(var(--str-chat__spacing-px, 1px) * ' + size / 2 + ')',\n height: 'calc(var(--str-chat__spacing-px, 1px) * ' + size + ')',\n lineHeight: 'calc(var(--str-chat__spacing-px, 1px) * ' + size + ')',\n width: 'calc(var(--str-chat__spacing-px, 1px) * ' + size + ')'\n }\"\n>\n <img\n *ngIf=\"(imageUrl || fallbackChannelImage) && !isError; else fallback\"\n class=\"str-chat__avatar-image str-chat__avatar-image{{\n isLoaded ? ' str-chat__avatar-image--loaded' : ''\n }}\"\n src=\"{{ imageUrl || fallbackChannelImage }}\"\n alt=\"{{ initials }}\"\n data-testid=\"avatar-img\"\n (load)=\"isLoaded = true\"\n (error)=\"isError = true\"\n [style]=\"{\n flexBasis: 'calc(var(--str-chat__spacing-px, 1px) * ' + size + ')',\n height: 'calc(var(--str-chat__spacing-px, 1px) * ' + size + ')',\n objectFit: 'cover',\n width: 'calc(var(--str-chat__spacing-px, 1px) * ' + size + ')'\n }\"\n />\n <ng-template #fallback>\n <div data-testid=\"fallback-img\" class=\"str-chat__avatar-fallback\">\n {{ initials }}\n </div>\n </ng-template>\n</div>\n", styles: [""], directives: [{ type: i4__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
2666
2700
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.5", ngImport: i0__namespace, type: AvatarComponent, decorators: [{
2667
2701
  type: i0.Component,
2668
2702
  args: [{