stream-chat-angular 4.39.5 → 4.39.7

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.
@@ -20,7 +20,7 @@ import transliterate from '@stream-io/transliterate';
20
20
  import * as i8 from 'angular-mentions';
21
21
  import { MentionModule } from 'angular-mentions';
22
22
 
23
- const version = '4.39.5';
23
+ const version = '4.39.7';
24
24
 
25
25
  /**
26
26
  * The `NotificationService` can be used to add or remove notifications. By default the [`NotificationList`](../components/NotificationListComponent.mdx) component displays the currently active notifications.
@@ -309,6 +309,7 @@ class ChannelService {
309
309
  this.activeChannelPinnedMessagesSubject = new BehaviorSubject([]);
310
310
  this.hasMoreChannelsSubject = new ReplaySubject(1);
311
311
  this.activeChannelSubscriptions = [];
312
+ this.channelSubscriptions = {};
312
313
  this.activeParentMessageIdSubject = new BehaviorSubject(undefined);
313
314
  this.activeThreadMessagesSubject = new BehaviorSubject([]);
314
315
  this.jumpToMessageSubject = new BehaviorSubject({ id: undefined, parentId: undefined });
@@ -320,12 +321,12 @@ class ChannelService {
320
321
  this._shouldMarkActiveChannelAsRead = true;
321
322
  this.isStateRecoveryInProgress = false;
322
323
  this.channelQueryStateSubject = new BehaviorSubject(undefined);
323
- this.channelListSetter = (channels) => {
324
+ this.channelListSetter = (channels, shouldStopWatchingRemovedChannels = true) => {
324
325
  const currentChannels = this.channelsSubject.getValue() || [];
325
326
  const newChannels = channels.filter((c) => !currentChannels.find((channel) => channel.cid === c.cid));
326
327
  const deletedChannels = currentChannels.filter((c) => !(channels === null || channels === void 0 ? void 0 : channels.find((channel) => channel.cid === c.cid)));
327
328
  void this.addChannelsFromNotification(newChannels);
328
- this.removeChannelsFromChannelList(deletedChannels.map((c) => c.cid));
329
+ this.removeChannelsFromChannelList(deletedChannels.map((c) => c.cid), shouldStopWatchingRemovedChannels);
329
330
  };
330
331
  this.messageListSetter = (messages) => {
331
332
  this.activeChannelMessagesSubject.next(messages);
@@ -568,6 +569,10 @@ class ChannelService {
568
569
  (_a = this.clientEventsSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
569
570
  (_b = this.dismissErrorNotification) === null || _b === void 0 ? void 0 : _b.call(this);
570
571
  this.dismissErrorNotification = undefined;
572
+ Object.keys(this.channelSubscriptions).forEach((cid) => {
573
+ this.channelSubscriptions[cid]();
574
+ });
575
+ this.channelSubscriptions = {};
571
576
  }
572
577
  /**
573
578
  * 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.
@@ -966,7 +971,7 @@ class ChannelService {
966
971
  }
967
972
  handleRemovedFromChannelNotification(clientEvent) {
968
973
  const channelIdToBeRemoved = clientEvent.event.channel.cid;
969
- this.removeChannelsFromChannelList([channelIdToBeRemoved]);
974
+ this.removeChannelsFromChannelList([channelIdToBeRemoved], true);
970
975
  }
971
976
  handleNewMessageNotification(clientEvent) {
972
977
  if (clientEvent.event.channel) {
@@ -996,13 +1001,19 @@ class ChannelService {
996
1001
  }
997
1002
  });
998
1003
  }
999
- removeChannelsFromChannelList(cids) {
1004
+ removeChannelsFromChannelList(cids, shouldStopWatching) {
1000
1005
  var _a;
1001
1006
  const channels = this.channels.filter((c) => !cids.includes(c.cid || ''));
1002
- cids.forEach((cid) => {
1003
- var _a;
1004
- return void ((_a = this.chatClientService.chatClient.activeChannels[cid]) === null || _a === void 0 ? void 0 : _a.stopWatching());
1005
- });
1007
+ if (shouldStopWatching) {
1008
+ cids.forEach((cid) => {
1009
+ var _a;
1010
+ if (this.channelSubscriptions[cid]) {
1011
+ this.channelSubscriptions[cid]();
1012
+ delete this.channelSubscriptions.cid;
1013
+ }
1014
+ void ((_a = this.chatClientService.chatClient.activeChannels[cid]) === null || _a === void 0 ? void 0 : _a.stopWatching());
1015
+ });
1016
+ }
1006
1017
  if (channels.length < this.channels.length) {
1007
1018
  this.channelsSubject.next(channels);
1008
1019
  if (cids.includes(((_a = this.activeChannelSubject.getValue()) === null || _a === void 0 ? void 0 : _a.cid) || '')) {
@@ -1197,7 +1208,7 @@ class ChannelService {
1197
1208
  });
1198
1209
  }
1199
1210
  watchForChannelEvents(channel) {
1200
- channel.on((event) => {
1211
+ const unsubscribe = channel.on((event) => {
1201
1212
  switch (event.type) {
1202
1213
  case 'message.new': {
1203
1214
  this.ngZone.run(() => {
@@ -1267,6 +1278,7 @@ class ChannelService {
1267
1278
  }
1268
1279
  }
1269
1280
  });
1281
+ this.channelSubscriptions[channel.cid] = unsubscribe.unsubscribe;
1270
1282
  }
1271
1283
  handleNewMessage(_, channel) {
1272
1284
  const channelIndex = this.channels.findIndex((c) => c.cid === channel.cid);
@@ -1274,10 +1286,10 @@ class ChannelService {
1274
1286
  this.channelsSubject.next([channel, ...this.channels]);
1275
1287
  }
1276
1288
  handleChannelHidden(event) {
1277
- this.removeChannelsFromChannelList([event.channel.cid]);
1289
+ this.removeChannelsFromChannelList([event.channel.cid], false);
1278
1290
  }
1279
1291
  handleChannelDeleted(event) {
1280
- this.removeChannelsFromChannelList([event.channel.cid]);
1292
+ this.removeChannelsFromChannelList([event.channel.cid], true);
1281
1293
  }
1282
1294
  handleChannelVisible(event, channel) {
1283
1295
  if (!this.channels.find((c) => c.cid === event.cid)) {
@@ -2469,11 +2481,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.5", ngImpor
2469
2481
  * The `AvatarPlaceholder` component displays the [default avatar](./AvatarComponent.mdx) unless a [custom template](../services/CustomTemplatesService.mdx) is provided. This component is used by the SDK internally, you likely won't need to use it.
2470
2482
  */
2471
2483
  class AvatarPlaceholderComponent {
2472
- constructor(customTemplatesService, hostElement, cdRef, themeService) {
2484
+ constructor(customTemplatesService) {
2473
2485
  this.customTemplatesService = customTemplatesService;
2474
- this.hostElement = hostElement;
2475
- this.cdRef = cdRef;
2476
- this.themeService = themeService;
2477
2486
  /**
2478
2487
  * The size in pixels of the avatar image.
2479
2488
  */
@@ -2497,26 +2506,6 @@ class AvatarPlaceholderComponent {
2497
2506
  initialsType: undefined,
2498
2507
  showOnlineIndicator: undefined,
2499
2508
  };
2500
- this.isVisible = true;
2501
- }
2502
- ngAfterViewInit() {
2503
- var _a, _b;
2504
- const elementToObserve = (_b = (_a = this.hostElement.nativeElement.parentElement) === null || _a === void 0 ? void 0 : _a.parentElement) === null || _b === void 0 ? void 0 : _b.parentElement;
2505
- if (this.location !== 'message-sender' ||
2506
- !elementToObserve ||
2507
- !elementToObserve.classList.contains('str-chat__li') ||
2508
- this.themeService.themeVersion === '1') {
2509
- this.isVisible = true;
2510
- this.cdRef.detectChanges();
2511
- return;
2512
- }
2513
- this.checkIfVisible();
2514
- this.mutationObserver = new MutationObserver(() => {
2515
- this.checkIfVisible();
2516
- });
2517
- this.mutationObserver.observe(elementToObserve, {
2518
- attributeFilter: ['class'],
2519
- });
2520
2509
  }
2521
2510
  ngOnChanges() {
2522
2511
  this.context = {
@@ -2531,20 +2520,9 @@ class AvatarPlaceholderComponent {
2531
2520
  showOnlineIndicator: this.showOnlineIndicator,
2532
2521
  };
2533
2522
  }
2534
- ngOnDestroy() {
2535
- var _a;
2536
- (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
2537
- }
2538
- checkIfVisible() {
2539
- const isVisible = getComputedStyle(this.hostElement.nativeElement).getPropertyValue('visibility') === 'visible';
2540
- if (isVisible !== this.isVisible) {
2541
- this.isVisible = isVisible;
2542
- this.cdRef.detectChanges();
2543
- }
2544
- }
2545
2523
  }
2546
- AvatarPlaceholderComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.5", ngImport: i0, type: AvatarPlaceholderComponent, deps: [{ token: CustomTemplatesService }, { token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: ThemeService }], target: i0.ɵɵFactoryTarget.Component });
2547
- AvatarPlaceholderComponent.ɵcmp = i0.ɵɵ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", initialsType: "initialsType", showOnlineIndicator: "showOnlineIndicator" }, usesOnChanges: true, ngImport: i0, 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 let-initialsType=\"initialsType\"\n let-showOnlineIndicator=\"showOnlineIndicator\"\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 [initialsType]=\"initialsType\"\n [showOnlineIndicator]=\"showOnlineIndicator\"\n ></stream-avatar>\n</ng-template>\n<ng-container *ngIf=\"isVisible; else emptyPlaceholder\">\n <ng-container\n *ngTemplateOutlet=\"\n (customTemplatesService.avatarTemplate$ | async) || defaultAvatar;\n context: context\n \"\n ></ng-container>\n</ng-container>\n<ng-template #emptyPlaceholder>\n <div\n class=\"str-chat__avatar\"\n [ngStyle]=\"{\n width: 'calc(var(--str-chat__spacing-px, 1px) * ' + size + ')',\n height: 'calc(var(--str-chat__spacing-px, 1px) * ' + size + ')'\n }\"\n ></div>\n</ng-template>\n", components: [{ type: AvatarComponent, selector: "stream-avatar", inputs: ["name", "imageUrl", "size", "location", "channel", "user", "type", "showOnlineIndicator", "initialsType"] }], directives: [{ type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i5.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }, { type: i5.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }], pipes: { "async": i5.AsyncPipe } });
2524
+ AvatarPlaceholderComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.5", ngImport: i0, type: AvatarPlaceholderComponent, deps: [{ token: CustomTemplatesService }], target: i0.ɵɵFactoryTarget.Component });
2525
+ AvatarPlaceholderComponent.ɵcmp = i0.ɵɵ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", initialsType: "initialsType", showOnlineIndicator: "showOnlineIndicator" }, usesOnChanges: true, ngImport: i0, 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 let-initialsType=\"initialsType\"\n let-showOnlineIndicator=\"showOnlineIndicator\"\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 [initialsType]=\"initialsType\"\n [showOnlineIndicator]=\"showOnlineIndicator\"\n ></stream-avatar>\n</ng-template>\n<ng-container\n *ngTemplateOutlet=\"\n (customTemplatesService.avatarTemplate$ | async) || defaultAvatar;\n context: context\n \"\n></ng-container>\n", components: [{ type: AvatarComponent, selector: "stream-avatar", inputs: ["name", "imageUrl", "size", "location", "channel", "user", "type", "showOnlineIndicator", "initialsType"] }], directives: [{ type: i5.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }], pipes: { "async": i5.AsyncPipe } });
2548
2526
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.5", ngImport: i0, type: AvatarPlaceholderComponent, decorators: [{
2549
2527
  type: Component,
2550
2528
  args: [{
@@ -2552,7 +2530,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.5", ngImpor
2552
2530
  templateUrl: './avatar-placeholder.component.html',
2553
2531
  styles: [],
2554
2532
  }]
2555
- }], ctorParameters: function () { return [{ type: CustomTemplatesService }, { type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: ThemeService }]; }, propDecorators: { name: [{
2533
+ }], ctorParameters: function () { return [{ type: CustomTemplatesService }]; }, propDecorators: { name: [{
2556
2534
  type: Input
2557
2535
  }], imageUrl: [{
2558
2536
  type: Input