stream-chat 8.47.0 → 8.48.0
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 +112 -17
- 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 +112 -17
- package/dist/browser.js.map +1 -1
- package/dist/index.es.js +112 -17
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +112 -17
- package/dist/index.js.map +1 -1
- package/dist/types/channel.d.ts +2 -1
- package/dist/types/channel.d.ts.map +1 -1
- package/dist/types/client.d.ts +26 -2
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/moderation.d.ts +33 -1
- package/dist/types/moderation.d.ts.map +1 -1
- package/dist/types/thread.d.ts.map +1 -1
- package/dist/types/types.d.ts +10 -0
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils.d.ts +14 -3
- package/dist/types/utils.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/channel.ts +2 -0
- package/src/moderation.ts +47 -0
- package/src/thread.ts +3 -5
- package/src/types.ts +13 -0
- package/src/utils.ts +41 -15
package/dist/index.js
CHANGED
|
@@ -607,6 +607,7 @@ function formatMessage(message) {
|
|
|
607
607
|
var findIndexInSortedArray = function findIndexInSortedArray(_ref) {
|
|
608
608
|
var needle = _ref.needle,
|
|
609
609
|
sortedArray = _ref.sortedArray,
|
|
610
|
+
selectKey = _ref.selectKey,
|
|
610
611
|
_ref$selectValueToCom = _ref.selectValueToCompare,
|
|
611
612
|
selectValueToCompare = _ref$selectValueToCom === void 0 ? function (e) {
|
|
612
613
|
return e;
|
|
@@ -626,13 +627,27 @@ var findIndexInSortedArray = function findIndexInSortedArray(_ref) {
|
|
|
626
627
|
|
|
627
628
|
while (left <= right) {
|
|
628
629
|
recalculateMiddle();
|
|
629
|
-
var comparableMiddle = selectValueToCompare(sortedArray[middle]);
|
|
630
|
+
var comparableMiddle = selectValueToCompare(sortedArray[middle]);
|
|
630
631
|
|
|
631
|
-
if (sortDirection === 'ascending' && comparableNeedle < comparableMiddle || sortDirection === 'descending' && comparableNeedle
|
|
632
|
+
if (sortDirection === 'ascending' && comparableNeedle < comparableMiddle || sortDirection === 'descending' && comparableNeedle >= comparableMiddle) {
|
|
632
633
|
right = middle - 1;
|
|
633
634
|
} else {
|
|
634
635
|
left = middle + 1;
|
|
635
636
|
}
|
|
637
|
+
} // In case there are several array elements with the same comparable value, search around the insertion
|
|
638
|
+
// point to possibly find an element with the same key. If found, prefer it.
|
|
639
|
+
// This, for example, prevents duplication of messages with the same creation date.
|
|
640
|
+
|
|
641
|
+
|
|
642
|
+
if (selectKey) {
|
|
643
|
+
var needleKey = selectKey(needle);
|
|
644
|
+
var step = sortDirection === 'ascending' ? -1 : +1;
|
|
645
|
+
|
|
646
|
+
for (var i = left + step; 0 <= i && i < sortedArray.length && selectValueToCompare(sortedArray[i]) === comparableNeedle; i += step) {
|
|
647
|
+
if (selectKey(sortedArray[i]) === needleKey) {
|
|
648
|
+
return i;
|
|
649
|
+
}
|
|
650
|
+
}
|
|
636
651
|
}
|
|
637
652
|
|
|
638
653
|
return left;
|
|
@@ -679,19 +694,15 @@ function addToMessageList(messages, newMessage) {
|
|
|
679
694
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
680
695
|
selectValueToCompare: function selectValueToCompare(m) {
|
|
681
696
|
return m[sortBy].getTime();
|
|
697
|
+
},
|
|
698
|
+
selectKey: function selectKey(m) {
|
|
699
|
+
return m.id;
|
|
682
700
|
}
|
|
683
701
|
}); // message already exists and not filtered with timestampChanged, update and return
|
|
684
702
|
|
|
685
|
-
if (!timestampChanged && newMessage.id) {
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
return newMessages;
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
if (newMessages[insertionIndex - 1] && newMessage.id === newMessages[insertionIndex - 1].id) {
|
|
692
|
-
newMessages[insertionIndex - 1] = newMessage;
|
|
693
|
-
return newMessages;
|
|
694
|
-
}
|
|
703
|
+
if (!timestampChanged && newMessage.id && newMessages[insertionIndex] && newMessage.id === newMessages[insertionIndex].id) {
|
|
704
|
+
newMessages[insertionIndex] = newMessage;
|
|
705
|
+
return newMessages;
|
|
695
706
|
} // do not add updated or deleted messages to the list if they already exist or come with a timestamp change
|
|
696
707
|
|
|
697
708
|
|
|
@@ -7916,7 +7927,7 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7916
7927
|
});
|
|
7917
7928
|
|
|
7918
7929
|
_defineProperty__default['default'](this, "deleteReplyLocally", function (_ref5) {
|
|
7919
|
-
var _replies$index
|
|
7930
|
+
var _replies$index;
|
|
7920
7931
|
|
|
7921
7932
|
var message = _ref5.message;
|
|
7922
7933
|
|
|
@@ -7929,17 +7940,19 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7929
7940
|
sortDirection: 'ascending',
|
|
7930
7941
|
selectValueToCompare: function selectValueToCompare(reply) {
|
|
7931
7942
|
return reply.created_at.getTime();
|
|
7943
|
+
},
|
|
7944
|
+
selectKey: function selectKey(reply) {
|
|
7945
|
+
return reply.id;
|
|
7932
7946
|
}
|
|
7933
7947
|
});
|
|
7934
|
-
var actualIndex = ((_replies$index = replies[index]) === null || _replies$index === void 0 ? void 0 : _replies$index.id) === message.id ? index : ((_replies = replies[index - 1]) === null || _replies === void 0 ? void 0 : _replies.id) === message.id ? index - 1 : null;
|
|
7935
7948
|
|
|
7936
|
-
if (
|
|
7949
|
+
if (((_replies$index = replies[index]) === null || _replies$index === void 0 ? void 0 : _replies$index.id) !== message.id) {
|
|
7937
7950
|
return;
|
|
7938
7951
|
}
|
|
7939
7952
|
|
|
7940
7953
|
var updatedReplies = _toConsumableArray__default['default'](replies);
|
|
7941
7954
|
|
|
7942
|
-
updatedReplies.splice(
|
|
7955
|
+
updatedReplies.splice(index, 1);
|
|
7943
7956
|
|
|
7944
7957
|
_this.state.partialNext({
|
|
7945
7958
|
replies: updatedReplies
|
|
@@ -8782,6 +8795,88 @@ var Moderation = /*#__PURE__*/function () {
|
|
|
8782
8795
|
|
|
8783
8796
|
return check;
|
|
8784
8797
|
}()
|
|
8798
|
+
/**
|
|
8799
|
+
*
|
|
8800
|
+
* @param {string} entityType string Type of entity to be checked E.g., stream:user, stream:chat:v1:message, or any custom string
|
|
8801
|
+
* @param {string} entityID string ID of the entity to be checked. This is mainly for tracking purposes
|
|
8802
|
+
* @param {string} entityCreatorID string ID of the entity creator
|
|
8803
|
+
* @param {object} moderationPayload object Content to be checked for moderation. E.g., { texts: ['text1', 'text2'], images: ['image1', 'image2']}
|
|
8804
|
+
* @param {Array} moderationPayload.texts array Array of texts to be checked for moderation
|
|
8805
|
+
* @param {Array} moderationPayload.images array Array of images to be checked for moderation
|
|
8806
|
+
* @param {Array} moderationPayload.videos array Array of videos to be checked for moderation
|
|
8807
|
+
* @param {Array<CustomCheckFlag>} flags Array of CustomCheckFlag to be passed to flag the entity
|
|
8808
|
+
* @returns
|
|
8809
|
+
*/
|
|
8810
|
+
|
|
8811
|
+
}, {
|
|
8812
|
+
key: "addCustomFlags",
|
|
8813
|
+
value: function () {
|
|
8814
|
+
var _addCustomFlags = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee14(entityType, entityID, entityCreatorID, moderationPayload, flags) {
|
|
8815
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee14$(_context14) {
|
|
8816
|
+
while (1) {
|
|
8817
|
+
switch (_context14.prev = _context14.next) {
|
|
8818
|
+
case 0:
|
|
8819
|
+
_context14.next = 2;
|
|
8820
|
+
return this.client.post(this.client.baseURL + "/api/v2/moderation/custom_check", {
|
|
8821
|
+
entity_type: entityType,
|
|
8822
|
+
entity_id: entityID,
|
|
8823
|
+
entity_creator_id: entityCreatorID,
|
|
8824
|
+
moderation_payload: moderationPayload,
|
|
8825
|
+
flags: flags
|
|
8826
|
+
});
|
|
8827
|
+
|
|
8828
|
+
case 2:
|
|
8829
|
+
return _context14.abrupt("return", _context14.sent);
|
|
8830
|
+
|
|
8831
|
+
case 3:
|
|
8832
|
+
case "end":
|
|
8833
|
+
return _context14.stop();
|
|
8834
|
+
}
|
|
8835
|
+
}
|
|
8836
|
+
}, _callee14, this);
|
|
8837
|
+
}));
|
|
8838
|
+
|
|
8839
|
+
function addCustomFlags(_x25, _x26, _x27, _x28, _x29) {
|
|
8840
|
+
return _addCustomFlags.apply(this, arguments);
|
|
8841
|
+
}
|
|
8842
|
+
|
|
8843
|
+
return addCustomFlags;
|
|
8844
|
+
}()
|
|
8845
|
+
/**
|
|
8846
|
+
* Add custom flags to a message
|
|
8847
|
+
* @param {string} messageID Message ID to be flagged
|
|
8848
|
+
* @param {Array<CustomCheckFlag>} flags Array of CustomCheckFlag to be passed to flag the message
|
|
8849
|
+
* @returns
|
|
8850
|
+
*/
|
|
8851
|
+
|
|
8852
|
+
}, {
|
|
8853
|
+
key: "addCustomMessageFlags",
|
|
8854
|
+
value: function () {
|
|
8855
|
+
var _addCustomMessageFlags = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee15(messageID, flags) {
|
|
8856
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee15$(_context15) {
|
|
8857
|
+
while (1) {
|
|
8858
|
+
switch (_context15.prev = _context15.next) {
|
|
8859
|
+
case 0:
|
|
8860
|
+
_context15.next = 2;
|
|
8861
|
+
return this.addCustomFlags(MODERATION_ENTITY_TYPES.message, messageID, '', {}, flags);
|
|
8862
|
+
|
|
8863
|
+
case 2:
|
|
8864
|
+
return _context15.abrupt("return", _context15.sent);
|
|
8865
|
+
|
|
8866
|
+
case 3:
|
|
8867
|
+
case "end":
|
|
8868
|
+
return _context15.stop();
|
|
8869
|
+
}
|
|
8870
|
+
}
|
|
8871
|
+
}, _callee15, this);
|
|
8872
|
+
}));
|
|
8873
|
+
|
|
8874
|
+
function addCustomMessageFlags(_x30, _x31) {
|
|
8875
|
+
return _addCustomMessageFlags.apply(this, arguments);
|
|
8876
|
+
}
|
|
8877
|
+
|
|
8878
|
+
return addCustomMessageFlags;
|
|
8879
|
+
}()
|
|
8785
8880
|
}]);
|
|
8786
8881
|
|
|
8787
8882
|
return Moderation;
|
|
@@ -14769,7 +14864,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
14769
14864
|
}, {
|
|
14770
14865
|
key: "getUserAgent",
|
|
14771
14866
|
value: function getUserAgent() {
|
|
14772
|
-
return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "8.
|
|
14867
|
+
return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "8.48.0");
|
|
14773
14868
|
}
|
|
14774
14869
|
}, {
|
|
14775
14870
|
key: "setUserAgent",
|