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/browser.es.js
CHANGED
|
@@ -7339,7 +7339,6 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7339
7339
|
function Thread(_ref) {
|
|
7340
7340
|
var _this = this,
|
|
7341
7341
|
_threadData$channel$m,
|
|
7342
|
-
_threadData$read,
|
|
7343
7342
|
_threadData$reply_cou;
|
|
7344
7343
|
|
|
7345
7344
|
var client = _ref.client,
|
|
@@ -7467,7 +7466,7 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7467
7466
|
|
|
7468
7467
|
_this.unsubscribeFunctions.add(_this.subscribeRepliesRead());
|
|
7469
7468
|
|
|
7470
|
-
_this.unsubscribeFunctions.add(_this.
|
|
7469
|
+
_this.unsubscribeFunctions.add(_this.subscribeMessageDeleted());
|
|
7471
7470
|
|
|
7472
7471
|
_this.unsubscribeFunctions.add(_this.subscribeMessageUpdated());
|
|
7473
7472
|
});
|
|
@@ -7599,19 +7598,26 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7599
7598
|
}).unsubscribe;
|
|
7600
7599
|
});
|
|
7601
7600
|
|
|
7602
|
-
_defineProperty(this, "
|
|
7601
|
+
_defineProperty(this, "subscribeMessageDeleted", function () {
|
|
7603
7602
|
return _this.client.on('message.deleted', function (event) {
|
|
7604
|
-
|
|
7603
|
+
if (!event.message) return; // Deleted message is a reply of this thread
|
|
7605
7604
|
|
|
7606
|
-
if (
|
|
7605
|
+
if (event.message.parent_id === _this.id) {
|
|
7606
|
+
if (event.hard_delete) {
|
|
7607
|
+
_this.deleteReplyLocally({
|
|
7608
|
+
message: event.message
|
|
7609
|
+
});
|
|
7610
|
+
} else {
|
|
7611
|
+
// Handle soft delete (updates deleted_at timestamp)
|
|
7612
|
+
_this.upsertReplyLocally({
|
|
7613
|
+
message: event.message
|
|
7614
|
+
});
|
|
7615
|
+
}
|
|
7616
|
+
} // Deleted message is parent message of this thread
|
|
7607
7617
|
|
|
7608
|
-
|
|
7609
|
-
|
|
7610
|
-
|
|
7611
|
-
});
|
|
7612
|
-
} else {
|
|
7613
|
-
// Handle soft delete (updates deleted_at timestamp)
|
|
7614
|
-
_this.upsertReplyLocally({
|
|
7618
|
+
|
|
7619
|
+
if (event.message.id === _this.id) {
|
|
7620
|
+
_this.updateParentMessageLocally({
|
|
7615
7621
|
message: event.message
|
|
7616
7622
|
});
|
|
7617
7623
|
}
|
|
@@ -7619,7 +7625,8 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7619
7625
|
});
|
|
7620
7626
|
|
|
7621
7627
|
_defineProperty(this, "subscribeMessageUpdated", function () {
|
|
7622
|
-
var
|
|
7628
|
+
var eventTypes = ['message.updated', 'reaction.new', 'reaction.deleted', 'reaction.updated'];
|
|
7629
|
+
var unsubscribeFunctions = eventTypes.map(function (eventType) {
|
|
7623
7630
|
return _this.client.on(eventType, function (event) {
|
|
7624
7631
|
if (event.message) {
|
|
7625
7632
|
_this.updateParentMessageOrReplyLocally(event.message);
|
|
@@ -7697,7 +7704,9 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7697
7704
|
});
|
|
7698
7705
|
});
|
|
7699
7706
|
|
|
7700
|
-
_defineProperty(this, "updateParentMessageLocally", function (
|
|
7707
|
+
_defineProperty(this, "updateParentMessageLocally", function (_ref9) {
|
|
7708
|
+
var message = _ref9.message;
|
|
7709
|
+
|
|
7701
7710
|
if (message.id !== _this.id) {
|
|
7702
7711
|
throw new Error('Message does not belong to this thread');
|
|
7703
7712
|
}
|
|
@@ -7706,19 +7715,11 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7706
7715
|
var _message$reply_count;
|
|
7707
7716
|
|
|
7708
7717
|
var formattedMessage = formatMessage(message);
|
|
7709
|
-
|
|
7710
|
-
var newData = _objectSpread$3(_objectSpread$3({}, current), {}, {
|
|
7718
|
+
return _objectSpread$3(_objectSpread$3({}, current), {}, {
|
|
7711
7719
|
deletedAt: formattedMessage.deleted_at,
|
|
7712
7720
|
parentMessage: formattedMessage,
|
|
7713
7721
|
replyCount: (_message$reply_count = message.reply_count) !== null && _message$reply_count !== void 0 ? _message$reply_count : current.replyCount
|
|
7714
|
-
});
|
|
7715
|
-
|
|
7716
|
-
|
|
7717
|
-
if (message.channel) {
|
|
7718
|
-
newData['channel'] = _this.client.channel(message.channel.type, message.channel.id, message.channel);
|
|
7719
|
-
}
|
|
7720
|
-
|
|
7721
|
-
return newData;
|
|
7722
|
+
});
|
|
7722
7723
|
});
|
|
7723
7724
|
});
|
|
7724
7725
|
|
|
@@ -7730,13 +7731,15 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7730
7731
|
}
|
|
7731
7732
|
|
|
7732
7733
|
if (!message.parent_id && message.id === _this.id) {
|
|
7733
|
-
_this.updateParentMessageLocally(
|
|
7734
|
+
_this.updateParentMessageLocally({
|
|
7735
|
+
message: message
|
|
7736
|
+
});
|
|
7734
7737
|
}
|
|
7735
7738
|
});
|
|
7736
7739
|
|
|
7737
7740
|
_defineProperty(this, "markAsRead", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
7738
|
-
var
|
|
7739
|
-
|
|
7741
|
+
var _ref11,
|
|
7742
|
+
_ref11$force,
|
|
7740
7743
|
force,
|
|
7741
7744
|
_args2 = arguments;
|
|
7742
7745
|
|
|
@@ -7744,7 +7747,7 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7744
7747
|
while (1) {
|
|
7745
7748
|
switch (_context2.prev = _context2.next) {
|
|
7746
7749
|
case 0:
|
|
7747
|
-
|
|
7750
|
+
_ref11 = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {}, _ref11$force = _ref11.force, force = _ref11$force === void 0 ? false : _ref11$force;
|
|
7748
7751
|
|
|
7749
7752
|
if (!(_this.ownUnreadCount === 0 && !force)) {
|
|
7750
7753
|
_context2.next = 3;
|
|
@@ -7777,13 +7780,13 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7777
7780
|
}));
|
|
7778
7781
|
|
|
7779
7782
|
_defineProperty(this, "queryReplies", function () {
|
|
7780
|
-
var
|
|
7783
|
+
var _ref12 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
7781
7784
|
|
|
7782
|
-
var
|
|
7783
|
-
limit =
|
|
7784
|
-
|
|
7785
|
-
sort =
|
|
7786
|
-
otherOptions = _objectWithoutProperties(
|
|
7785
|
+
var _ref12$limit = _ref12.limit,
|
|
7786
|
+
limit = _ref12$limit === void 0 ? DEFAULT_PAGE_LIMIT : _ref12$limit,
|
|
7787
|
+
_ref12$sort = _ref12.sort,
|
|
7788
|
+
sort = _ref12$sort === void 0 ? DEFAULT_SORT : _ref12$sort,
|
|
7789
|
+
otherOptions = _objectWithoutProperties(_ref12, _excluded$1);
|
|
7787
7790
|
|
|
7788
7791
|
return _this.channel.getReplies(_this.id, _objectSpread$3({
|
|
7789
7792
|
limit: limit
|
|
@@ -7791,31 +7794,31 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7791
7794
|
});
|
|
7792
7795
|
|
|
7793
7796
|
_defineProperty(this, "loadNextPage", function () {
|
|
7794
|
-
var
|
|
7795
|
-
|
|
7796
|
-
limit =
|
|
7797
|
+
var _ref13 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
7798
|
+
_ref13$limit = _ref13.limit,
|
|
7799
|
+
limit = _ref13$limit === void 0 ? DEFAULT_PAGE_LIMIT : _ref13$limit;
|
|
7797
7800
|
|
|
7798
7801
|
return _this.loadPage(limit);
|
|
7799
7802
|
});
|
|
7800
7803
|
|
|
7801
7804
|
_defineProperty(this, "loadPrevPage", function () {
|
|
7802
|
-
var
|
|
7803
|
-
|
|
7804
|
-
limit =
|
|
7805
|
+
var _ref14 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
7806
|
+
_ref14$limit = _ref14.limit,
|
|
7807
|
+
limit = _ref14$limit === void 0 ? DEFAULT_PAGE_LIMIT : _ref14$limit;
|
|
7805
7808
|
|
|
7806
7809
|
return _this.loadPage(-limit);
|
|
7807
7810
|
});
|
|
7808
7811
|
|
|
7809
7812
|
_defineProperty(this, "loadPage", /*#__PURE__*/function () {
|
|
7810
|
-
var
|
|
7811
|
-
var _this$state$getLatest4, pagination,
|
|
7813
|
+
var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(count) {
|
|
7814
|
+
var _this$state$getLatest4, pagination, _ref16, _ref17, loadingKey, cursorKey, insertionMethodKey, queryOptions, limit, _replies$at$id, _replies$at, data, replies, maybeNextCursor;
|
|
7812
7815
|
|
|
7813
7816
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
7814
7817
|
while (1) {
|
|
7815
7818
|
switch (_context3.prev = _context3.next) {
|
|
7816
7819
|
case 0:
|
|
7817
7820
|
_this$state$getLatest4 = _this.state.getLatestValue(), pagination = _this$state$getLatest4.pagination;
|
|
7818
|
-
|
|
7821
|
+
_ref16 = count > 0 ? ['isLoadingNext', 'nextCursor', 'push'] : ['isLoadingPrev', 'prevCursor', 'unshift'], _ref17 = _slicedToArray(_ref16, 3), loadingKey = _ref17[0], cursorKey = _ref17[1], insertionMethodKey = _ref17[2];
|
|
7819
7822
|
|
|
7820
7823
|
if (!(pagination[loadingKey] || pagination[cursorKey] === null)) {
|
|
7821
7824
|
_context3.next = 4;
|
|
@@ -7886,7 +7889,7 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7886
7889
|
}));
|
|
7887
7890
|
|
|
7888
7891
|
return function (_x) {
|
|
7889
|
-
return
|
|
7892
|
+
return _ref15.apply(this, arguments);
|
|
7890
7893
|
};
|
|
7891
7894
|
}());
|
|
7892
7895
|
|
|
@@ -7894,8 +7897,17 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7894
7897
|
name: threadData.channel.name
|
|
7895
7898
|
});
|
|
7896
7899
|
|
|
7897
|
-
_channel._hydrateMembers((_threadData$channel$m = threadData.channel.members) !== null && _threadData$channel$m !== void 0 ? _threadData$channel$m : []);
|
|
7900
|
+
_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
|
|
7901
|
+
// the current user isn't being incremented on message.new
|
|
7902
|
+
|
|
7898
7903
|
|
|
7904
|
+
var placeholderReadResponse = client.userID ? [{
|
|
7905
|
+
user: {
|
|
7906
|
+
id: client.userID
|
|
7907
|
+
},
|
|
7908
|
+
unread_messages: 0,
|
|
7909
|
+
last_read: new Date().toISOString()
|
|
7910
|
+
}] : [];
|
|
7899
7911
|
this.state = new StateStore({
|
|
7900
7912
|
active: false,
|
|
7901
7913
|
channel: _channel,
|
|
@@ -7906,7 +7918,7 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7906
7918
|
pagination: repliesPaginationFromInitialThread(threadData),
|
|
7907
7919
|
parentMessage: formatMessage(threadData.parent_message),
|
|
7908
7920
|
participants: threadData.thread_participants,
|
|
7909
|
-
read: formatReadState(
|
|
7921
|
+
read: formatReadState(!threadData.read || threadData.read.length === 0 ? placeholderReadResponse : threadData.read),
|
|
7910
7922
|
replies: threadData.latest_replies.map(formatMessage),
|
|
7911
7923
|
replyCount: (_threadData$reply_cou = threadData.reply_count) !== null && _threadData$reply_cou !== void 0 ? _threadData$reply_cou : 0,
|
|
7912
7924
|
updatedAt: threadData.updated_at ? new Date(threadData.updated_at) : null
|
|
@@ -13330,7 +13342,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
13330
13342
|
}, {
|
|
13331
13343
|
key: "getUserAgent",
|
|
13332
13344
|
value: function getUserAgent() {
|
|
13333
|
-
return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "8.40.
|
|
13345
|
+
return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "8.40.8");
|
|
13334
13346
|
}
|
|
13335
13347
|
}, {
|
|
13336
13348
|
key: "setUserAgent",
|