stream-chat-react 9.5.1 → 9.5.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.
- package/dist/browser.full-bundle.js +66 -48
- package/dist/browser.full-bundle.js.map +1 -1
- package/dist/browser.full-bundle.min.js +3 -3
- package/dist/browser.full-bundle.min.js.map +1 -1
- package/dist/components/Attachment/Attachment.d.ts.map +1 -1
- package/dist/components/Attachment/Attachment.js +3 -2
- package/dist/components/Attachment/utils.d.ts.map +1 -1
- package/dist/components/Attachment/utils.js +12 -13
- package/dist/components/Channel/Channel.d.ts.map +1 -1
- package/dist/components/Channel/Channel.js +26 -11
- package/dist/components/MessageList/hooks/usePrependMessagesCount.d.ts.map +1 -1
- package/dist/components/MessageList/hooks/usePrependMessagesCount.js +7 -5
- package/dist/index.cjs.js +50 -32
- package/dist/index.cjs.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -5510,23 +5510,6 @@ var StreamChatReact = (function (exports, React, streamChat, reactDom) {
|
|
|
5510
5510
|
|
|
5511
5511
|
var ReactPlayer = unwrapExports(lib$8);
|
|
5512
5512
|
|
|
5513
|
-
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};
|
|
5514
|
-
|
|
5515
|
-
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};let nanoid = (size = 21) =>
|
|
5516
|
-
crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => {
|
|
5517
|
-
byte &= 63;
|
|
5518
|
-
if (byte < 36) {
|
|
5519
|
-
id += byte.toString(36);
|
|
5520
|
-
} else if (byte < 62) {
|
|
5521
|
-
id += (byte - 26).toString(36).toUpperCase();
|
|
5522
|
-
} else if (byte > 62) {
|
|
5523
|
-
id += '-';
|
|
5524
|
-
} else {
|
|
5525
|
-
id += '_';
|
|
5526
|
-
}
|
|
5527
|
-
return id
|
|
5528
|
-
}, '');
|
|
5529
|
-
|
|
5530
5513
|
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var UnMemoizedAttachmentActions = function (props) {
|
|
5531
5514
|
var actionHandler = props.actionHandler, actions = props.actions, id = props.id, text = props.text;
|
|
5532
5515
|
var handleActionClick = function (event, name, value) {
|
|
@@ -11781,20 +11764,20 @@ var StreamChatReact = (function (exports, React, streamChat, reactDom) {
|
|
|
11781
11764
|
? 'actions'
|
|
11782
11765
|
: '';
|
|
11783
11766
|
}
|
|
11784
|
-
return (React__default['default'].createElement("div", { className: "str-chat__message-attachment str-chat__message-attachment--" + componentType + " str-chat__message-attachment--" + ((attachment === null || attachment === void 0 ? void 0 : attachment.type) || '') + " str-chat__message-attachment--" + componentType + "--" + extra
|
|
11767
|
+
return (React__default['default'].createElement("div", { className: "str-chat__message-attachment str-chat__message-attachment--" + componentType + " str-chat__message-attachment--" + ((attachment === null || attachment === void 0 ? void 0 : attachment.type) || '') + " str-chat__message-attachment--" + componentType + "--" + extra }, children));
|
|
11785
11768
|
};
|
|
11786
11769
|
var renderAttachmentActions = function (props) {
|
|
11787
11770
|
var _a;
|
|
11788
11771
|
var actionHandler = props.actionHandler, attachment = props.attachment, _b = props.AttachmentActions, AttachmentActions$1 = _b === void 0 ? AttachmentActions : _b;
|
|
11789
11772
|
if (!((_a = attachment.actions) === null || _a === void 0 ? void 0 : _a.length))
|
|
11790
11773
|
return null;
|
|
11791
|
-
return (React__default['default'].createElement(AttachmentActions$1, __assign$2({}, attachment, { actionHandler: function (event, name, value) { return actionHandler === null || actionHandler === void 0 ? void 0 : actionHandler(event, name, value); }, actions: attachment.actions, id: attachment.id || '',
|
|
11774
|
+
return (React__default['default'].createElement(AttachmentActions$1, __assign$2({}, attachment, { actionHandler: function (event, name, value) { return actionHandler === null || actionHandler === void 0 ? void 0 : actionHandler(event, name, value); }, actions: attachment.actions, id: attachment.id || '', text: attachment.text || '' })));
|
|
11792
11775
|
};
|
|
11793
11776
|
var renderGallery = function (props) {
|
|
11794
11777
|
var attachment = props.attachment, _a = props.Gallery, Gallery$1 = _a === void 0 ? Gallery : _a;
|
|
11795
11778
|
return renderAttachmentWithinContainer({
|
|
11796
11779
|
attachment: attachment,
|
|
11797
|
-
children: React__default['default'].createElement(Gallery$1, { images: attachment.images || []
|
|
11780
|
+
children: React__default['default'].createElement(Gallery$1, { images: attachment.images || [] }),
|
|
11798
11781
|
componentType: 'gallery',
|
|
11799
11782
|
});
|
|
11800
11783
|
};
|
|
@@ -11803,7 +11786,7 @@ var StreamChatReact = (function (exports, React, streamChat, reactDom) {
|
|
|
11803
11786
|
if (attachment.actions && attachment.actions.length) {
|
|
11804
11787
|
return renderAttachmentWithinContainer({
|
|
11805
11788
|
attachment: attachment,
|
|
11806
|
-
children: (React__default['default'].createElement("div", { className: 'str-chat__attachment'
|
|
11789
|
+
children: (React__default['default'].createElement("div", { className: 'str-chat__attachment' },
|
|
11807
11790
|
React__default['default'].createElement(Image, __assign$2({}, attachment)),
|
|
11808
11791
|
renderAttachmentActions(props))),
|
|
11809
11792
|
componentType: 'image',
|
|
@@ -11811,7 +11794,7 @@ var StreamChatReact = (function (exports, React, streamChat, reactDom) {
|
|
|
11811
11794
|
}
|
|
11812
11795
|
return renderAttachmentWithinContainer({
|
|
11813
11796
|
attachment: attachment,
|
|
11814
|
-
children: React__default['default'].createElement(Image, __assign$2({}, attachment
|
|
11797
|
+
children: React__default['default'].createElement(Image, __assign$2({}, attachment)),
|
|
11815
11798
|
componentType: 'image',
|
|
11816
11799
|
});
|
|
11817
11800
|
};
|
|
@@ -11820,15 +11803,15 @@ var StreamChatReact = (function (exports, React, streamChat, reactDom) {
|
|
|
11820
11803
|
if (attachment.actions && attachment.actions.length) {
|
|
11821
11804
|
return renderAttachmentWithinContainer({
|
|
11822
11805
|
attachment: attachment,
|
|
11823
|
-
children: (React__default['default'].createElement("div", { className: 'str-chat__attachment'
|
|
11824
|
-
React__default['default'].createElement(Card, __assign$2({}, attachment
|
|
11806
|
+
children: (React__default['default'].createElement("div", { className: 'str-chat__attachment' },
|
|
11807
|
+
React__default['default'].createElement(Card, __assign$2({}, attachment)),
|
|
11825
11808
|
renderAttachmentActions(props))),
|
|
11826
11809
|
componentType: 'card',
|
|
11827
11810
|
});
|
|
11828
11811
|
}
|
|
11829
11812
|
return renderAttachmentWithinContainer({
|
|
11830
11813
|
attachment: attachment,
|
|
11831
|
-
children: React__default['default'].createElement(Card, __assign$2({}, attachment
|
|
11814
|
+
children: React__default['default'].createElement(Card, __assign$2({}, attachment)),
|
|
11832
11815
|
componentType: 'card',
|
|
11833
11816
|
});
|
|
11834
11817
|
};
|
|
@@ -11838,7 +11821,7 @@ var StreamChatReact = (function (exports, React, streamChat, reactDom) {
|
|
|
11838
11821
|
return null;
|
|
11839
11822
|
return renderAttachmentWithinContainer({
|
|
11840
11823
|
attachment: attachment,
|
|
11841
|
-
children: React__default['default'].createElement(File, { attachment: attachment
|
|
11824
|
+
children: React__default['default'].createElement(File, { attachment: attachment }),
|
|
11842
11825
|
componentType: 'file',
|
|
11843
11826
|
});
|
|
11844
11827
|
};
|
|
@@ -11846,7 +11829,7 @@ var StreamChatReact = (function (exports, React, streamChat, reactDom) {
|
|
|
11846
11829
|
var attachment = props.attachment, _a = props.Audio, Audio$1 = _a === void 0 ? Audio : _a;
|
|
11847
11830
|
return renderAttachmentWithinContainer({
|
|
11848
11831
|
attachment: attachment,
|
|
11849
|
-
children: (React__default['default'].createElement("div", { className: 'str-chat__attachment'
|
|
11832
|
+
children: (React__default['default'].createElement("div", { className: 'str-chat__attachment' },
|
|
11850
11833
|
React__default['default'].createElement(Audio$1, { og: attachment }))),
|
|
11851
11834
|
componentType: 'audio',
|
|
11852
11835
|
});
|
|
@@ -11857,7 +11840,7 @@ var StreamChatReact = (function (exports, React, streamChat, reactDom) {
|
|
|
11857
11840
|
if ((_a = attachment.actions) === null || _a === void 0 ? void 0 : _a.length) {
|
|
11858
11841
|
return renderAttachmentWithinContainer({
|
|
11859
11842
|
attachment: attachment,
|
|
11860
|
-
children: (React__default['default'].createElement("div", { className: 'str-chat__attachment str-chat__attachment-media'
|
|
11843
|
+
children: (React__default['default'].createElement("div", { className: 'str-chat__attachment str-chat__attachment-media' },
|
|
11861
11844
|
React__default['default'].createElement("div", { className: 'str-chat__player-wrapper' },
|
|
11862
11845
|
React__default['default'].createElement(Media, { className: 'react-player', controls: true, height: '100%', url: attachment.asset_url, width: '100%' })),
|
|
11863
11846
|
renderAttachmentActions(props))),
|
|
@@ -11866,7 +11849,7 @@ var StreamChatReact = (function (exports, React, streamChat, reactDom) {
|
|
|
11866
11849
|
}
|
|
11867
11850
|
return renderAttachmentWithinContainer({
|
|
11868
11851
|
attachment: attachment,
|
|
11869
|
-
children: (React__default['default'].createElement("div", { className: 'str-chat__player-wrapper'
|
|
11852
|
+
children: (React__default['default'].createElement("div", { className: 'str-chat__player-wrapper' },
|
|
11870
11853
|
React__default['default'].createElement(Media, { className: 'react-player', controls: true, height: '100%', url: attachment.asset_url, width: '100%' }))),
|
|
11871
11854
|
componentType: 'media',
|
|
11872
11855
|
});
|
|
@@ -11889,7 +11872,7 @@ var StreamChatReact = (function (exports, React, streamChat, reactDom) {
|
|
|
11889
11872
|
})), [
|
|
11890
11873
|
gallery,
|
|
11891
11874
|
]) : attachments;
|
|
11892
|
-
|
|
11875
|
+
var getContent = function (attachment) {
|
|
11893
11876
|
if (isGalleryAttachmentType(attachment)) {
|
|
11894
11877
|
return renderGallery(__assign$2(__assign$2({}, rest), { attachment: attachment }));
|
|
11895
11878
|
}
|
|
@@ -11906,7 +11889,8 @@ var StreamChatReact = (function (exports, React, streamChat, reactDom) {
|
|
|
11906
11889
|
return renderMedia(__assign$2(__assign$2({}, rest), { attachment: attachment }));
|
|
11907
11890
|
}
|
|
11908
11891
|
return renderCard(__assign$2(__assign$2({}, rest), { attachment: attachment }));
|
|
11909
|
-
}
|
|
11892
|
+
};
|
|
11893
|
+
return (React__default['default'].createElement(React__default['default'].Fragment, null, newAttachments.map(function (attachment, i) { return (React__default['default'].createElement(React__default['default'].Fragment, { key: i }, getContent(attachment))); })));
|
|
11910
11894
|
};
|
|
11911
11895
|
|
|
11912
11896
|
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};
|
|
@@ -13562,6 +13546,23 @@ var StreamChatReact = (function (exports, React, streamChat, reactDom) {
|
|
|
13562
13546
|
var linkifyjs = linkify;
|
|
13563
13547
|
var linkifyjs_1 = linkifyjs.find;
|
|
13564
13548
|
|
|
13549
|
+
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};
|
|
13550
|
+
|
|
13551
|
+
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};let nanoid = (size = 21) =>
|
|
13552
|
+
crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => {
|
|
13553
|
+
byte &= 63;
|
|
13554
|
+
if (byte < 36) {
|
|
13555
|
+
id += byte.toString(36);
|
|
13556
|
+
} else if (byte < 62) {
|
|
13557
|
+
id += (byte - 26).toString(36).toUpperCase();
|
|
13558
|
+
} else if (byte > 62) {
|
|
13559
|
+
id += '-';
|
|
13560
|
+
} else {
|
|
13561
|
+
id += '_';
|
|
13562
|
+
}
|
|
13563
|
+
return id
|
|
13564
|
+
}, '');
|
|
13565
|
+
|
|
13565
13566
|
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};function escapeStringRegexp(string) {
|
|
13566
13567
|
if (typeof string !== 'string') {
|
|
13567
13568
|
throw new TypeError('Expected a string');
|
|
@@ -42183,9 +42184,10 @@ var StreamChatReact = (function (exports, React, streamChat, reactDom) {
|
|
|
42183
42184
|
};
|
|
42184
42185
|
var isUserResponseArray = function (output) { var _a; return ((_a = output[0]) === null || _a === void 0 ? void 0 : _a.id) != null; };
|
|
42185
42186
|
var doSendMessage = function (message, customMessageData) { return __awaiter$1(void 0, void 0, void 0, function () {
|
|
42186
|
-
var attachments, id, _a, mentioned_users, parent_id, text, mentions, messageData, messageResponse, error_1, stringError, parsedError;
|
|
42187
|
-
|
|
42188
|
-
|
|
42187
|
+
var attachments, id, _a, mentioned_users, parent_id, text, mentions, messageData, messageResponse, existingMessage, i, msg, responseTimestamp, existingMessageTimestamp, responseIsTheNewest, error_1, stringError, parsedError;
|
|
42188
|
+
var _b, _c;
|
|
42189
|
+
return __generator$1(this, function (_d) {
|
|
42190
|
+
switch (_d.label) {
|
|
42189
42191
|
case 0:
|
|
42190
42192
|
attachments = message.attachments, id = message.id, _a = message.mentioned_users, mentioned_users = _a === void 0 ? [] : _a, parent_id = message.parent_id, text = message.text;
|
|
42191
42193
|
mentions = isUserResponseArray(mentioned_users)
|
|
@@ -42195,29 +42197,43 @@ var StreamChatReact = (function (exports, React, streamChat, reactDom) {
|
|
|
42195
42197
|
})
|
|
42196
42198
|
: mentioned_users;
|
|
42197
42199
|
messageData = __assign$2({ attachments: attachments, id: id, mentioned_users: mentions, parent_id: parent_id, quoted_message_id: parent_id === (quotedMessage === null || quotedMessage === void 0 ? void 0 : quotedMessage.parent_id) ? quotedMessage === null || quotedMessage === void 0 ? void 0 : quotedMessage.id : undefined, text: text }, customMessageData);
|
|
42198
|
-
|
|
42200
|
+
_d.label = 1;
|
|
42199
42201
|
case 1:
|
|
42200
|
-
|
|
42202
|
+
_d.trys.push([1, 6, , 7]);
|
|
42201
42203
|
messageResponse = void 0;
|
|
42202
42204
|
if (!doSendMessageRequest) return [3 /*break*/, 3];
|
|
42203
42205
|
return [4 /*yield*/, doSendMessageRequest(channel.cid, messageData)];
|
|
42204
42206
|
case 2:
|
|
42205
|
-
messageResponse =
|
|
42207
|
+
messageResponse = _d.sent();
|
|
42206
42208
|
return [3 /*break*/, 5];
|
|
42207
42209
|
case 3: return [4 /*yield*/, channel.sendMessage(messageData)];
|
|
42208
42210
|
case 4:
|
|
42209
|
-
messageResponse =
|
|
42210
|
-
|
|
42211
|
+
messageResponse = _d.sent();
|
|
42212
|
+
_d.label = 5;
|
|
42211
42213
|
case 5:
|
|
42212
|
-
|
|
42213
|
-
|
|
42214
|
+
existingMessage = void 0;
|
|
42215
|
+
for (i = channel.state.messages.length - 1; i >= 0; i--) {
|
|
42216
|
+
msg = channel.state.messages[i];
|
|
42217
|
+
if (msg.id === messageData.id) {
|
|
42218
|
+
existingMessage = msg;
|
|
42219
|
+
break;
|
|
42220
|
+
}
|
|
42221
|
+
}
|
|
42222
|
+
responseTimestamp = new Date(((_b = messageResponse === null || messageResponse === void 0 ? void 0 : messageResponse.message) === null || _b === void 0 ? void 0 : _b.updated_at) || 0).getTime();
|
|
42223
|
+
existingMessageTimestamp = ((_c = existingMessage === null || existingMessage === void 0 ? void 0 : existingMessage.updated_at) === null || _c === void 0 ? void 0 : _c.getTime()) || 0;
|
|
42224
|
+
responseIsTheNewest = responseTimestamp > existingMessageTimestamp;
|
|
42225
|
+
// Replace the message payload after send is completed
|
|
42226
|
+
// We need to check for the newest message payload, because on slow network, the response can arrive later than WS events message.new, message.updated.
|
|
42227
|
+
// Always override existing message in status "sending"
|
|
42228
|
+
if ((messageResponse === null || messageResponse === void 0 ? void 0 : messageResponse.message) &&
|
|
42229
|
+
(responseIsTheNewest || (existingMessage === null || existingMessage === void 0 ? void 0 : existingMessage.status) === 'sending')) {
|
|
42214
42230
|
updateMessage(__assign$2(__assign$2({}, messageResponse.message), { status: 'received' }));
|
|
42215
42231
|
}
|
|
42216
42232
|
if (quotedMessage && parent_id === (quotedMessage === null || quotedMessage === void 0 ? void 0 : quotedMessage.parent_id))
|
|
42217
42233
|
setQuotedMessage(undefined);
|
|
42218
42234
|
return [3 /*break*/, 7];
|
|
42219
42235
|
case 6:
|
|
42220
|
-
error_1 =
|
|
42236
|
+
error_1 = _d.sent();
|
|
42221
42237
|
stringError = JSON.stringify(error_1);
|
|
42222
42238
|
parsedError = stringError ? JSON.parse(stringError) : {};
|
|
42223
42239
|
updateMessage(__assign$2(__assign$2({}, message), { error: parsedError, errorStatusCode: parsedError.status || undefined, status: 'failed' }));
|
|
@@ -43383,7 +43399,7 @@ var StreamChatReact = (function (exports, React, streamChat, reactDom) {
|
|
|
43383
43399
|
|
|
43384
43400
|
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};
|
|
43385
43401
|
|
|
43386
|
-
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var version = '9.5.
|
|
43402
|
+
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var version = '9.5.3';
|
|
43387
43403
|
|
|
43388
43404
|
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var useChat = function (_a) {
|
|
43389
43405
|
var _b, _c;
|
|
@@ -46535,16 +46551,17 @@ var StreamChatReact = (function (exports, React, streamChat, reactDom) {
|
|
|
46535
46551
|
}
|
|
46536
46552
|
|
|
46537
46553
|
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};function usePrependedMessagesCount(messages, hasDateSeparator) {
|
|
46538
|
-
var _a;
|
|
46539
46554
|
var firstRealMessageIndex = hasDateSeparator ? 1 : 0;
|
|
46540
|
-
var
|
|
46541
|
-
var
|
|
46542
|
-
var earliestMessageId = React.useRef(currentFirstMessageId);
|
|
46555
|
+
var firstMessageId = React.useRef();
|
|
46556
|
+
var earliestMessageId = React.useRef();
|
|
46543
46557
|
var previousNumItemsPrepended = React.useRef(0);
|
|
46544
46558
|
var numItemsPrepended = React.useMemo(function () {
|
|
46559
|
+
var _a;
|
|
46545
46560
|
if (!messages || !messages.length) {
|
|
46561
|
+
previousNumItemsPrepended.current = 0;
|
|
46546
46562
|
return 0;
|
|
46547
46563
|
}
|
|
46564
|
+
var currentFirstMessageId = (_a = messages === null || messages === void 0 ? void 0 : messages[firstRealMessageIndex]) === null || _a === void 0 ? void 0 : _a.id;
|
|
46548
46565
|
// if no new messages were prepended, return early (same amount as before)
|
|
46549
46566
|
if (currentFirstMessageId === earliestMessageId.current) {
|
|
46550
46567
|
return previousNumItemsPrepended.current;
|
|
@@ -46561,8 +46578,9 @@ var StreamChatReact = (function (exports, React, streamChat, reactDom) {
|
|
|
46561
46578
|
return i;
|
|
46562
46579
|
}
|
|
46563
46580
|
}
|
|
46564
|
-
// if no match has found, we have jumped
|
|
46581
|
+
// if no match has found, we have jumped - reset the prepend item count.
|
|
46565
46582
|
firstMessageId.current = currentFirstMessageId;
|
|
46583
|
+
previousNumItemsPrepended.current = 0;
|
|
46566
46584
|
return 0;
|
|
46567
46585
|
// TODO: there's a bug here, the messages prop is the same array instance (something mutates it)
|
|
46568
46586
|
// that's why the second dependency is necessary
|