stream-chat-react 10.8.4 → 10.8.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.
@@ -44997,27 +44997,27 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
44997
44997
 
44998
44998
  window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var useCooldownTimer = function () {
44999
44999
  var _a;
45000
- var latestMessageDatesByChannels = useChatContext('useCooldownTimer').latestMessageDatesByChannels;
45001
- var _b = useChannelStateContext('useCooldownTimer'), channel = _b.channel, _c = _b.messages, messages = _c === void 0 ? [] : _c;
45002
- var client = useChatContext('useCooldownTimer').client;
45003
- var _d = React$2.useState(), cooldownRemaining = _d[0], setCooldownRemaining = _d[1];
45004
- var _e = (channel.data ||
45005
- {}), cooldownInterval = _e.cooldown, own_capabilities = _e.own_capabilities;
45006
- var skipCooldown = !(own_capabilities === null || own_capabilities === void 0 ? void 0 : own_capabilities.includes('slow-mode'));
45000
+ var _b = useChatContext('useCooldownTimer'), client = _b.client, latestMessageDatesByChannels = _b.latestMessageDatesByChannels;
45001
+ var _c = useChannelStateContext('useCooldownTimer'), channel = _c.channel, _d = _c.messages, messages = _d === void 0 ? [] : _d;
45002
+ var _e = React$2.useState(), cooldownRemaining = _e[0], setCooldownRemaining = _e[1];
45003
+ var _f = (channel.data ||
45004
+ {}), _g = _f.cooldown, cooldownInterval = _g === void 0 ? 0 : _g, own_capabilities = _f.own_capabilities;
45005
+ var skipCooldown = own_capabilities === null || own_capabilities === void 0 ? void 0 : own_capabilities.includes('skip-slow-mode');
45007
45006
  var ownLatestMessageDate = React$2.useMemo(function () {
45008
45007
  var _a, _b;
45009
45008
  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()); })
45010
45009
  .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;
45011
45010
  }, [messages, (_a = client.user) === null || _a === void 0 ? void 0 : _a.id, latestMessageDatesByChannels, channel.cid]);
45012
45011
  React$2.useEffect(function () {
45013
- if (skipCooldown || !cooldownInterval || !ownLatestMessageDate)
45014
- return;
45015
- var remainingCooldown = Math.round(cooldownInterval - (new Date().getTime() - ownLatestMessageDate.getTime()) / 1000);
45016
- if (remainingCooldown > 0)
45017
- setCooldownRemaining(remainingCooldown);
45012
+ var timeSinceOwnLastMessage = ownLatestMessageDate
45013
+ ? (new Date().getTime() - ownLatestMessageDate.getTime()) / 1000
45014
+ : undefined;
45015
+ setCooldownRemaining(!skipCooldown && timeSinceOwnLastMessage && cooldownInterval > timeSinceOwnLastMessage
45016
+ ? Math.round(cooldownInterval - timeSinceOwnLastMessage)
45017
+ : 0);
45018
45018
  }, [cooldownInterval, ownLatestMessageDate, skipCooldown]);
45019
45019
  return {
45020
- cooldownInterval: cooldownInterval !== null && cooldownInterval !== void 0 ? cooldownInterval : 0,
45020
+ cooldownInterval: cooldownInterval,
45021
45021
  cooldownRemaining: cooldownRemaining,
45022
45022
  setCooldownRemaining: setCooldownRemaining,
45023
45023
  };
@@ -48513,7 +48513,7 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
48513
48513
 
48514
48514
  window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};
48515
48515
 
48516
- window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var version$1 = '10.8.4';
48516
+ window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var version$1 = '10.8.5';
48517
48517
 
48518
48518
  window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var useChat = function (_a) {
48519
48519
  var _b, _c;