stream-chat-angular 4.68.2 → 4.68.4

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$1 from 'angular-mentions';
21
21
  import { MentionModule } from 'angular-mentions';
22
22
 
23
- const version = '4.68.2';
23
+ const version = '4.68.4';
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.
@@ -387,6 +387,7 @@ class ChannelService {
387
387
  this.activeParentMessageIdSubject.next(message === null || message === void 0 ? void 0 : message.id);
388
388
  };
389
389
  this.areReadEventsPaused = false;
390
+ this.markReadThrottleTime = 1050;
390
391
  this.channels$ = this.channelsSubject.asObservable().pipe(shareReplay(1));
391
392
  this.activeChannel$ = this.activeChannelSubject
392
393
  .asObservable()
@@ -495,6 +496,7 @@ class ChannelService {
495
496
  return;
496
497
  }
497
498
  this.stopWatchForActiveChannelEvents(prevActiveChannel);
499
+ this.flushMarkReadQueue();
498
500
  this.areReadEventsPaused = false;
499
501
  const readState = channel.state.read[((_a = this.chatClientService.chatClient.user) === null || _a === void 0 ? void 0 : _a.id) || ''];
500
502
  this.activeChannelLastReadMessageId = readState === null || readState === void 0 ? void 0 : readState.last_read_message_id;
@@ -520,6 +522,7 @@ class ChannelService {
520
522
  return;
521
523
  }
522
524
  this.stopWatchForActiveChannelEvents(activeChannel);
525
+ this.flushMarkReadQueue();
523
526
  this.activeChannelMessagesSubject.next([]);
524
527
  this.activeChannelSubject.next(undefined);
525
528
  this.activeParentMessageIdSubject.next(undefined);
@@ -1809,13 +1812,40 @@ class ChannelService {
1809
1812
  this.usersTypingInChannelSubject.next([]);
1810
1813
  this.usersTypingInThreadSubject.next([]);
1811
1814
  }
1812
- markRead(channel) {
1815
+ markRead(channel, isThrottled = true) {
1813
1816
  if (this.canSendReadEvents &&
1814
1817
  this.shouldMarkActiveChannelAsRead &&
1815
1818
  !this.areReadEventsPaused) {
1816
- void channel.markRead();
1819
+ if (isThrottled) {
1820
+ this.markReadThrottled(channel);
1821
+ }
1822
+ else {
1823
+ void channel.markRead();
1824
+ }
1825
+ }
1826
+ }
1827
+ markReadThrottled(channel) {
1828
+ if (!this.markReadTimeout) {
1829
+ this.markRead(channel, false);
1830
+ this.markReadTimeout = setTimeout(() => {
1831
+ this.flushMarkReadQueue();
1832
+ }, this.markReadThrottleTime);
1833
+ }
1834
+ else {
1835
+ clearTimeout(this.markReadTimeout);
1836
+ this.scheduledMarkReadRequest = () => this.markRead(channel, false);
1837
+ this.markReadTimeout = setTimeout(() => {
1838
+ this.flushMarkReadQueue();
1839
+ }, this.markReadThrottleTime);
1817
1840
  }
1818
1841
  }
1842
+ flushMarkReadQueue() {
1843
+ var _a;
1844
+ (_a = this.scheduledMarkReadRequest) === null || _a === void 0 ? void 0 : _a.call(this);
1845
+ this.scheduledMarkReadRequest = undefined;
1846
+ clearTimeout(this.markReadTimeout);
1847
+ this.markReadTimeout = undefined;
1848
+ }
1819
1849
  setNextPageConfiguration(channelQueryResult) {
1820
1850
  var _a;
1821
1851
  if (this.customPaginator) {
@@ -2616,6 +2646,9 @@ class AvatarComponent {
2616
2646
  this.setFallbackChannelImage();
2617
2647
  }
2618
2648
  }
2649
+ ngOnDestroy() {
2650
+ this.subscriptions.forEach((s) => s.unsubscribe());
2651
+ }
2619
2652
  setFallbackChannelImage() {
2620
2653
  if (this.type !== 'channel') {
2621
2654
  this.fallbackChannelImage = undefined;