stream-chat 8.40.7 → 8.40.9
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 +65 -54
- 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 +65 -54
- package/dist/browser.js.map +1 -1
- package/dist/index.es.js +65 -54
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +65 -54
- 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/dist/types/types.d.ts +12 -0
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/thread.ts +32 -20
- package/src/types.ts +12 -0
- package/src/utils.ts +9 -8
package/dist/browser.js
CHANGED
|
@@ -413,18 +413,17 @@ var findIndexInSortedArray = function findIndexInSortedArray(_ref) {
|
|
|
413
413
|
middle = Math.round((left + right) / 2);
|
|
414
414
|
};
|
|
415
415
|
|
|
416
|
-
var
|
|
417
|
-
recalculateMiddle();
|
|
416
|
+
var comparableNeedle = selectValueToCompare(needle);
|
|
418
417
|
|
|
419
418
|
while (left <= right) {
|
|
420
|
-
|
|
421
|
-
|
|
419
|
+
recalculateMiddle();
|
|
420
|
+
var comparableMiddle = selectValueToCompare(sortedArray[middle]); // if (comparableNeedle === comparableMiddle) return middle;
|
|
421
|
+
|
|
422
|
+
if (sortDirection === 'ascending' && comparableNeedle < comparableMiddle || sortDirection === 'descending' && comparableNeedle > comparableMiddle) {
|
|
422
423
|
right = middle - 1;
|
|
423
424
|
} else {
|
|
424
425
|
left = middle + 1;
|
|
425
426
|
}
|
|
426
|
-
|
|
427
|
-
recalculateMiddle();
|
|
428
427
|
}
|
|
429
428
|
|
|
430
429
|
return left;
|
|
@@ -466,7 +465,7 @@ function addToMessageList(messages, newMessage) {
|
|
|
466
465
|
|
|
467
466
|
var insertionIndex = findIndexInSortedArray({
|
|
468
467
|
needle: newMessage,
|
|
469
|
-
sortedArray:
|
|
468
|
+
sortedArray: newMessages,
|
|
470
469
|
sortDirection: 'ascending',
|
|
471
470
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
472
471
|
selectValueToCompare: function selectValueToCompare(m) {
|
|
@@ -7364,7 +7363,6 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7364
7363
|
function Thread(_ref) {
|
|
7365
7364
|
var _this = this,
|
|
7366
7365
|
_threadData$channel$m,
|
|
7367
|
-
_threadData$read,
|
|
7368
7366
|
_threadData$reply_cou;
|
|
7369
7367
|
|
|
7370
7368
|
var client = _ref.client,
|
|
@@ -7492,7 +7490,7 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7492
7490
|
|
|
7493
7491
|
_this.unsubscribeFunctions.add(_this.subscribeRepliesRead());
|
|
7494
7492
|
|
|
7495
|
-
_this.unsubscribeFunctions.add(_this.
|
|
7493
|
+
_this.unsubscribeFunctions.add(_this.subscribeMessageDeleted());
|
|
7496
7494
|
|
|
7497
7495
|
_this.unsubscribeFunctions.add(_this.subscribeMessageUpdated());
|
|
7498
7496
|
});
|
|
@@ -7624,19 +7622,26 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7624
7622
|
}).unsubscribe;
|
|
7625
7623
|
});
|
|
7626
7624
|
|
|
7627
|
-
_defineProperty__default['default'](this, "
|
|
7625
|
+
_defineProperty__default['default'](this, "subscribeMessageDeleted", function () {
|
|
7628
7626
|
return _this.client.on('message.deleted', function (event) {
|
|
7629
|
-
|
|
7627
|
+
if (!event.message) return; // Deleted message is a reply of this thread
|
|
7628
|
+
|
|
7629
|
+
if (event.message.parent_id === _this.id) {
|
|
7630
|
+
if (event.hard_delete) {
|
|
7631
|
+
_this.deleteReplyLocally({
|
|
7632
|
+
message: event.message
|
|
7633
|
+
});
|
|
7634
|
+
} else {
|
|
7635
|
+
// Handle soft delete (updates deleted_at timestamp)
|
|
7636
|
+
_this.upsertReplyLocally({
|
|
7637
|
+
message: event.message
|
|
7638
|
+
});
|
|
7639
|
+
}
|
|
7640
|
+
} // Deleted message is parent message of this thread
|
|
7630
7641
|
|
|
7631
|
-
if (((_event$message2 = event.message) === null || _event$message2 === void 0 ? void 0 : _event$message2.parent_id) !== _this.id) return;
|
|
7632
7642
|
|
|
7633
|
-
if (event.
|
|
7634
|
-
_this.
|
|
7635
|
-
message: event.message
|
|
7636
|
-
});
|
|
7637
|
-
} else {
|
|
7638
|
-
// Handle soft delete (updates deleted_at timestamp)
|
|
7639
|
-
_this.upsertReplyLocally({
|
|
7643
|
+
if (event.message.id === _this.id) {
|
|
7644
|
+
_this.updateParentMessageLocally({
|
|
7640
7645
|
message: event.message
|
|
7641
7646
|
});
|
|
7642
7647
|
}
|
|
@@ -7644,7 +7649,8 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7644
7649
|
});
|
|
7645
7650
|
|
|
7646
7651
|
_defineProperty__default['default'](this, "subscribeMessageUpdated", function () {
|
|
7647
|
-
var
|
|
7652
|
+
var eventTypes = ['message.updated', 'reaction.new', 'reaction.deleted', 'reaction.updated'];
|
|
7653
|
+
var unsubscribeFunctions = eventTypes.map(function (eventType) {
|
|
7648
7654
|
return _this.client.on(eventType, function (event) {
|
|
7649
7655
|
if (event.message) {
|
|
7650
7656
|
_this.updateParentMessageOrReplyLocally(event.message);
|
|
@@ -7722,7 +7728,9 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7722
7728
|
});
|
|
7723
7729
|
});
|
|
7724
7730
|
|
|
7725
|
-
_defineProperty__default['default'](this, "updateParentMessageLocally", function (
|
|
7731
|
+
_defineProperty__default['default'](this, "updateParentMessageLocally", function (_ref9) {
|
|
7732
|
+
var message = _ref9.message;
|
|
7733
|
+
|
|
7726
7734
|
if (message.id !== _this.id) {
|
|
7727
7735
|
throw new Error('Message does not belong to this thread');
|
|
7728
7736
|
}
|
|
@@ -7731,19 +7739,11 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7731
7739
|
var _message$reply_count;
|
|
7732
7740
|
|
|
7733
7741
|
var formattedMessage = formatMessage(message);
|
|
7734
|
-
|
|
7735
|
-
var newData = _objectSpread$3(_objectSpread$3({}, current), {}, {
|
|
7742
|
+
return _objectSpread$3(_objectSpread$3({}, current), {}, {
|
|
7736
7743
|
deletedAt: formattedMessage.deleted_at,
|
|
7737
7744
|
parentMessage: formattedMessage,
|
|
7738
7745
|
replyCount: (_message$reply_count = message.reply_count) !== null && _message$reply_count !== void 0 ? _message$reply_count : current.replyCount
|
|
7739
|
-
});
|
|
7740
|
-
|
|
7741
|
-
|
|
7742
|
-
if (message.channel) {
|
|
7743
|
-
newData['channel'] = _this.client.channel(message.channel.type, message.channel.id, message.channel);
|
|
7744
|
-
}
|
|
7745
|
-
|
|
7746
|
-
return newData;
|
|
7746
|
+
});
|
|
7747
7747
|
});
|
|
7748
7748
|
});
|
|
7749
7749
|
|
|
@@ -7755,13 +7755,15 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7755
7755
|
}
|
|
7756
7756
|
|
|
7757
7757
|
if (!message.parent_id && message.id === _this.id) {
|
|
7758
|
-
_this.updateParentMessageLocally(
|
|
7758
|
+
_this.updateParentMessageLocally({
|
|
7759
|
+
message: message
|
|
7760
|
+
});
|
|
7759
7761
|
}
|
|
7760
7762
|
});
|
|
7761
7763
|
|
|
7762
7764
|
_defineProperty__default['default'](this, "markAsRead", /*#__PURE__*/_asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee2() {
|
|
7763
|
-
var
|
|
7764
|
-
|
|
7765
|
+
var _ref11,
|
|
7766
|
+
_ref11$force,
|
|
7765
7767
|
force,
|
|
7766
7768
|
_args2 = arguments;
|
|
7767
7769
|
|
|
@@ -7769,7 +7771,7 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7769
7771
|
while (1) {
|
|
7770
7772
|
switch (_context2.prev = _context2.next) {
|
|
7771
7773
|
case 0:
|
|
7772
|
-
|
|
7774
|
+
_ref11 = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {}, _ref11$force = _ref11.force, force = _ref11$force === void 0 ? false : _ref11$force;
|
|
7773
7775
|
|
|
7774
7776
|
if (!(_this.ownUnreadCount === 0 && !force)) {
|
|
7775
7777
|
_context2.next = 3;
|
|
@@ -7802,13 +7804,13 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7802
7804
|
}));
|
|
7803
7805
|
|
|
7804
7806
|
_defineProperty__default['default'](this, "queryReplies", function () {
|
|
7805
|
-
var
|
|
7807
|
+
var _ref12 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
7806
7808
|
|
|
7807
|
-
var
|
|
7808
|
-
limit =
|
|
7809
|
-
|
|
7810
|
-
sort =
|
|
7811
|
-
otherOptions = _objectWithoutProperties__default['default'](
|
|
7809
|
+
var _ref12$limit = _ref12.limit,
|
|
7810
|
+
limit = _ref12$limit === void 0 ? DEFAULT_PAGE_LIMIT : _ref12$limit,
|
|
7811
|
+
_ref12$sort = _ref12.sort,
|
|
7812
|
+
sort = _ref12$sort === void 0 ? DEFAULT_SORT : _ref12$sort,
|
|
7813
|
+
otherOptions = _objectWithoutProperties__default['default'](_ref12, _excluded$1);
|
|
7812
7814
|
|
|
7813
7815
|
return _this.channel.getReplies(_this.id, _objectSpread$3({
|
|
7814
7816
|
limit: limit
|
|
@@ -7816,31 +7818,31 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7816
7818
|
});
|
|
7817
7819
|
|
|
7818
7820
|
_defineProperty__default['default'](this, "loadNextPage", function () {
|
|
7819
|
-
var
|
|
7820
|
-
|
|
7821
|
-
limit =
|
|
7821
|
+
var _ref13 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
7822
|
+
_ref13$limit = _ref13.limit,
|
|
7823
|
+
limit = _ref13$limit === void 0 ? DEFAULT_PAGE_LIMIT : _ref13$limit;
|
|
7822
7824
|
|
|
7823
7825
|
return _this.loadPage(limit);
|
|
7824
7826
|
});
|
|
7825
7827
|
|
|
7826
7828
|
_defineProperty__default['default'](this, "loadPrevPage", function () {
|
|
7827
|
-
var
|
|
7828
|
-
|
|
7829
|
-
limit =
|
|
7829
|
+
var _ref14 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
7830
|
+
_ref14$limit = _ref14.limit,
|
|
7831
|
+
limit = _ref14$limit === void 0 ? DEFAULT_PAGE_LIMIT : _ref14$limit;
|
|
7830
7832
|
|
|
7831
7833
|
return _this.loadPage(-limit);
|
|
7832
7834
|
});
|
|
7833
7835
|
|
|
7834
7836
|
_defineProperty__default['default'](this, "loadPage", /*#__PURE__*/function () {
|
|
7835
|
-
var
|
|
7836
|
-
var _this$state$getLatest4, pagination,
|
|
7837
|
+
var _ref15 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee3(count) {
|
|
7838
|
+
var _this$state$getLatest4, pagination, _ref16, _ref17, loadingKey, cursorKey, insertionMethodKey, queryOptions, limit, _replies$at$id, _replies$at, data, replies, maybeNextCursor;
|
|
7837
7839
|
|
|
7838
7840
|
return _regeneratorRuntime__default['default'].wrap(function _callee3$(_context3) {
|
|
7839
7841
|
while (1) {
|
|
7840
7842
|
switch (_context3.prev = _context3.next) {
|
|
7841
7843
|
case 0:
|
|
7842
7844
|
_this$state$getLatest4 = _this.state.getLatestValue(), pagination = _this$state$getLatest4.pagination;
|
|
7843
|
-
|
|
7845
|
+
_ref16 = count > 0 ? ['isLoadingNext', 'nextCursor', 'push'] : ['isLoadingPrev', 'prevCursor', 'unshift'], _ref17 = _slicedToArray__default['default'](_ref16, 3), loadingKey = _ref17[0], cursorKey = _ref17[1], insertionMethodKey = _ref17[2];
|
|
7844
7846
|
|
|
7845
7847
|
if (!(pagination[loadingKey] || pagination[cursorKey] === null)) {
|
|
7846
7848
|
_context3.next = 4;
|
|
@@ -7911,7 +7913,7 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7911
7913
|
}));
|
|
7912
7914
|
|
|
7913
7915
|
return function (_x) {
|
|
7914
|
-
return
|
|
7916
|
+
return _ref15.apply(this, arguments);
|
|
7915
7917
|
};
|
|
7916
7918
|
}());
|
|
7917
7919
|
|
|
@@ -7919,8 +7921,17 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7919
7921
|
name: threadData.channel.name
|
|
7920
7922
|
});
|
|
7921
7923
|
|
|
7922
|
-
_channel._hydrateMembers((_threadData$channel$m = threadData.channel.members) !== null && _threadData$channel$m !== void 0 ? _threadData$channel$m : []);
|
|
7924
|
+
_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
|
|
7925
|
+
// the current user isn't being incremented on message.new
|
|
7923
7926
|
|
|
7927
|
+
|
|
7928
|
+
var placeholderReadResponse = client.userID ? [{
|
|
7929
|
+
user: {
|
|
7930
|
+
id: client.userID
|
|
7931
|
+
},
|
|
7932
|
+
unread_messages: 0,
|
|
7933
|
+
last_read: new Date().toISOString()
|
|
7934
|
+
}] : [];
|
|
7924
7935
|
this.state = new StateStore({
|
|
7925
7936
|
active: false,
|
|
7926
7937
|
channel: _channel,
|
|
@@ -7931,7 +7942,7 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7931
7942
|
pagination: repliesPaginationFromInitialThread(threadData),
|
|
7932
7943
|
parentMessage: formatMessage(threadData.parent_message),
|
|
7933
7944
|
participants: threadData.thread_participants,
|
|
7934
|
-
read: formatReadState(
|
|
7945
|
+
read: formatReadState(!threadData.read || threadData.read.length === 0 ? placeholderReadResponse : threadData.read),
|
|
7935
7946
|
replies: threadData.latest_replies.map(formatMessage),
|
|
7936
7947
|
replyCount: (_threadData$reply_cou = threadData.reply_count) !== null && _threadData$reply_cou !== void 0 ? _threadData$reply_cou : 0,
|
|
7937
7948
|
updatedAt: threadData.updated_at ? new Date(threadData.updated_at) : null
|
|
@@ -13355,7 +13366,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
13355
13366
|
}, {
|
|
13356
13367
|
key: "getUserAgent",
|
|
13357
13368
|
value: function getUserAgent() {
|
|
13358
|
-
return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "8.40.
|
|
13369
|
+
return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "8.40.9");
|
|
13359
13370
|
}
|
|
13360
13371
|
}, {
|
|
13361
13372
|
key: "setUserAgent",
|