stream-chat-angular 5.8.2 → 5.8.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.
@@ -21,7 +21,7 @@ import transliterate from '@stream-io/transliterate';
21
21
  import * as i7 from 'angular-mentions';
22
22
  import { MentionModule } from 'angular-mentions';
23
23
 
24
- const version = '5.8.2';
24
+ const version = '5.8.4';
25
25
 
26
26
  /**
27
27
  * The `NotificationService` can be used to add or remove notifications. By default the [`NotificationList`](../components/NotificationListComponent.mdx) component displays the currently active notifications.
@@ -7677,6 +7677,7 @@ class MessageListComponent {
7677
7677
  this.isLatestMessageInList = true;
7678
7678
  this.parsedDates = new Map();
7679
7679
  this.isViewInited = false;
7680
+ this.jumpToMessageTimeouts = [];
7680
7681
  this.forceRepaintSubject = new Subject();
7681
7682
  this.isSafari = isSafari();
7682
7683
  this.scrollPosition$ = new BehaviorSubject('bottom');
@@ -7704,6 +7705,9 @@ class MessageListComponent {
7704
7705
  if (this.checkIfUnreadNotificationIsVisibleTimeout) {
7705
7706
  clearTimeout(this.checkIfUnreadNotificationIsVisibleTimeout);
7706
7707
  }
7708
+ this.jumpToMessageTimeouts.forEach((timeout) => clearTimeout(timeout));
7709
+ this.jumpToMessageTimeouts = [];
7710
+ this.highlightedMessageId = undefined;
7707
7711
  this.isUnreadNotificationVisible = false;
7708
7712
  this.parsedDates = new Map();
7709
7713
  this.resetScrollState();
@@ -7905,6 +7909,7 @@ class MessageListComponent {
7905
7909
  if (this.jumpToLatestButtonVisibilityTimeout) {
7906
7910
  clearTimeout(this.jumpToLatestButtonVisibilityTimeout);
7907
7911
  }
7912
+ this.jumpToMessageTimeouts.forEach((timeout) => clearTimeout(timeout));
7908
7913
  this.disposeVirtualizedList();
7909
7914
  }
7910
7915
  trackByMessageId(_, item) {
@@ -7950,19 +7955,7 @@ class MessageListComponent {
7950
7955
  }
7951
7956
  }
7952
7957
  this.scroll$.next();
7953
- let scrollPosition = this.getScrollPosition();
7954
- const isUserScrolled = (this.direction === 'bottom-to-top'
7955
- ? scrollPosition !== 'bottom'
7956
- : scrollPosition !== 'top') || !this.isLatestMessageInList;
7957
- if (this.isUserScrolled !== isUserScrolled) {
7958
- this.ngZone.run(() => {
7959
- this.isUserScrolled = isUserScrolled;
7960
- if (!this.isUserScrolled) {
7961
- this.newMessageCountWhileBeingScrolled = 0;
7962
- }
7963
- this.cdRef.detectChanges();
7964
- });
7965
- }
7958
+ this.checkIfUserScrolled();
7966
7959
  if (this.hideJumpToLatestButtonDuringScroll) {
7967
7960
  if (this.isJumpToLatestButtonVisible) {
7968
7961
  this.isJumpToLatestButtonVisible = false;
@@ -7979,33 +7972,6 @@ class MessageListComponent {
7979
7972
  }
7980
7973
  }, 100);
7981
7974
  }
7982
- const prevScrollPosition = this.scrollPosition$.getValue();
7983
- if (this.direction === 'top-to-bottom') {
7984
- if (scrollPosition === 'top') {
7985
- scrollPosition = 'bottom';
7986
- }
7987
- else if (scrollPosition === 'bottom') {
7988
- scrollPosition = 'top';
7989
- }
7990
- }
7991
- if (prevScrollPosition !== scrollPosition && !this.isJumpingToMessage) {
7992
- if (scrollPosition === 'top' || scrollPosition === 'bottom') {
7993
- this.virtualizedList?.virtualizedItems$
7994
- .pipe(take(1))
7995
- .subscribe((items) => {
7996
- this.messageIdToAnchorTo =
7997
- scrollPosition === 'top'
7998
- ? items[0]?.id
7999
- : items[items.length - 1]?.id;
8000
- this.anchorMessageTopOffset = document
8001
- .getElementById(this.messageIdToAnchorTo)
8002
- ?.getBoundingClientRect()?.top;
8003
- });
8004
- }
8005
- this.ngZone.run(() => {
8006
- this.scrollPosition$.next(scrollPosition);
8007
- });
8008
- }
8009
7975
  }
8010
7976
  jumpToFirstUnreadMessage() {
8011
7977
  if (!this.lastReadMessageId) {
@@ -8045,6 +8011,48 @@ class MessageListComponent {
8045
8011
  ? this.emptyMainMessageListTemplate
8046
8012
  : this.emptyThreadMessageListTemplate;
8047
8013
  }
8014
+ checkIfUserScrolled() {
8015
+ let scrollPosition = this.getScrollPosition();
8016
+ const isUserScrolled = (this.direction === 'bottom-to-top'
8017
+ ? scrollPosition !== 'bottom'
8018
+ : scrollPosition !== 'top') || !this.isLatestMessageInList;
8019
+ if (this.isUserScrolled !== isUserScrolled) {
8020
+ this.ngZone.run(() => {
8021
+ this.isUserScrolled = isUserScrolled;
8022
+ if (!this.isUserScrolled) {
8023
+ this.newMessageCountWhileBeingScrolled = 0;
8024
+ }
8025
+ this.cdRef.detectChanges();
8026
+ });
8027
+ }
8028
+ const prevScrollPosition = this.scrollPosition$.getValue();
8029
+ if (this.direction === 'top-to-bottom') {
8030
+ if (scrollPosition === 'top') {
8031
+ scrollPosition = 'bottom';
8032
+ }
8033
+ else if (scrollPosition === 'bottom') {
8034
+ scrollPosition = 'top';
8035
+ }
8036
+ }
8037
+ if (prevScrollPosition !== scrollPosition && !this.isJumpingToMessage) {
8038
+ if (scrollPosition === 'top' || scrollPosition === 'bottom') {
8039
+ this.virtualizedList?.virtualizedItems$
8040
+ .pipe(take(1))
8041
+ .subscribe((items) => {
8042
+ this.messageIdToAnchorTo =
8043
+ scrollPosition === 'top'
8044
+ ? items[0]?.id
8045
+ : items[items.length - 1]?.id;
8046
+ this.anchorMessageTopOffset = document
8047
+ .getElementById(this.messageIdToAnchorTo)
8048
+ ?.getBoundingClientRect()?.top;
8049
+ });
8050
+ }
8051
+ this.ngZone.run(() => {
8052
+ this.scrollPosition$.next(scrollPosition);
8053
+ });
8054
+ }
8055
+ }
8048
8056
  preserveScrollbarPosition() {
8049
8057
  if (!this.messageIdToAnchorTo) {
8050
8058
  return;
@@ -8184,9 +8192,11 @@ class MessageListComponent {
8184
8192
  }
8185
8193
  scrollMessageIntoView(options, withRetry = true) {
8186
8194
  const element = document.getElementById(options.messageId);
8195
+ this.jumpToMessageTimeouts.forEach((t) => clearTimeout(t));
8196
+ this.jumpToMessageTimeouts = [];
8187
8197
  if (!element && withRetry) {
8188
8198
  // If the message was newly inserted into activeChannelMessages$, the message will be rendered after the current change detection cycle -> wait for this cycle to complete
8189
- setTimeout(() => this.scrollMessageIntoView(options, false));
8199
+ this.jumpToMessageTimeouts.push(setTimeout(() => this.scrollMessageIntoView(options, false)));
8190
8200
  }
8191
8201
  else if (element) {
8192
8202
  const blockMapping = {
@@ -8194,7 +8204,9 @@ class MessageListComponent {
8194
8204
  bottom: 'end',
8195
8205
  middle: 'center',
8196
8206
  };
8207
+ // We can't know when smooth scrolling ends, so we set the behavior to instant https://github.com/w3c/csswg-drafts/issues/3744
8197
8208
  element.scrollIntoView({
8209
+ behavior: 'instant',
8198
8210
  block: blockMapping[options.position],
8199
8211
  });
8200
8212
  if (options.position !== 'middle') {
@@ -8202,15 +8214,19 @@ class MessageListComponent {
8202
8214
  ? this.scrollToBottom()
8203
8215
  : this.scrollToTop();
8204
8216
  }
8205
- setTimeout(() => {
8217
+ this.jumpToMessageTimeouts.push(setTimeout(() => {
8206
8218
  this.isJumpingToMessage = false;
8207
- }, 0);
8208
- setTimeout(() => {
8219
+ if (!this.isUserScrolled) {
8220
+ this.checkIfUserScrolled();
8221
+ }
8222
+ }, 200));
8223
+ this.jumpToMessageTimeouts.push(setTimeout(() => {
8209
8224
  this.highlightedMessageId = undefined;
8210
8225
  this.firstUnreadMessageId = undefined;
8211
8226
  this.isJumpingToLatestUnreadMessage = false;
8227
+ this.jumpToMessageTimeouts = [];
8212
8228
  this.cdRef.detectChanges();
8213
- }, 1000);
8229
+ }, 1000));
8214
8230
  }
8215
8231
  }
8216
8232
  newMessageReceived(message) {