stream-chat 8.40.7 → 8.40.8
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/dist/browser.es.js +59 -47
- package/dist/browser.es.js.map +1 -1
- package/dist/browser.full-bundle.min.js +1 -1
- package/dist/browser.full-bundle.min.js.map +1 -1
- package/dist/browser.js +59 -47
- package/dist/browser.js.map +1 -1
- package/dist/index.es.js +59 -47
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +59 -47
- package/dist/index.js.map +1 -1
- package/dist/types/thread.d.ts +4 -2
- package/dist/types/thread.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/thread.ts +32 -20
package/dist/index.js
CHANGED
|
@@ -7370,7 +7370,6 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7370
7370
|
function Thread(_ref) {
|
|
7371
7371
|
var _this = this,
|
|
7372
7372
|
_threadData$channel$m,
|
|
7373
|
-
_threadData$read,
|
|
7374
7373
|
_threadData$reply_cou;
|
|
7375
7374
|
|
|
7376
7375
|
var client = _ref.client,
|
|
@@ -7498,7 +7497,7 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7498
7497
|
|
|
7499
7498
|
_this.unsubscribeFunctions.add(_this.subscribeRepliesRead());
|
|
7500
7499
|
|
|
7501
|
-
_this.unsubscribeFunctions.add(_this.
|
|
7500
|
+
_this.unsubscribeFunctions.add(_this.subscribeMessageDeleted());
|
|
7502
7501
|
|
|
7503
7502
|
_this.unsubscribeFunctions.add(_this.subscribeMessageUpdated());
|
|
7504
7503
|
});
|
|
@@ -7630,19 +7629,26 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7630
7629
|
}).unsubscribe;
|
|
7631
7630
|
});
|
|
7632
7631
|
|
|
7633
|
-
_defineProperty__default['default'](this, "
|
|
7632
|
+
_defineProperty__default['default'](this, "subscribeMessageDeleted", function () {
|
|
7634
7633
|
return _this.client.on('message.deleted', function (event) {
|
|
7635
|
-
|
|
7634
|
+
if (!event.message) return; // Deleted message is a reply of this thread
|
|
7636
7635
|
|
|
7637
|
-
if (
|
|
7636
|
+
if (event.message.parent_id === _this.id) {
|
|
7637
|
+
if (event.hard_delete) {
|
|
7638
|
+
_this.deleteReplyLocally({
|
|
7639
|
+
message: event.message
|
|
7640
|
+
});
|
|
7641
|
+
} else {
|
|
7642
|
+
// Handle soft delete (updates deleted_at timestamp)
|
|
7643
|
+
_this.upsertReplyLocally({
|
|
7644
|
+
message: event.message
|
|
7645
|
+
});
|
|
7646
|
+
}
|
|
7647
|
+
} // Deleted message is parent message of this thread
|
|
7638
7648
|
|
|
7639
|
-
|
|
7640
|
-
|
|
7641
|
-
|
|
7642
|
-
});
|
|
7643
|
-
} else {
|
|
7644
|
-
// Handle soft delete (updates deleted_at timestamp)
|
|
7645
|
-
_this.upsertReplyLocally({
|
|
7649
|
+
|
|
7650
|
+
if (event.message.id === _this.id) {
|
|
7651
|
+
_this.updateParentMessageLocally({
|
|
7646
7652
|
message: event.message
|
|
7647
7653
|
});
|
|
7648
7654
|
}
|
|
@@ -7650,7 +7656,8 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7650
7656
|
});
|
|
7651
7657
|
|
|
7652
7658
|
_defineProperty__default['default'](this, "subscribeMessageUpdated", function () {
|
|
7653
|
-
var
|
|
7659
|
+
var eventTypes = ['message.updated', 'reaction.new', 'reaction.deleted', 'reaction.updated'];
|
|
7660
|
+
var unsubscribeFunctions = eventTypes.map(function (eventType) {
|
|
7654
7661
|
return _this.client.on(eventType, function (event) {
|
|
7655
7662
|
if (event.message) {
|
|
7656
7663
|
_this.updateParentMessageOrReplyLocally(event.message);
|
|
@@ -7728,7 +7735,9 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7728
7735
|
});
|
|
7729
7736
|
});
|
|
7730
7737
|
|
|
7731
|
-
_defineProperty__default['default'](this, "updateParentMessageLocally", function (
|
|
7738
|
+
_defineProperty__default['default'](this, "updateParentMessageLocally", function (_ref9) {
|
|
7739
|
+
var message = _ref9.message;
|
|
7740
|
+
|
|
7732
7741
|
if (message.id !== _this.id) {
|
|
7733
7742
|
throw new Error('Message does not belong to this thread');
|
|
7734
7743
|
}
|
|
@@ -7737,19 +7746,11 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7737
7746
|
var _message$reply_count;
|
|
7738
7747
|
|
|
7739
7748
|
var formattedMessage = formatMessage(message);
|
|
7740
|
-
|
|
7741
|
-
var newData = _objectSpread$3(_objectSpread$3({}, current), {}, {
|
|
7749
|
+
return _objectSpread$3(_objectSpread$3({}, current), {}, {
|
|
7742
7750
|
deletedAt: formattedMessage.deleted_at,
|
|
7743
7751
|
parentMessage: formattedMessage,
|
|
7744
7752
|
replyCount: (_message$reply_count = message.reply_count) !== null && _message$reply_count !== void 0 ? _message$reply_count : current.replyCount
|
|
7745
|
-
});
|
|
7746
|
-
|
|
7747
|
-
|
|
7748
|
-
if (message.channel) {
|
|
7749
|
-
newData['channel'] = _this.client.channel(message.channel.type, message.channel.id, message.channel);
|
|
7750
|
-
}
|
|
7751
|
-
|
|
7752
|
-
return newData;
|
|
7753
|
+
});
|
|
7753
7754
|
});
|
|
7754
7755
|
});
|
|
7755
7756
|
|
|
@@ -7761,13 +7762,15 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7761
7762
|
}
|
|
7762
7763
|
|
|
7763
7764
|
if (!message.parent_id && message.id === _this.id) {
|
|
7764
|
-
_this.updateParentMessageLocally(
|
|
7765
|
+
_this.updateParentMessageLocally({
|
|
7766
|
+
message: message
|
|
7767
|
+
});
|
|
7765
7768
|
}
|
|
7766
7769
|
});
|
|
7767
7770
|
|
|
7768
7771
|
_defineProperty__default['default'](this, "markAsRead", /*#__PURE__*/_asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee2() {
|
|
7769
|
-
var
|
|
7770
|
-
|
|
7772
|
+
var _ref11,
|
|
7773
|
+
_ref11$force,
|
|
7771
7774
|
force,
|
|
7772
7775
|
_args2 = arguments;
|
|
7773
7776
|
|
|
@@ -7775,7 +7778,7 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7775
7778
|
while (1) {
|
|
7776
7779
|
switch (_context2.prev = _context2.next) {
|
|
7777
7780
|
case 0:
|
|
7778
|
-
|
|
7781
|
+
_ref11 = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {}, _ref11$force = _ref11.force, force = _ref11$force === void 0 ? false : _ref11$force;
|
|
7779
7782
|
|
|
7780
7783
|
if (!(_this.ownUnreadCount === 0 && !force)) {
|
|
7781
7784
|
_context2.next = 3;
|
|
@@ -7808,13 +7811,13 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7808
7811
|
}));
|
|
7809
7812
|
|
|
7810
7813
|
_defineProperty__default['default'](this, "queryReplies", function () {
|
|
7811
|
-
var
|
|
7814
|
+
var _ref12 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
7812
7815
|
|
|
7813
|
-
var
|
|
7814
|
-
limit =
|
|
7815
|
-
|
|
7816
|
-
sort =
|
|
7817
|
-
otherOptions = _objectWithoutProperties__default['default'](
|
|
7816
|
+
var _ref12$limit = _ref12.limit,
|
|
7817
|
+
limit = _ref12$limit === void 0 ? DEFAULT_PAGE_LIMIT : _ref12$limit,
|
|
7818
|
+
_ref12$sort = _ref12.sort,
|
|
7819
|
+
sort = _ref12$sort === void 0 ? DEFAULT_SORT : _ref12$sort,
|
|
7820
|
+
otherOptions = _objectWithoutProperties__default['default'](_ref12, _excluded$1);
|
|
7818
7821
|
|
|
7819
7822
|
return _this.channel.getReplies(_this.id, _objectSpread$3({
|
|
7820
7823
|
limit: limit
|
|
@@ -7822,31 +7825,31 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7822
7825
|
});
|
|
7823
7826
|
|
|
7824
7827
|
_defineProperty__default['default'](this, "loadNextPage", function () {
|
|
7825
|
-
var
|
|
7826
|
-
|
|
7827
|
-
limit =
|
|
7828
|
+
var _ref13 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
7829
|
+
_ref13$limit = _ref13.limit,
|
|
7830
|
+
limit = _ref13$limit === void 0 ? DEFAULT_PAGE_LIMIT : _ref13$limit;
|
|
7828
7831
|
|
|
7829
7832
|
return _this.loadPage(limit);
|
|
7830
7833
|
});
|
|
7831
7834
|
|
|
7832
7835
|
_defineProperty__default['default'](this, "loadPrevPage", function () {
|
|
7833
|
-
var
|
|
7834
|
-
|
|
7835
|
-
limit =
|
|
7836
|
+
var _ref14 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
7837
|
+
_ref14$limit = _ref14.limit,
|
|
7838
|
+
limit = _ref14$limit === void 0 ? DEFAULT_PAGE_LIMIT : _ref14$limit;
|
|
7836
7839
|
|
|
7837
7840
|
return _this.loadPage(-limit);
|
|
7838
7841
|
});
|
|
7839
7842
|
|
|
7840
7843
|
_defineProperty__default['default'](this, "loadPage", /*#__PURE__*/function () {
|
|
7841
|
-
var
|
|
7842
|
-
var _this$state$getLatest4, pagination,
|
|
7844
|
+
var _ref15 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee3(count) {
|
|
7845
|
+
var _this$state$getLatest4, pagination, _ref16, _ref17, loadingKey, cursorKey, insertionMethodKey, queryOptions, limit, _replies$at$id, _replies$at, data, replies, maybeNextCursor;
|
|
7843
7846
|
|
|
7844
7847
|
return _regeneratorRuntime__default['default'].wrap(function _callee3$(_context3) {
|
|
7845
7848
|
while (1) {
|
|
7846
7849
|
switch (_context3.prev = _context3.next) {
|
|
7847
7850
|
case 0:
|
|
7848
7851
|
_this$state$getLatest4 = _this.state.getLatestValue(), pagination = _this$state$getLatest4.pagination;
|
|
7849
|
-
|
|
7852
|
+
_ref16 = count > 0 ? ['isLoadingNext', 'nextCursor', 'push'] : ['isLoadingPrev', 'prevCursor', 'unshift'], _ref17 = _slicedToArray__default['default'](_ref16, 3), loadingKey = _ref17[0], cursorKey = _ref17[1], insertionMethodKey = _ref17[2];
|
|
7850
7853
|
|
|
7851
7854
|
if (!(pagination[loadingKey] || pagination[cursorKey] === null)) {
|
|
7852
7855
|
_context3.next = 4;
|
|
@@ -7917,7 +7920,7 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7917
7920
|
}));
|
|
7918
7921
|
|
|
7919
7922
|
return function (_x) {
|
|
7920
|
-
return
|
|
7923
|
+
return _ref15.apply(this, arguments);
|
|
7921
7924
|
};
|
|
7922
7925
|
}());
|
|
7923
7926
|
|
|
@@ -7925,8 +7928,17 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7925
7928
|
name: threadData.channel.name
|
|
7926
7929
|
});
|
|
7927
7930
|
|
|
7928
|
-
_channel._hydrateMembers((_threadData$channel$m = threadData.channel.members) !== null && _threadData$channel$m !== void 0 ? _threadData$channel$m : []);
|
|
7931
|
+
_channel._hydrateMembers((_threadData$channel$m = threadData.channel.members) !== null && _threadData$channel$m !== void 0 ? _threadData$channel$m : []); // For when read object is undefined and due to that unreadMessageCount for
|
|
7932
|
+
// the current user isn't being incremented on message.new
|
|
7933
|
+
|
|
7929
7934
|
|
|
7935
|
+
var placeholderReadResponse = client.userID ? [{
|
|
7936
|
+
user: {
|
|
7937
|
+
id: client.userID
|
|
7938
|
+
},
|
|
7939
|
+
unread_messages: 0,
|
|
7940
|
+
last_read: new Date().toISOString()
|
|
7941
|
+
}] : [];
|
|
7930
7942
|
this.state = new StateStore({
|
|
7931
7943
|
active: false,
|
|
7932
7944
|
channel: _channel,
|
|
@@ -7937,7 +7949,7 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7937
7949
|
pagination: repliesPaginationFromInitialThread(threadData),
|
|
7938
7950
|
parentMessage: formatMessage(threadData.parent_message),
|
|
7939
7951
|
participants: threadData.thread_participants,
|
|
7940
|
-
read: formatReadState(
|
|
7952
|
+
read: formatReadState(!threadData.read || threadData.read.length === 0 ? placeholderReadResponse : threadData.read),
|
|
7941
7953
|
replies: threadData.latest_replies.map(formatMessage),
|
|
7942
7954
|
replyCount: (_threadData$reply_cou = threadData.reply_count) !== null && _threadData$reply_cou !== void 0 ? _threadData$reply_cou : 0,
|
|
7943
7955
|
updatedAt: threadData.updated_at ? new Date(threadData.updated_at) : null
|
|
@@ -13361,7 +13373,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
13361
13373
|
}, {
|
|
13362
13374
|
key: "getUserAgent",
|
|
13363
13375
|
value: function getUserAgent() {
|
|
13364
|
-
return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "8.40.
|
|
13376
|
+
return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "8.40.8");
|
|
13365
13377
|
}
|
|
13366
13378
|
}, {
|
|
13367
13379
|
key: "setUserAgent",
|