stream-chat-angular 4.68.2 → 4.68.3

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.3';
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,13 +496,15 @@ 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;
501
- if (((_b = channel.state.latestMessages[channel.state.latestMessages.length - 1]) === null || _b === void 0 ? void 0 : _b.id) === this.activeChannelLastReadMessageId) {
503
+ this.activeChannelUnreadCount = (readState === null || readState === void 0 ? void 0 : readState.unread_messages) || 0;
504
+ if (((_b = channel.state.latestMessages[channel.state.latestMessages.length - 1]) === null || _b === void 0 ? void 0 : _b.id) === this.activeChannelLastReadMessageId ||
505
+ this.activeChannelUnreadCount === 0) {
502
506
  this.activeChannelLastReadMessageId = undefined;
503
507
  }
504
- this.activeChannelUnreadCount = (readState === null || readState === void 0 ? void 0 : readState.unread_messages) || 0;
505
508
  this.watchForActiveChannelEvents(channel);
506
509
  this.addChannel(channel);
507
510
  this.activeChannelSubject.next(channel);
@@ -520,6 +523,7 @@ class ChannelService {
520
523
  return;
521
524
  }
522
525
  this.stopWatchForActiveChannelEvents(activeChannel);
526
+ this.flushMarkReadQueue();
523
527
  this.activeChannelMessagesSubject.next([]);
524
528
  this.activeChannelSubject.next(undefined);
525
529
  this.activeParentMessageIdSubject.next(undefined);
@@ -1288,6 +1292,9 @@ class ChannelService {
1288
1292
  this.ngZone.run(() => {
1289
1293
  this.activeChannelLastReadMessageId = e.last_read_message_id;
1290
1294
  this.activeChannelUnreadCount = e.unread_messages;
1295
+ if (this.activeChannelUnreadCount === 0) {
1296
+ this.activeChannelLastReadMessageId = undefined;
1297
+ }
1291
1298
  this.activeChannelSubject.next(this.activeChannel);
1292
1299
  });
1293
1300
  }));
@@ -1809,13 +1816,41 @@ class ChannelService {
1809
1816
  this.usersTypingInChannelSubject.next([]);
1810
1817
  this.usersTypingInThreadSubject.next([]);
1811
1818
  }
1812
- markRead(channel) {
1819
+ markRead(channel, isThrottled = true) {
1813
1820
  if (this.canSendReadEvents &&
1814
1821
  this.shouldMarkActiveChannelAsRead &&
1815
- !this.areReadEventsPaused) {
1816
- void channel.markRead();
1822
+ !this.areReadEventsPaused &&
1823
+ channel.countUnread() > 0) {
1824
+ if (isThrottled) {
1825
+ this.markReadThrottled(channel);
1826
+ }
1827
+ else {
1828
+ void channel.markRead();
1829
+ }
1817
1830
  }
1818
1831
  }
1832
+ markReadThrottled(channel) {
1833
+ if (!this.markReadTimeout) {
1834
+ this.markRead(channel, false);
1835
+ this.markReadTimeout = setTimeout(() => {
1836
+ this.flushMarkReadQueue();
1837
+ }, this.markReadThrottleTime);
1838
+ }
1839
+ else {
1840
+ clearTimeout(this.markReadTimeout);
1841
+ this.scheduledMarkReadRequest = () => this.markRead(channel, false);
1842
+ this.markReadTimeout = setTimeout(() => {
1843
+ this.flushMarkReadQueue();
1844
+ }, this.markReadThrottleTime);
1845
+ }
1846
+ }
1847
+ flushMarkReadQueue() {
1848
+ var _a;
1849
+ (_a = this.scheduledMarkReadRequest) === null || _a === void 0 ? void 0 : _a.call(this);
1850
+ this.scheduledMarkReadRequest = undefined;
1851
+ clearTimeout(this.markReadTimeout);
1852
+ this.markReadTimeout = undefined;
1853
+ }
1819
1854
  setNextPageConfiguration(channelQueryResult) {
1820
1855
  var _a;
1821
1856
  if (this.customPaginator) {
@@ -2616,6 +2651,9 @@ class AvatarComponent {
2616
2651
  this.setFallbackChannelImage();
2617
2652
  }
2618
2653
  }
2654
+ ngOnDestroy() {
2655
+ this.subscriptions.forEach((s) => s.unsubscribe());
2656
+ }
2619
2657
  setFallbackChannelImage() {
2620
2658
  if (this.type !== 'channel') {
2621
2659
  this.fallbackChannelImage = undefined;