stream-chat-angular 5.1.1 → 5.1.2
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.
- package/assets/version.d.ts +1 -1
- package/esm2020/assets/version.mjs +2 -2
- package/esm2020/lib/channel.service.mjs +40 -6
- package/fesm2015/stream-chat-angular.mjs +41 -6
- package/fesm2015/stream-chat-angular.mjs.map +1 -1
- package/fesm2020/stream-chat-angular.mjs +40 -6
- package/fesm2020/stream-chat-angular.mjs.map +1 -1
- package/lib/channel.service.d.ts +5 -0
- package/package.json +1 -1
- package/src/assets/version.ts +1 -1
|
@@ -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.
|
|
22
|
+
const version = '5.1.2';
|
|
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,14 +609,16 @@ 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;
|
|
616
|
+
this.activeChannelUnreadCount = readState?.unread_messages || 0;
|
|
614
617
|
if (channel.state.latestMessages[channel.state.latestMessages.length - 1]
|
|
615
|
-
?.id === this.activeChannelLastReadMessageId
|
|
618
|
+
?.id === this.activeChannelLastReadMessageId ||
|
|
619
|
+
this.activeChannelUnreadCount === 0) {
|
|
616
620
|
this.activeChannelLastReadMessageId = undefined;
|
|
617
621
|
}
|
|
618
|
-
this.activeChannelUnreadCount = readState?.unread_messages || 0;
|
|
619
622
|
this.watchForActiveChannelEvents(channel);
|
|
620
623
|
this.addChannel(channel);
|
|
621
624
|
this.activeChannelSubject.next(channel);
|
|
@@ -634,6 +637,7 @@ class ChannelService {
|
|
|
634
637
|
return;
|
|
635
638
|
}
|
|
636
639
|
this.stopWatchForActiveChannelEvents(activeChannel);
|
|
640
|
+
this.flushMarkReadQueue();
|
|
637
641
|
this.activeChannelMessagesSubject.next([]);
|
|
638
642
|
this.activeChannelSubject.next(undefined);
|
|
639
643
|
this.activeParentMessageIdSubject.next(undefined);
|
|
@@ -1407,6 +1411,9 @@ class ChannelService {
|
|
|
1407
1411
|
this.ngZone.run(() => {
|
|
1408
1412
|
this.activeChannelLastReadMessageId = e.last_read_message_id;
|
|
1409
1413
|
this.activeChannelUnreadCount = e.unread_messages;
|
|
1414
|
+
if (this.activeChannelUnreadCount === 0) {
|
|
1415
|
+
this.activeChannelLastReadMessageId = undefined;
|
|
1416
|
+
}
|
|
1410
1417
|
this.activeChannelSubject.next(this.activeChannel);
|
|
1411
1418
|
});
|
|
1412
1419
|
}));
|
|
@@ -1893,12 +1900,39 @@ class ChannelService {
|
|
|
1893
1900
|
this.usersTypingInChannelSubject.next([]);
|
|
1894
1901
|
this.usersTypingInThreadSubject.next([]);
|
|
1895
1902
|
}
|
|
1896
|
-
markRead(channel) {
|
|
1903
|
+
markRead(channel, isThrottled = true) {
|
|
1897
1904
|
if (this.canSendReadEvents &&
|
|
1898
1905
|
this.shouldMarkActiveChannelAsRead &&
|
|
1899
|
-
!this.areReadEventsPaused
|
|
1900
|
-
|
|
1906
|
+
!this.areReadEventsPaused &&
|
|
1907
|
+
channel.countUnread() > 0) {
|
|
1908
|
+
if (isThrottled) {
|
|
1909
|
+
this.markReadThrottled(channel);
|
|
1910
|
+
}
|
|
1911
|
+
else {
|
|
1912
|
+
void channel.markRead();
|
|
1913
|
+
}
|
|
1914
|
+
}
|
|
1915
|
+
}
|
|
1916
|
+
markReadThrottled(channel) {
|
|
1917
|
+
if (!this.markReadTimeout) {
|
|
1918
|
+
this.markRead(channel, false);
|
|
1919
|
+
this.markReadTimeout = setTimeout(() => {
|
|
1920
|
+
this.flushMarkReadQueue();
|
|
1921
|
+
}, this.markReadThrottleTime);
|
|
1901
1922
|
}
|
|
1923
|
+
else {
|
|
1924
|
+
clearTimeout(this.markReadTimeout);
|
|
1925
|
+
this.scheduledMarkReadRequest = () => this.markRead(channel, false);
|
|
1926
|
+
this.markReadTimeout = setTimeout(() => {
|
|
1927
|
+
this.flushMarkReadQueue();
|
|
1928
|
+
}, this.markReadThrottleTime);
|
|
1929
|
+
}
|
|
1930
|
+
}
|
|
1931
|
+
flushMarkReadQueue() {
|
|
1932
|
+
this.scheduledMarkReadRequest?.();
|
|
1933
|
+
this.scheduledMarkReadRequest = undefined;
|
|
1934
|
+
clearTimeout(this.markReadTimeout);
|
|
1935
|
+
this.markReadTimeout = undefined;
|
|
1902
1936
|
}
|
|
1903
1937
|
async _init(settings) {
|
|
1904
1938
|
this.shouldSetActiveChannel = settings.shouldSetActiveChannel;
|