stream-chat-angular 5.1.1 → 5.1.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.
@@ -19,7 +19,7 @@ import transliterate from '@stream-io/transliterate';
19
19
  import * as i8$1 from 'angular-mentions';
20
20
  import { MentionModule } from 'angular-mentions';
21
21
 
22
- const version = '5.1.1';
22
+ const version = '5.1.3';
23
23
 
24
24
  /**
25
25
  * The `NotificationService` can be used to add or remove notifications. By default the [`NotificationList`](../components/NotificationListComponent.mdx) component displays the currently active notifications.
@@ -506,6 +506,7 @@ class ChannelService {
506
506
  this.activeParentMessageIdSubject.next(message?.id);
507
507
  };
508
508
  this.areReadEventsPaused = false;
509
+ this.markReadThrottleTime = 1050;
509
510
  this.channels$ = this.channelsSubject.asObservable().pipe(shareReplay(1));
510
511
  this.activeChannel$ = this.activeChannelSubject
511
512
  .asObservable()
@@ -608,6 +609,7 @@ class ChannelService {
608
609
  return;
609
610
  }
610
611
  this.stopWatchForActiveChannelEvents(prevActiveChannel);
612
+ this.flushMarkReadQueue();
611
613
  this.areReadEventsPaused = false;
612
614
  const readState = channel.state.read[this.chatClientService.chatClient.user?.id || ''];
613
615
  this.activeChannelLastReadMessageId = readState?.last_read_message_id;
@@ -634,6 +636,7 @@ class ChannelService {
634
636
  return;
635
637
  }
636
638
  this.stopWatchForActiveChannelEvents(activeChannel);
639
+ this.flushMarkReadQueue();
637
640
  this.activeChannelMessagesSubject.next([]);
638
641
  this.activeChannelSubject.next(undefined);
639
642
  this.activeParentMessageIdSubject.next(undefined);
@@ -1893,13 +1896,39 @@ class ChannelService {
1893
1896
  this.usersTypingInChannelSubject.next([]);
1894
1897
  this.usersTypingInThreadSubject.next([]);
1895
1898
  }
1896
- markRead(channel) {
1899
+ markRead(channel, isThrottled = true) {
1897
1900
  if (this.canSendReadEvents &&
1898
1901
  this.shouldMarkActiveChannelAsRead &&
1899
1902
  !this.areReadEventsPaused) {
1900
- void channel.markRead();
1903
+ if (isThrottled) {
1904
+ this.markReadThrottled(channel);
1905
+ }
1906
+ else {
1907
+ void channel.markRead();
1908
+ }
1901
1909
  }
1902
1910
  }
1911
+ markReadThrottled(channel) {
1912
+ if (!this.markReadTimeout) {
1913
+ this.markRead(channel, false);
1914
+ this.markReadTimeout = setTimeout(() => {
1915
+ this.flushMarkReadQueue();
1916
+ }, this.markReadThrottleTime);
1917
+ }
1918
+ else {
1919
+ clearTimeout(this.markReadTimeout);
1920
+ this.scheduledMarkReadRequest = () => this.markRead(channel, false);
1921
+ this.markReadTimeout = setTimeout(() => {
1922
+ this.flushMarkReadQueue();
1923
+ }, this.markReadThrottleTime);
1924
+ }
1925
+ }
1926
+ flushMarkReadQueue() {
1927
+ this.scheduledMarkReadRequest?.();
1928
+ this.scheduledMarkReadRequest = undefined;
1929
+ clearTimeout(this.markReadTimeout);
1930
+ this.markReadTimeout = undefined;
1931
+ }
1903
1932
  async _init(settings) {
1904
1933
  this.shouldSetActiveChannel = settings.shouldSetActiveChannel;
1905
1934
  this.messagePageSize = settings.messagePageSize;