stream-chat-react 10.4.0 → 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.
@@ -1 +1 @@
1
- {"version":3,"file":"AttachmentContainer.d.ts","sourceRoot":"","sources":["../../../src/components/Attachment/AttachmentContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,iBAAiB,EAAqC,MAAM,OAAO,CAAC;AASpF,OAAO,EACL,wBAAwB,EAGxB,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,SAAS,CAAC;AAIjB,OAAO,KAAK,EACV,yBAAyB,EAG1B,MAAM,mBAAmB,CAAC;AAE3B,eAAO,MAAM,yBAAyB,oNA+BrC,CAAC;AAEF,eAAO,MAAM,0BAA0B,wMAkBtC,CAAC;AAoBF,eAAO,MAAM,gBAAgB,qKAwC5B,CAAC;AAEF,eAAO,MAAM,cAAc,qJA0C1B,CAAC;AAEF,eAAO,MAAM,aAAa,qJAwBzB,CAAC;AAEF,eAAO,MAAM,aAAa,4KAazB,CAAC;AACF,eAAO,MAAM,cAAc,sKAW1B,CAAC;AAEF,eAAO,MAAM,cAAc,qJAuD1B,CAAC"}
1
+ {"version":3,"file":"AttachmentContainer.d.ts","sourceRoot":"","sources":["../../../src/components/Attachment/AttachmentContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,iBAAiB,EAAqC,MAAM,OAAO,CAAC;AAWpF,OAAO,EACL,wBAAwB,EAGxB,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,SAAS,CAAC;AAIjB,OAAO,KAAK,EACV,yBAAyB,EAG1B,MAAM,mBAAmB,CAAC;AAE3B,eAAO,MAAM,yBAAyB,oNA+BrC,CAAC;AAEF,eAAO,MAAM,0BAA0B,wMAkBtC,CAAC;AAqBF,eAAO,MAAM,gBAAgB,qKAwC5B,CAAC;AAEF,eAAO,MAAM,cAAc,qJA0C1B,CAAC;AAEF,eAAO,MAAM,aAAa,qJAwBzB,CAAC;AAEF,eAAO,MAAM,aAAa,4KAazB,CAAC;AACF,eAAO,MAAM,cAAc,sKAW1B,CAAC;AAEF,eAAO,MAAM,cAAc,qJAuD1B,CAAC"}
@@ -12,6 +12,7 @@ var __assign = (this && this.__assign) || function () {
12
12
  import React, { useLayoutEffect, useRef, useState } from 'react';
13
13
  import ReactPlayer from 'react-player';
14
14
  import clsx from 'clsx';
15
+ import * as linkify from 'linkifyjs';
15
16
  import { AttachmentActions as DefaultAttachmentActions } from './AttachmentActions';
16
17
  import { Audio as DefaultAudio } from './Audio';
17
18
  import { Gallery as DefaultGallery, ImageComponent as DefaultImage } from '../Gallery';
@@ -50,12 +51,11 @@ export var AttachmentActionsContainer = function (_a) {
50
51
  return (React.createElement(AttachmentActions, __assign({}, attachment, { actionHandler: actionHandler, actions: attachment.actions, id: attachment.id || '', text: attachment.text || '' })));
51
52
  };
52
53
  function getCssDimensionsVariables(url) {
53
- var _a;
54
- var cssVars = (_a = {},
55
- _a['--original-height'] = 1000000,
56
- _a['--original-width'] = 1000000,
57
- _a);
58
- if (url) {
54
+ var cssVars = {
55
+ '--original-height': 1000000,
56
+ '--original-width': 1000000,
57
+ };
58
+ if (linkify.test(url, 'url')) {
59
59
  var urlParams = new URL(url).searchParams;
60
60
  var oh = Number(urlParams.get('oh'));
61
61
  var ow = Number(urlParams.get('ow'));
@@ -1 +1 @@
1
- {"version":3,"file":"attachment-sizing.d.ts","sourceRoot":"","sources":["../../../src/components/Attachment/attachment-sizing.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,eAAO,MAAM,+BAA+B,eAAgB,UAAU,WAAW,WAAW;;CAc3F,CAAC;AAEF,eAAO,MAAM,+BAA+B,eAC9B,UAAU,WACb,WAAW,gCACU,OAAO;;;CAoBtC,CAAC"}
1
+ {"version":3,"file":"attachment-sizing.d.ts","sourceRoot":"","sources":["../../../src/components/Attachment/attachment-sizing.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG9C,eAAO,MAAM,+BAA+B,eAAgB,UAAU,WAAW,WAAW;;CAqB3F,CAAC;AAEF,eAAO,MAAM,+BAA+B,eAC9B,UAAU,WACb,WAAW,gCACU,OAAO;;;CAwBtC,CAAC"}
@@ -1,19 +1,27 @@
1
+ import * as linkify from 'linkifyjs';
1
2
  export var getImageAttachmentConfiguration = function (attachment, element) {
2
- var url = new URL((attachment.image_url || attachment.thumb_url || ''));
3
- var resizeDimensions = getSizingRestrictions(url, element);
4
- if (resizeDimensions) {
5
- // Apply 2x for retina displays
6
- resizeDimensions.height *= 2;
7
- resizeDimensions.width *= 2;
8
- addResizingParamsToUrl(resizeDimensions, url);
3
+ var newUrl = undefined;
4
+ var urlToTest = attachment.image_url || attachment.thumb_url || '';
5
+ if (linkify.test(urlToTest, 'url')) {
6
+ var url = new URL(urlToTest);
7
+ var resizeDimensions = getSizingRestrictions(url, element);
8
+ if (resizeDimensions) {
9
+ // Apply 2x for retina displays
10
+ resizeDimensions.height *= 2;
11
+ resizeDimensions.width *= 2;
12
+ addResizingParamsToUrl(resizeDimensions, url);
13
+ }
14
+ newUrl = url.href;
9
15
  }
10
16
  return {
11
- url: url.href,
17
+ url: newUrl || '',
12
18
  };
13
19
  };
14
20
  export var getVideoAttachmentConfiguration = function (attachment, element, shouldGenerateVideoThumbnail) {
15
21
  var thumbUrl = undefined;
16
- if (attachment.thumb_url && shouldGenerateVideoThumbnail) {
22
+ if (attachment.thumb_url &&
23
+ shouldGenerateVideoThumbnail &&
24
+ linkify.test(attachment.thumb_url, 'url')) {
17
25
  var url = new URL(attachment.thumb_url);
18
26
  var resizeDimensions = getSizingRestrictions(url, element);
19
27
  if (resizeDimensions) {
@@ -1 +1 @@
1
- {"version":3,"file":"useCooldownTimer.d.ts","sourceRoot":"","sources":["../../../../src/components/MessageInput/hooks/useCooldownTimer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAOnD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAEtE,oBAAY,kBAAkB,GAAG;IAC/B,gBAAgB,EAAE,MAAM,CAAC;IACzB,oBAAoB,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;IAC/E,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,gBAAgB,0FAExB,kBA6BJ,CAAC"}
1
+ {"version":3,"file":"useCooldownTimer.d.ts","sourceRoot":"","sources":["../../../../src/components/MessageInput/hooks/useCooldownTimer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAO5D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAEtE,oBAAY,kBAAkB,GAAG;IAC/B,gBAAgB,EAAE,MAAM,CAAC;IACzB,oBAAoB,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;IAC/E,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,gBAAgB,0FAExB,kBAmCJ,CAAC"}
@@ -1,25 +1,38 @@
1
- import { useEffect, useState } from 'react';
1
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
2
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
3
+ if (ar || !(i in from)) {
4
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
5
+ ar[i] = from[i];
6
+ }
7
+ }
8
+ return to.concat(ar || Array.prototype.slice.call(from));
9
+ };
10
+ import { useEffect, useMemo, useState } from 'react';
2
11
  import { useChatContext } from '../../../context/ChatContext';
3
12
  import { useChannelStateContext } from '../../../context/ChannelStateContext';
4
13
  export var useCooldownTimer = function () {
14
+ var _a;
5
15
  var latestMessageDatesByChannels = useChatContext('useCooldownTimer').latestMessageDatesByChannels;
6
- var channel = useChannelStateContext('useCooldownTimer').channel;
7
- var _a = (channel.data ||
8
- {}), cooldownInterval = _a.cooldown, own_capabilities = _a.own_capabilities;
9
- var _b = useState(), cooldownRemaining = _b[0], setCooldownRemaining = _b[1];
16
+ var _b = useChannelStateContext('useCooldownTimer'), channel = _b.channel, _c = _b.messages, messages = _c === void 0 ? [] : _c;
17
+ var client = useChatContext('useCooldownTimer').client;
18
+ var _d = useState(), cooldownRemaining = _d[0], setCooldownRemaining = _d[1];
19
+ var _e = (channel.data ||
20
+ {}), cooldownInterval = _e.cooldown, own_capabilities = _e.own_capabilities;
10
21
  var skipCooldown = !(own_capabilities === null || own_capabilities === void 0 ? void 0 : own_capabilities.includes('slow-mode'));
22
+ var ownLatestMessageDate = useMemo(function () {
23
+ var _a, _b;
24
+ 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()); })
25
+ .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;
26
+ }, [messages, (_a = client.user) === null || _a === void 0 ? void 0 : _a.id, latestMessageDatesByChannels, channel.cid]);
11
27
  useEffect(function () {
12
- var latestMessageDate = latestMessageDatesByChannels[channel.cid];
13
- if (!cooldownInterval || !latestMessageDate) {
28
+ if (skipCooldown || !cooldownInterval || !ownLatestMessageDate)
14
29
  return;
15
- }
16
- var remainingCooldown = Math.round(cooldownInterval - (new Date().getTime() - latestMessageDate.getTime()) / 1000);
17
- if (remainingCooldown > 0 && !skipCooldown) {
30
+ var remainingCooldown = Math.round(cooldownInterval - (new Date().getTime() - ownLatestMessageDate.getTime()) / 1000);
31
+ if (remainingCooldown > 0)
18
32
  setCooldownRemaining(remainingCooldown);
19
- }
20
- }, [channel.id, cooldownInterval, latestMessageDatesByChannels[channel.cid]]);
33
+ }, [cooldownInterval, ownLatestMessageDate, skipCooldown]);
21
34
  return {
22
- cooldownInterval: cooldownInterval || 0,
35
+ cooldownInterval: cooldownInterval !== null && cooldownInterval !== void 0 ? cooldownInterval : 0,
23
36
  cooldownRemaining: cooldownRemaining,
24
37
  setCooldownRemaining: setCooldownRemaining,
25
38
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useUserTrigger.d.ts","sourceRoot":"","sources":["../../../../src/components/MessageInput/hooks/useUserTrigger.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4CAA4C,CAAC;AACpF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAEpF,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAEtE,oBAAY,iBAAiB,CAC3B,kBAAkB,SAAS,yBAAyB,GAAG,yBAAyB,IAC9E;IACF,YAAY,EAAE,CAAC,IAAI,EAAE,YAAY,CAAC,kBAAkB,CAAC,KAAK,IAAI,CAAC;IAC/D,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,kBAAkB,CAAC,EAAE,iBAAiB,CAAC,kBAAkB,CAAC,CAAC,aAAa,CAAC,CAAC;IAC1E,0BAA0B,CAAC,EAAE,OAAO,CAAC;CACtC,CAAC;AAEF,eAAO,MAAM,cAAc,6KAgK1B,CAAC"}
1
+ {"version":3,"file":"useUserTrigger.d.ts","sourceRoot":"","sources":["../../../../src/components/MessageInput/hooks/useUserTrigger.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4CAA4C,CAAC;AACpF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAEpF,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAEtE,oBAAY,iBAAiB,CAC3B,kBAAkB,SAAS,yBAAyB,GAAG,yBAAyB,IAC9E;IACF,YAAY,EAAE,CAAC,IAAI,EAAE,YAAY,CAAC,kBAAkB,CAAC,KAAK,IAAI,CAAC;IAC/D,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,kBAAkB,CAAC,EAAE,iBAAiB,CAAC,kBAAkB,CAAC,CAAC,aAAa,CAAC,CAAC;IAC1E,0BAA0B,CAAC,EAAE,OAAO,CAAC;CACtC,CAAC;AAEF,eAAO,MAAM,cAAc,6KAkK1B,CAAC"}
@@ -121,7 +121,8 @@ export var useUserTrigger = function (params) {
121
121
  _a.label = 1;
122
122
  case 1:
123
123
  _a.trys.push([1, 3, , 4]);
124
- return [4 /*yield*/, client.queryUsers(__assign({ $or: [{ id: { $autocomplete: query } }, { name: { $autocomplete: query } }], id: { $ne: client.userID } }, mentionQueryParams.filters), __assign({ id: 1 }, mentionQueryParams.sort), __assign({ limit: 10 }, mentionQueryParams.options))];
124
+ return [4 /*yield*/, client.queryUsers(__assign({ $or: [{ id: { $autocomplete: query } }, { name: { $autocomplete: query } }], id: { $ne: client.userID } }, mentionQueryParams.filters), Array.isArray(mentionQueryParams.sort)
125
+ ? __spreadArray([{ id: 1 }], mentionQueryParams.sort, true) : __assign({ id: 1 }, mentionQueryParams.sort), __assign({ limit: 10 }, mentionQueryParams.options))];
125
126
  case 2:
126
127
  users = (_a.sent()).users;
127
128
  if (onReady && users.length) {