stream-chat-angular 4.13.0 → 4.14.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.13.0";
1
+ export declare const version = "4.14.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.13.0';
358
+ var version = '4.14.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.
@@ -2677,15 +2677,73 @@
2677
2677
  * The `Avatar` component displays the provided image, with fallback to the first letter of the optional name input.
2678
2678
  */
2679
2679
  var AvatarComponent = /** @class */ (function () {
2680
- function AvatarComponent(chatClientService) {
2680
+ function AvatarComponent(chatClientService, ngZone) {
2681
2681
  this.chatClientService = chatClientService;
2682
+ this.ngZone = ngZone;
2682
2683
  /**
2683
2684
  * The size in pixels of the avatar image.
2684
2685
  */
2685
2686
  this.size = 32;
2687
+ /**
2688
+ * If a channel avatar is displayed, and if the channel has exactly two members a green dot is displayed if the other member is online. Set this flag to `false` to turn off this behavior.
2689
+ */
2690
+ this.showOnlineIndicator = true;
2686
2691
  this.isLoaded = false;
2687
2692
  this.isError = false;
2693
+ this.isOnline = false;
2688
2694
  }
2695
+ AvatarComponent.prototype.ngOnChanges = function (changes) {
2696
+ var _a, _b, _c;
2697
+ return __awaiter(this, void 0, void 0, function () {
2698
+ var otherMember_1, response, error_1;
2699
+ var _this = this;
2700
+ return __generator(this, function (_f) {
2701
+ switch (_f.label) {
2702
+ case 0:
2703
+ if (!changes['channel']) return [3 /*break*/, 8];
2704
+ if (!this.channel) return [3 /*break*/, 7];
2705
+ otherMember_1 = this.getOtherMemberIfOneToOneChannel();
2706
+ if (!otherMember_1) return [3 /*break*/, 5];
2707
+ this.isOnlineSubscription = this.chatClientService.events$
2708
+ .pipe(operators.filter(function (e) { return e.eventType === 'user.presence.changed'; }))
2709
+ .subscribe(function (event) {
2710
+ var _a;
2711
+ if (((_a = event.event.user) === null || _a === void 0 ? void 0 : _a.id) === otherMember_1.id) {
2712
+ _this.ngZone.run(function () {
2713
+ var _a;
2714
+ _this.isOnline = ((_a = event.event.user) === null || _a === void 0 ? void 0 : _a.online) || false;
2715
+ });
2716
+ }
2717
+ });
2718
+ _f.label = 1;
2719
+ case 1:
2720
+ _f.trys.push([1, 3, , 4]);
2721
+ return [4 /*yield*/, this.chatClientService.chatClient.queryUsers({
2722
+ id: { $eq: otherMember_1.id },
2723
+ })];
2724
+ case 2:
2725
+ response = _f.sent();
2726
+ this.isOnline = ((_a = response.users[0]) === null || _a === void 0 ? void 0 : _a.online) || false;
2727
+ return [3 /*break*/, 4];
2728
+ case 3:
2729
+ error_1 = _f.sent();
2730
+ // Fallback if we can't query user -> for example due to permission problems
2731
+ this.isOnline = otherMember_1.online || false;
2732
+ return [3 /*break*/, 4];
2733
+ case 4: return [3 /*break*/, 6];
2734
+ case 5:
2735
+ (_b = this.isOnlineSubscription) === null || _b === void 0 ? void 0 : _b.unsubscribe();
2736
+ _f.label = 6;
2737
+ case 6: return [3 /*break*/, 8];
2738
+ case 7:
2739
+ this.isOnline = false;
2740
+ (_c = this.isOnlineSubscription) === null || _c === void 0 ? void 0 : _c.unsubscribe();
2741
+ _f.label = 8;
2742
+ case 8: return [2 /*return*/];
2743
+ }
2744
+ });
2745
+ });
2746
+ };
2689
2747
  Object.defineProperty(AvatarComponent.prototype, "initials", {
2690
2748
  get: function () {
2691
2749
  var _a, _b, _c, _d, _e;
@@ -2743,8 +2801,8 @@
2743
2801
  };
2744
2802
  return AvatarComponent;
2745
2803
  }());
2746
- 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 });
2747
- 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: i7__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
2804
+ AvatarComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.5", ngImport: i0__namespace, type: AvatarComponent, deps: [{ token: ChatClientService }, { token: i0__namespace.NgZone }], target: i0__namespace.ɵɵFactoryTarget.Component });
2805
+ 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", showOnlineIndicator: "showOnlineIndicator" }, usesOnChanges: true, 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 data-testid=\"online-indicator\"\n *ngIf=\"isOnline\"\n class=\"str-chat__avatar--online-indicator\"\n ></div>\n</div>\n", styles: [""], directives: [{ type: i7__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
2748
2806
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.5", ngImport: i0__namespace, type: AvatarComponent, decorators: [{
2749
2807
  type: i0.Component,
2750
2808
  args: [{
@@ -2752,7 +2810,7 @@
2752
2810
  templateUrl: './avatar.component.html',
2753
2811
  styleUrls: ['./avatar.component.scss'],
2754
2812
  }]
2755
- }], ctorParameters: function () { return [{ type: ChatClientService }]; }, propDecorators: { name: [{
2813
+ }], ctorParameters: function () { return [{ type: ChatClientService }, { type: i0__namespace.NgZone }]; }, propDecorators: { name: [{
2756
2814
  type: i0.Input
2757
2815
  }], imageUrl: [{
2758
2816
  type: i0.Input
@@ -2766,6 +2824,8 @@
2766
2824
  type: i0.Input
2767
2825
  }], type: [{
2768
2826
  type: i0.Input
2827
+ }], showOnlineIndicator: [{
2828
+ type: i0.Input
2769
2829
  }] } });
2770
2830
 
2771
2831
  /**
@@ -2946,7 +3006,7 @@
2946
3006
  return AvatarPlaceholderComponent;
2947
3007
  }());
2948
3008
  AvatarPlaceholderComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.5", ngImport: i0__namespace, type: AvatarPlaceholderComponent, deps: [{ token: CustomTemplatesService }], target: i0__namespace.ɵɵFactoryTarget.Component });
2949
- AvatarPlaceholderComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.5", type: AvatarPlaceholderComponent, selector: "stream-avatar-placeholder", inputs: { name: "name", imageUrl: "imageUrl", size: "size", location: "location", channel: "channel", user: "user", type: "type" }, ngImport: i0__namespace, template: "<ng-template\n #defaultAvatar\n let-name=\"name\"\n let-imageUrl=\"imageUrl\"\n let-size=\"size\"\n let-type=\"type\"\n let-channel=\"channel\"\n let-user=\"user\"\n let-location=\"location\"\n>\n <stream-avatar\n [name]=\"name\"\n [imageUrl]=\"imageUrl\"\n [size]=\"size\"\n [type]=\"type\"\n [channel]=\"channel\"\n [user]=\"user\"\n [location]=\"location\"\n ></stream-avatar>\n</ng-template>\n<ng-container\n *ngTemplateOutlet=\"\n (customTemplatesService.avatarTemplate$ | async) || defaultAvatar;\n context: getAvatarContext()\n \"\n></ng-container>\n", components: [{ type: AvatarComponent, selector: "stream-avatar", inputs: ["name", "imageUrl", "size", "location", "channel", "user", "type"] }], directives: [{ type: i7__namespace.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }], pipes: { "async": i7__namespace.AsyncPipe } });
3009
+ AvatarPlaceholderComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.5", type: AvatarPlaceholderComponent, selector: "stream-avatar-placeholder", inputs: { name: "name", imageUrl: "imageUrl", size: "size", location: "location", channel: "channel", user: "user", type: "type" }, ngImport: i0__namespace, template: "<ng-template\n #defaultAvatar\n let-name=\"name\"\n let-imageUrl=\"imageUrl\"\n let-size=\"size\"\n let-type=\"type\"\n let-channel=\"channel\"\n let-user=\"user\"\n let-location=\"location\"\n>\n <stream-avatar\n [name]=\"name\"\n [imageUrl]=\"imageUrl\"\n [size]=\"size\"\n [type]=\"type\"\n [channel]=\"channel\"\n [user]=\"user\"\n [location]=\"location\"\n ></stream-avatar>\n</ng-template>\n<ng-container\n *ngTemplateOutlet=\"\n (customTemplatesService.avatarTemplate$ | async) || defaultAvatar;\n context: getAvatarContext()\n \"\n></ng-container>\n", components: [{ type: AvatarComponent, selector: "stream-avatar", inputs: ["name", "imageUrl", "size", "location", "channel", "user", "type", "showOnlineIndicator"] }], directives: [{ type: i7__namespace.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }], pipes: { "async": i7__namespace.AsyncPipe } });
2950
3010
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.5", ngImport: i0__namespace, type: AvatarPlaceholderComponent, decorators: [{
2951
3011
  type: i0.Component,
2952
3012
  args: [{