stream-chat-react 10.7.3 → 10.7.5
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 +97 -58
- package/dist/browser.full-bundle.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/components/Channel/Channel.d.ts.map +1 -1
- package/dist/components/Channel/Channel.js +95 -57
- package/dist/components/MessageInput/hooks/useCreateMessageInputContext.d.ts.map +1 -1
- package/dist/components/MessageInput/hooks/useCreateMessageInputContext.js +1 -0
- package/dist/index.cjs.js +97 -58
- 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
|
@@ -45791,6 +45791,7 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
45791
45791
|
showCommandsList,
|
|
45792
45792
|
showMentionsList,
|
|
45793
45793
|
text,
|
|
45794
|
+
handleSubmit,
|
|
45794
45795
|
]);
|
|
45795
45796
|
return messageInputContext;
|
|
45796
45797
|
};
|
|
@@ -46653,55 +46654,78 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
46653
46654
|
}
|
|
46654
46655
|
};
|
|
46655
46656
|
var markReadThrottled = lodash_throttle(markRead, 500, { leading: true, trailing: true });
|
|
46656
|
-
var handleEvent = function (event) {
|
|
46657
|
-
var
|
|
46658
|
-
|
|
46659
|
-
|
|
46660
|
-
|
|
46661
|
-
|
|
46662
|
-
|
|
46663
|
-
|
|
46664
|
-
|
|
46665
|
-
|
|
46666
|
-
|
|
46667
|
-
|
|
46668
|
-
return dispatch({ channel: channel, type: 'setTyping' });
|
|
46669
|
-
}
|
|
46670
|
-
if (event.type === 'connection.changed' && typeof event.online === 'boolean') {
|
|
46671
|
-
online.current = event.online;
|
|
46672
|
-
}
|
|
46673
|
-
if (event.type === 'message.new') {
|
|
46674
|
-
var mainChannelUpdated = true;
|
|
46675
|
-
if (((_a = event.message) === null || _a === void 0 ? void 0 : _a.parent_id) && !((_b = event.message) === null || _b === void 0 ? void 0 : _b.show_in_channel)) {
|
|
46676
|
-
mainChannelUpdated = false;
|
|
46677
|
-
}
|
|
46678
|
-
if (mainChannelUpdated && ((_d = (_c = event.message) === null || _c === void 0 ? void 0 : _c.user) === null || _d === void 0 ? void 0 : _d.id) !== client.userID) {
|
|
46679
|
-
if (!document.hidden) {
|
|
46680
|
-
markReadThrottled();
|
|
46681
|
-
}
|
|
46682
|
-
else if ((channelConfig === null || channelConfig === void 0 ? void 0 : channelConfig.read_events) && !channel.muteStatus().muted) {
|
|
46683
|
-
var unread = channel.countUnread(lastRead.current);
|
|
46684
|
-
if (activeUnreadHandler) {
|
|
46685
|
-
activeUnreadHandler(unread, originalTitle.current);
|
|
46657
|
+
var handleEvent = function (event) { return __awaiter$1(void 0, void 0, void 0, function () {
|
|
46658
|
+
var mainChannelUpdated, unread, messageDate, cid, oldestID;
|
|
46659
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
46660
|
+
return __generator$1(this, function (_m) {
|
|
46661
|
+
switch (_m.label) {
|
|
46662
|
+
case 0:
|
|
46663
|
+
if (event.message) {
|
|
46664
|
+
dispatch({
|
|
46665
|
+
channel: channel,
|
|
46666
|
+
message: event.message,
|
|
46667
|
+
type: 'updateThreadOnEvent',
|
|
46668
|
+
});
|
|
46686
46669
|
}
|
|
46687
|
-
|
|
46688
|
-
|
|
46670
|
+
if (event.type === 'user.watching.start' || event.type === 'user.watching.stop')
|
|
46671
|
+
return [2 /*return*/];
|
|
46672
|
+
if (event.type === 'typing.start' || event.type === 'typing.stop') {
|
|
46673
|
+
return [2 /*return*/, dispatch({ channel: channel, type: 'setTyping' })];
|
|
46689
46674
|
}
|
|
46690
|
-
|
|
46691
|
-
|
|
46692
|
-
|
|
46693
|
-
|
|
46694
|
-
|
|
46695
|
-
|
|
46696
|
-
|
|
46697
|
-
|
|
46698
|
-
|
|
46699
|
-
|
|
46700
|
-
|
|
46675
|
+
if (event.type === 'connection.changed' && typeof event.online === 'boolean') {
|
|
46676
|
+
online.current = event.online;
|
|
46677
|
+
}
|
|
46678
|
+
if (event.type === 'message.new') {
|
|
46679
|
+
mainChannelUpdated = true;
|
|
46680
|
+
if (((_a = event.message) === null || _a === void 0 ? void 0 : _a.parent_id) && !((_b = event.message) === null || _b === void 0 ? void 0 : _b.show_in_channel)) {
|
|
46681
|
+
mainChannelUpdated = false;
|
|
46682
|
+
}
|
|
46683
|
+
if (mainChannelUpdated && ((_d = (_c = event.message) === null || _c === void 0 ? void 0 : _c.user) === null || _d === void 0 ? void 0 : _d.id) !== client.userID) {
|
|
46684
|
+
if (!document.hidden) {
|
|
46685
|
+
markReadThrottled();
|
|
46686
|
+
}
|
|
46687
|
+
else if ((channelConfig === null || channelConfig === void 0 ? void 0 : channelConfig.read_events) && !channel.muteStatus().muted) {
|
|
46688
|
+
unread = channel.countUnread(lastRead.current);
|
|
46689
|
+
if (activeUnreadHandler) {
|
|
46690
|
+
activeUnreadHandler(unread, originalTitle.current);
|
|
46691
|
+
}
|
|
46692
|
+
else {
|
|
46693
|
+
document.title = "(".concat(unread, ") ").concat(originalTitle.current);
|
|
46694
|
+
}
|
|
46695
|
+
}
|
|
46696
|
+
}
|
|
46697
|
+
if (((_f = (_e = event.message) === null || _e === void 0 ? void 0 : _e.user) === null || _f === void 0 ? void 0 : _f.id) === client.userID &&
|
|
46698
|
+
((_g = event === null || event === void 0 ? void 0 : event.message) === null || _g === void 0 ? void 0 : _g.created_at) &&
|
|
46699
|
+
((_h = event === null || event === void 0 ? void 0 : event.message) === null || _h === void 0 ? void 0 : _h.cid)) {
|
|
46700
|
+
messageDate = new Date(event.message.created_at);
|
|
46701
|
+
cid = event.message.cid;
|
|
46702
|
+
if (!latestMessageDatesByChannels[cid] ||
|
|
46703
|
+
latestMessageDatesByChannels[cid].getTime() < messageDate.getTime()) {
|
|
46704
|
+
latestMessageDatesByChannels[cid] = messageDate;
|
|
46705
|
+
}
|
|
46706
|
+
}
|
|
46707
|
+
}
|
|
46708
|
+
if (!(event.type === 'user.deleted')) return [3 /*break*/, 2];
|
|
46709
|
+
oldestID = (_l = (_k = (_j = channel.state) === null || _j === void 0 ? void 0 : _j.messages) === null || _k === void 0 ? void 0 : _k[0]) === null || _l === void 0 ? void 0 : _l.id;
|
|
46710
|
+
/**
|
|
46711
|
+
* As the channel state is not normalized we re-fetch the channel data. Thus, we avoid having to search for user references in the channel state.
|
|
46712
|
+
*/
|
|
46713
|
+
return [4 /*yield*/, channel.query({
|
|
46714
|
+
messages: { id_lt: oldestID, limit: DEFAULT_NEXT_CHANNEL_PAGE_SIZE },
|
|
46715
|
+
watchers: { limit: DEFAULT_NEXT_CHANNEL_PAGE_SIZE },
|
|
46716
|
+
})];
|
|
46717
|
+
case 1:
|
|
46718
|
+
/**
|
|
46719
|
+
* As the channel state is not normalized we re-fetch the channel data. Thus, we avoid having to search for user references in the channel state.
|
|
46720
|
+
*/
|
|
46721
|
+
_m.sent();
|
|
46722
|
+
_m.label = 2;
|
|
46723
|
+
case 2:
|
|
46724
|
+
throttledCopyStateFromChannel();
|
|
46725
|
+
return [2 /*return*/];
|
|
46701
46726
|
}
|
|
46702
|
-
}
|
|
46703
|
-
|
|
46704
|
-
};
|
|
46727
|
+
});
|
|
46728
|
+
}); };
|
|
46705
46729
|
// useLayoutEffect here to prevent spinner. Use Suspense when it is available in stable release
|
|
46706
46730
|
React$2.useLayoutEffect(function () {
|
|
46707
46731
|
var errored = false;
|
|
@@ -46923,9 +46947,10 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
46923
46947
|
};
|
|
46924
46948
|
var isUserResponseArray = function (output) { var _a; return ((_a = output[0]) === null || _a === void 0 ? void 0 : _a.id) != null; };
|
|
46925
46949
|
var doSendMessage = function (message, customMessageData) { return __awaiter$1(void 0, void 0, void 0, function () {
|
|
46926
|
-
var attachments, id, _a, mentioned_users, parent_id, text, mentions, messageData, messageResponse, error_1, stringError, parsedError;
|
|
46927
|
-
|
|
46928
|
-
|
|
46950
|
+
var attachments, id, _a, mentioned_users, parent_id, text, mentions, messageData, messageResponse, existingMessage, i, msg, responseTimestamp, existingMessageTimestamp, responseIsTheNewest, error_1, stringError, parsedError;
|
|
46951
|
+
var _b, _c;
|
|
46952
|
+
return __generator$1(this, function (_d) {
|
|
46953
|
+
switch (_d.label) {
|
|
46929
46954
|
case 0:
|
|
46930
46955
|
attachments = message.attachments, id = message.id, _a = message.mentioned_users, mentioned_users = _a === void 0 ? [] : _a, parent_id = message.parent_id, text = message.text;
|
|
46931
46956
|
mentions = isUserResponseArray(mentioned_users)
|
|
@@ -46935,29 +46960,43 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
46935
46960
|
})
|
|
46936
46961
|
: mentioned_users;
|
|
46937
46962
|
messageData = __assign$8({ 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);
|
|
46938
|
-
|
|
46963
|
+
_d.label = 1;
|
|
46939
46964
|
case 1:
|
|
46940
|
-
|
|
46965
|
+
_d.trys.push([1, 6, , 7]);
|
|
46941
46966
|
messageResponse = void 0;
|
|
46942
46967
|
if (!doSendMessageRequest) return [3 /*break*/, 3];
|
|
46943
46968
|
return [4 /*yield*/, doSendMessageRequest(channel.cid, messageData)];
|
|
46944
46969
|
case 2:
|
|
46945
|
-
messageResponse =
|
|
46970
|
+
messageResponse = _d.sent();
|
|
46946
46971
|
return [3 /*break*/, 5];
|
|
46947
46972
|
case 3: return [4 /*yield*/, channel.sendMessage(messageData)];
|
|
46948
46973
|
case 4:
|
|
46949
|
-
messageResponse =
|
|
46950
|
-
|
|
46974
|
+
messageResponse = _d.sent();
|
|
46975
|
+
_d.label = 5;
|
|
46951
46976
|
case 5:
|
|
46952
|
-
|
|
46953
|
-
|
|
46977
|
+
existingMessage = void 0;
|
|
46978
|
+
for (i = channel.state.messages.length - 1; i >= 0; i--) {
|
|
46979
|
+
msg = channel.state.messages[i];
|
|
46980
|
+
if (msg.id === messageData.id) {
|
|
46981
|
+
existingMessage = msg;
|
|
46982
|
+
break;
|
|
46983
|
+
}
|
|
46984
|
+
}
|
|
46985
|
+
responseTimestamp = new Date(((_b = messageResponse === null || messageResponse === void 0 ? void 0 : messageResponse.message) === null || _b === void 0 ? void 0 : _b.updated_at) || 0).getTime();
|
|
46986
|
+
existingMessageTimestamp = ((_c = existingMessage === null || existingMessage === void 0 ? void 0 : existingMessage.updated_at) === null || _c === void 0 ? void 0 : _c.getTime()) || 0;
|
|
46987
|
+
responseIsTheNewest = responseTimestamp > existingMessageTimestamp;
|
|
46988
|
+
// Replace the message payload after send is completed
|
|
46989
|
+
// 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.
|
|
46990
|
+
// Always override existing message in status "sending"
|
|
46991
|
+
if ((messageResponse === null || messageResponse === void 0 ? void 0 : messageResponse.message) &&
|
|
46992
|
+
(responseIsTheNewest || (existingMessage === null || existingMessage === void 0 ? void 0 : existingMessage.status) === 'sending')) {
|
|
46954
46993
|
updateMessage(__assign$8(__assign$8({}, messageResponse.message), { status: 'received' }));
|
|
46955
46994
|
}
|
|
46956
46995
|
if (quotedMessage && parent_id === (quotedMessage === null || quotedMessage === void 0 ? void 0 : quotedMessage.parent_id))
|
|
46957
46996
|
setQuotedMessage(undefined);
|
|
46958
46997
|
return [3 /*break*/, 7];
|
|
46959
46998
|
case 6:
|
|
46960
|
-
error_1 =
|
|
46999
|
+
error_1 = _d.sent();
|
|
46961
47000
|
stringError = JSON.stringify(error_1);
|
|
46962
47001
|
parsedError = stringError ? JSON.parse(stringError) : {};
|
|
46963
47002
|
updateMessage(__assign$8(__assign$8({}, message), { error: parsedError, errorStatusCode: parsedError.status || undefined, status: 'failed' }));
|
|
@@ -48355,7 +48394,7 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
48355
48394
|
|
|
48356
48395
|
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};
|
|
48357
48396
|
|
|
48358
|
-
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var version$1 = '10.7.
|
|
48397
|
+
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var version$1 = '10.7.5';
|
|
48359
48398
|
|
|
48360
48399
|
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var useChat = function (_a) {
|
|
48361
48400
|
var _b, _c;
|