stream-chat-react 10.4.1 → 10.4.2

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.
@@ -36672,7 +36672,7 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
36672
36672
  // valid cases: "text @", "@", " @"
36673
36673
  // invalid cases: "text@", "@text",
36674
36674
  /.?\s?@$|^@$/.test(node.value) &&
36675
- nextChildHref.startsWith('mailto:')) {
36675
+ (nextChildHref === null || nextChildHref === void 0 ? void 0 : nextChildHref.startsWith('mailto:'))) {
36676
36676
  var newTextValue = node.value.replace(/@$/, '');
36677
36677
  var username = nextChildHref.replace('mailto:', '');
36678
36678
  parent.children[index] = u$3('text', newTextValue);
@@ -42717,7 +42717,8 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
42717
42717
  _a.label = 1;
42718
42718
  case 1:
42719
42719
  _a.trys.push([1, 3, , 4]);
42720
- return [4 /*yield*/, client.queryUsers(__assign$8({ $or: [{ id: { $autocomplete: query } }, { name: { $autocomplete: query } }], id: { $ne: client.userID } }, mentionQueryParams.filters), __assign$8({ id: 1 }, mentionQueryParams.sort), __assign$8({ limit: 10 }, mentionQueryParams.options))];
42720
+ return [4 /*yield*/, client.queryUsers(__assign$8({ $or: [{ id: { $autocomplete: query } }, { name: { $autocomplete: query } }], id: { $ne: client.userID } }, mentionQueryParams.filters), Array.isArray(mentionQueryParams.sort)
42721
+ ? __spreadArray([{ id: 1 }], mentionQueryParams.sort, true) : __assign$8({ id: 1 }, mentionQueryParams.sort), __assign$8({ limit: 10 }, mentionQueryParams.options))];
42721
42722
  case 2:
42722
42723
  users = (_a.sent()).users;
42723
42724
  if (onReady && users.length) {
@@ -44674,24 +44675,28 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
44674
44675
  };
44675
44676
 
44676
44677
  window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var useCooldownTimer = function () {
44678
+ var _a;
44677
44679
  var latestMessageDatesByChannels = useChatContext('useCooldownTimer').latestMessageDatesByChannels;
44678
- var channel = useChannelStateContext('useCooldownTimer').channel;
44679
- var _a = (channel.data ||
44680
- {}), cooldownInterval = _a.cooldown, own_capabilities = _a.own_capabilities;
44681
- var _b = React$2.useState(), cooldownRemaining = _b[0], setCooldownRemaining = _b[1];
44680
+ var _b = useChannelStateContext('useCooldownTimer'), channel = _b.channel, _c = _b.messages, messages = _c === void 0 ? [] : _c;
44681
+ var client = useChatContext('useCooldownTimer').client;
44682
+ var _d = React$2.useState(), cooldownRemaining = _d[0], setCooldownRemaining = _d[1];
44683
+ var _e = (channel.data ||
44684
+ {}), cooldownInterval = _e.cooldown, own_capabilities = _e.own_capabilities;
44682
44685
  var skipCooldown = !(own_capabilities === null || own_capabilities === void 0 ? void 0 : own_capabilities.includes('slow-mode'));
44686
+ var ownLatestMessageDate = React$2.useMemo(function () {
44687
+ var _a, _b;
44688
+ return (_a = latestMessageDatesByChannels[channel.cid]) !== null && _a !== void 0 ? _a : (_b = __spreadArray([], messages, true).sort(function (a, b) { var _a, _b; return ((_a = b.created_at) === null || _a === void 0 ? void 0 : _a.getTime()) - ((_b = a.created_at) === null || _b === void 0 ? void 0 : _b.getTime()); })
44689
+ .find(function (v) { var _a, _b; return ((_a = v.user) === null || _a === void 0 ? void 0 : _a.id) === ((_b = client.user) === null || _b === void 0 ? void 0 : _b.id); })) === null || _b === void 0 ? void 0 : _b.created_at;
44690
+ }, [messages, (_a = client.user) === null || _a === void 0 ? void 0 : _a.id, latestMessageDatesByChannels, channel.cid]);
44683
44691
  React$2.useEffect(function () {
44684
- var latestMessageDate = latestMessageDatesByChannels[channel.cid];
44685
- if (!cooldownInterval || !latestMessageDate) {
44692
+ if (skipCooldown || !cooldownInterval || !ownLatestMessageDate)
44686
44693
  return;
44687
- }
44688
- var remainingCooldown = Math.round(cooldownInterval - (new Date().getTime() - latestMessageDate.getTime()) / 1000);
44689
- if (remainingCooldown > 0 && !skipCooldown) {
44694
+ var remainingCooldown = Math.round(cooldownInterval - (new Date().getTime() - ownLatestMessageDate.getTime()) / 1000);
44695
+ if (remainingCooldown > 0)
44690
44696
  setCooldownRemaining(remainingCooldown);
44691
- }
44692
- }, [channel.id, cooldownInterval, latestMessageDatesByChannels[channel.cid]]);
44697
+ }, [cooldownInterval, ownLatestMessageDate, skipCooldown]);
44693
44698
  return {
44694
- cooldownInterval: cooldownInterval || 0,
44699
+ cooldownInterval: cooldownInterval !== null && cooldownInterval !== void 0 ? cooldownInterval : 0,
44695
44700
  cooldownRemaining: cooldownRemaining,
44696
44701
  setCooldownRemaining: setCooldownRemaining,
44697
44702
  };
@@ -48127,7 +48132,7 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
48127
48132
 
48128
48133
  window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};
48129
48134
 
48130
- window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var version$1 = '10.4.1';
48135
+ window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var version$1 = '10.4.2';
48131
48136
 
48132
48137
  window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var useChat = function (_a) {
48133
48138
  var _b, _c;