stream-chat-angular 4.39.1 → 4.39.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.
@@ -1 +1 @@
1
- export declare const version = "4.39.1";
1
+ export declare const version = "4.39.3";
@@ -356,7 +356,7 @@
356
356
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
357
357
  }
358
358
 
359
- var version = '4.39.1';
359
+ var version = '4.39.3';
360
360
 
361
361
  /**
362
362
  * The `NotificationService` can be used to add or remove notifications. By default the [`NotificationList`](../components/NotificationListComponent.mdx) component displays the currently active notifications.
@@ -790,9 +790,11 @@
790
790
  * If set to false, read events won't be sent as new messages are received. If set to true active channel (if any) will immediately be marked as read.
791
791
  */
792
792
  set: function (shouldMarkActiveChannelAsRead) {
793
- var _a;
794
793
  if (!this._shouldMarkActiveChannelAsRead && shouldMarkActiveChannelAsRead) {
795
- (_a = this.activeChannelSubject.getValue()) === null || _a === void 0 ? void 0 : _a.markRead();
794
+ var activeChannel = this.activeChannelSubject.getValue();
795
+ if (activeChannel && this.canSendReadEvents) {
796
+ void activeChannel.markRead();
797
+ }
796
798
  }
797
799
  this._shouldMarkActiveChannelAsRead = shouldMarkActiveChannelAsRead;
798
800
  },
@@ -806,11 +808,18 @@
806
808
  * @param channel
807
809
  */
808
810
  ChannelService.prototype.setAsActiveChannel = function (channel) {
811
+ var _a, _b;
809
812
  var prevActiveChannel = this.activeChannelSubject.getValue();
810
813
  if ((prevActiveChannel === null || prevActiveChannel === void 0 ? void 0 : prevActiveChannel.cid) === channel.cid) {
811
814
  return;
812
815
  }
813
816
  this.stopWatchForActiveChannelEvents(prevActiveChannel);
817
+ this.activeChannelLastReadMessageId =
818
+ (_b = channel.state.read[((_a = this.chatClientService.chatClient.user) === null || _a === void 0 ? void 0 : _a.id) || '']) === null || _b === void 0 ? void 0 : _b.last_read_message_id;
819
+ if (channel.state.latestMessages[channel.state.latestMessages.length - 1]
820
+ .id === this.activeChannelLastReadMessageId) {
821
+ this.activeChannelLastReadMessageId = undefined;
822
+ }
814
823
  this.watchForActiveChannelEvents(channel);
815
824
  this.addChannel(channel);
816
825
  this.activeChannelSubject.next(channel);
@@ -835,6 +844,7 @@
835
844
  this.activeChannelPinnedMessagesSubject.next([]);
836
845
  this.usersTypingInChannelSubject.next([]);
837
846
  this.usersTypingInThreadSubject.next([]);
847
+ this.activeChannelLastReadMessageId = undefined;
838
848
  };
839
849
  /**
840
850
  * Sets the given `message` as an active parent message. If `undefined` is provided, it will deleselect the current parent message.
@@ -1602,11 +1612,14 @@
1602
1612
  this.activeChannelSubscriptions.push(channel.on('message.new', function (event) {
1603
1613
  _this.ngZone.run(function () {
1604
1614
  event.message && event.message.parent_id
1605
- ? _this.activeThreadMessagesSubject.next(__spreadArray([], __read(channel.state.threads[event.message.parent_id])))
1615
+ ? event.message.parent_id ===
1616
+ _this.activeParentMessageIdSubject.getValue()
1617
+ ? _this.activeThreadMessagesSubject.next(__spreadArray([], __read(channel.state.threads[event.message.parent_id])))
1618
+ : null
1606
1619
  : _this.activeChannelMessagesSubject.next(__spreadArray([], __read(channel.state.messages)));
1607
1620
  _this.activeChannel$.pipe(operators.first()).subscribe(function (c) {
1608
- if (_this.canSendReadEvents && _this.shouldMarkActiveChannelAsRead) {
1609
- void (c === null || c === void 0 ? void 0 : c.markRead());
1621
+ if (c) {
1622
+ _this.markRead(c);
1610
1623
  }
1611
1624
  });
1612
1625
  _this.updateLatestMessages(event);
@@ -2038,9 +2051,7 @@
2038
2051
  m.quoted_message.translation = getMessageTranslation(m.quoted_message, channel, _this.chatClientService.chatClient.user);
2039
2052
  }
2040
2053
  });
2041
- if (this.canSendReadEvents && this.shouldMarkActiveChannelAsRead) {
2042
- void channel.markRead();
2043
- }
2054
+ this.markRead(channel);
2044
2055
  this.activeChannelMessagesSubject.next(__spreadArray([], __read(channel.state.messages)));
2045
2056
  this.activeChannelPinnedMessagesSubject.next(__spreadArray([], __read(channel.state.pinnedMessages)));
2046
2057
  this.activeParentMessageIdSubject.next(undefined);
@@ -2049,6 +2060,11 @@
2049
2060
  this.usersTypingInChannelSubject.next([]);
2050
2061
  this.usersTypingInThreadSubject.next([]);
2051
2062
  };
2063
+ ChannelService.prototype.markRead = function (channel) {
2064
+ if (this.canSendReadEvents && this.shouldMarkActiveChannelAsRead) {
2065
+ void channel.markRead();
2066
+ }
2067
+ };
2052
2068
  return ChannelService;
2053
2069
  }());
2054
2070
  ChannelService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.5", ngImport: i0__namespace, type: ChannelService, deps: [{ token: ChatClientService }, { token: i0__namespace.NgZone }, { token: NotificationService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
@@ -6117,7 +6133,7 @@
6117
6133
  this.subscriptions = [];
6118
6134
  this.isLatestMessageInList = true;
6119
6135
  this.subscriptions.push(this.channelService.activeChannel$.subscribe(function (channel) {
6120
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
6136
+ var _a, _b, _c, _d, _e, _f, _g;
6121
6137
  (_b = (_a = _this.chatClientService.chatClient) === null || _a === void 0 ? void 0 : _a.logger) === null || _b === void 0 ? void 0 : _b.call(_a, 'info', ((channel === null || channel === void 0 ? void 0 : channel.cid) || 'undefined') + " selected", { tags: "message list " + _this.mode });
6122
6138
  if (_this.channelId !== (channel === null || channel === void 0 ? void 0 : channel.id)) {
6123
6139
  (_e = (_d = (_c = _this.chatClientService) === null || _c === void 0 ? void 0 : _c.chatClient) === null || _d === void 0 ? void 0 : _d.logger) === null || _e === void 0 ? void 0 : _e.call(_d, 'info', "new channel is different from prev channel, reseting scroll state", { tags: "message list " + _this.mode });
@@ -6126,11 +6142,7 @@
6126
6142
  if (_this.openMessageListAt === 'last-read-message' &&
6127
6143
  _this.mode === 'main') {
6128
6144
  _this.lastReadMessageId =
6129
- (_g = channel === null || channel === void 0 ? void 0 : channel.state.read[((_f = _this.chatClientService.chatClient.user) === null || _f === void 0 ? void 0 : _f.id) || '']) === null || _g === void 0 ? void 0 : _g.last_read_message_id;
6130
- if (channel &&
6131
- channel.state.latestMessages[channel.state.latestMessages.length - 1].id === _this.lastReadMessageId) {
6132
- _this.lastReadMessageId = undefined;
6133
- }
6145
+ _this.channelService.activeChannelLastReadMessageId;
6134
6146
  if (_this.lastReadMessageId) {
6135
6147
  _this.isJumpingToLatestUnreadMessage = true;
6136
6148
  void _this.channelService.jumpToMessage(_this.lastReadMessageId);
@@ -6140,11 +6152,11 @@
6140
6152
  _this.lastReadMessageId = undefined;
6141
6153
  }
6142
6154
  }
6143
- var capabilites = (_h = channel === null || channel === void 0 ? void 0 : channel.data) === null || _h === void 0 ? void 0 : _h.own_capabilities;
6155
+ var capabilites = (_f = channel === null || channel === void 0 ? void 0 : channel.data) === null || _f === void 0 ? void 0 : _f.own_capabilities;
6144
6156
  if (capabilites) {
6145
6157
  _this.enabledMessageActions = capabilites;
6146
6158
  }
6147
- (_j = _this.newMessageSubscription) === null || _j === void 0 ? void 0 : _j.unsubscribe();
6159
+ (_g = _this.newMessageSubscription) === null || _g === void 0 ? void 0 : _g.unsubscribe();
6148
6160
  if (channel) {
6149
6161
  _this.newMessageSubscription = channel.on('message.new', function (event) {
6150
6162
  // If we display main channel messages and we're switched to an older message set -> use message.new event to update unread count and detect new messages sent by current user