stream-chat-react 9.5.1 → 9.5.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":"Attachment.d.ts","sourceRoot":"","sources":["../../../src/components/Attachment/Attachment.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAgB1B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,IAAI,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAElE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAEjF,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAEnE,oBAAY,eAAe,CACzB,kBAAkB,SAAS,yBAAyB,GAAG,yBAAyB,IAC9E;IACF,oJAAoJ;IACpJ,WAAW,EAAE,gBAAgB,CAAC,kBAAkB,CAAC,EAAE,CAAC;IACpD,wJAAwJ;IACxJ,aAAa,CAAC,EAAE,uBAAuB,CAAC;IACxC,oOAAoO;IACpO,iBAAiB,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,sBAAsB,CAAC,kBAAkB,CAAC,CAAC,CAAC;IACpF,kNAAkN;IAClN,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC,CAAC;IAC5D,8MAA8M;IAC9M,IAAI,CAAC,EA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;IACpJ,WAAW,EAAE,gBAAgB,CAAC,kBAAkB,CAAC,EAAE,CAAC;IACpD,wJAAwJ;IACxJ,aAAa,CAAC,EAAE,uBAAuB,CAAC;IACxC,oOAAoO;IACpO,iBAAiB,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,sBAAsB,CAAC,kBAAkB,CAAC,CAAC,CAAC;IACpF,kNAAkN;IAClN,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC,CAAC;IAC5D,8MAA8M;IAC9M,IAAI,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IACtC,wNAAwN;IACxN,IAAI,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,mBAAmB,CAAC,kBAAkB,CAAC,CAAC,CAAC;IACpE,8NAA8N;IAC9N,OAAO,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,YAAY,CAAC,kBAAkB,CAAC,CAAC,CAAC;IAChE,+MAA+M;IAC/M,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IACxC,gHAAgH;IAChH,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC;CAC/C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU,+IA2DtB,CAAC"}
@@ -44,7 +44,7 @@ export var Attachment = function (props) {
44
44
  })), [
45
45
  gallery,
46
46
  ]) : attachments;
47
- return (React.createElement(React.Fragment, null, newAttachments.map(function (attachment) {
47
+ var getContent = function (attachment) {
48
48
  if (isGalleryAttachmentType(attachment)) {
49
49
  return renderGallery(__assign(__assign({}, rest), { attachment: attachment }));
50
50
  }
@@ -61,5 +61,6 @@ export var Attachment = function (props) {
61
61
  return renderMedia(__assign(__assign({}, rest), { attachment: attachment }));
62
62
  }
63
63
  return renderCard(__assign(__assign({}, rest), { attachment: attachment }));
64
- })));
64
+ };
65
+ return (React.createElement(React.Fragment, null, newAttachments.map(function (attachment, i) { return (React.createElement(React.Fragment, { key: i }, getContent(attachment))); })));
65
66
  };
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/components/Attachment/utils.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAUjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAEnE,eAAO,MAAM,uBAAuB,UAA8D,CAAC;AAEnG,oBAAY,iBAAiB,CAC3B,kBAAkB,SAAS,yBAAyB,GAAG,yBAAyB,IAC9E;IACF,MAAM,EAAE,UAAU,CAAC,kBAAkB,CAAC,EAAE,CAAC;IACzC,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,oBAAY,wBAAwB,CAClC,kBAAkB,SAAS,yBAAyB,GAAG,yBAAyB,IAC9E;IACF,UAAU,EAAE,UAAU,CAAC,kBAAkB,CAAC,GAAG,iBAAiB,CAAC,kBAAkB,CAAC,CAAC;IACnF,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,oBAAY,qBAAqB,CAC/B,kBAAkB,SAAS,yBAAyB,GAAG,yBAAyB,IAC9E,IAAI,CAAC,eAAe,CAAC,kBAAkB,CAAC,EAAE,aAAa,CAAC,GAAG;IAC7D,UAAU,EAAE,UAAU,CAAC,kBAAkB,CAAC,CAAC;CAC5C,CAAC;AAEF,oBAAY,kBAAkB,CAC5B,kBAAkB,SAAS,yBAAyB,GAAG,yBAAyB,IAC9E,IAAI,CAAC,eAAe,CAAC,kBAAkB,CAAC,EAAE,aAAa,CAAC,GAAG;IAC7D,UAAU,EAAE,iBAAiB,CAAC,kBAAkB,CAAC,CAAC;CACnD,CAAC;AAEF,eAAO,MAAM,uBAA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AAY,qBAAqB,CAC/B,kBAAkB,SAAS,yBAAyB,GAAG,yBAAyB,IAC9E,IAAI,CAAC,eAAe,CAAC,kBAAkB,CAAC,EAAE,aAAa,CAAC,GAAG;IAC7D,UAAU,EAAE,UAAU,CAAC,kBAAkB,CAAC,CAAC;CAC5C,CAAC;AAEF,oBAAY,kBAAkB,CAC5B,kBAAkB,SAAS,yBAAyB,GAAG,yBAAyB,IAC9E,IAAI,CAAC,eAAe,CAAC,kBAAkB,CAAC,EAAE,aAAa,CAAC,GAAG;IAC7D,UAAU,EAAE,iBAAiB,CAAC,kBAAkB,CAAC,CAAC;CACnD,CAAC;AAEF,eAAO,MAAM,uBAAuB,uNAK8B,CAAC;AAEnE,eAAO,MAAM,iBAAiB,2IAIE,CAAC;AAEjC,eAAO,MAAM,gBAAgB,4JAQG,CAAC;AAEjC,eAAO,MAAM,iBAAiB,2IAIyD,CAAC;AAExF,eAAO,MAAM,iBAAiB,2IAMD,CAAC;AAE9B,eAAO,MAAM,+BAA+B,iLA2B3C,CAAC;AAEF,eAAO,MAAM,uBAAuB,4JAkBnC,CAAC;AAEF,eAAO,MAAM,aAAa,kJAYzB,CAAC;AAEF,eAAO,MAAM,WAAW,qJAyBvB,CAAC;AAEF,eAAO,MAAM,UAAU,qJAyBtB,CAAC;AAEF,eAAO,MAAM,UAAU,4JActB,CAAC;AAEF,eAAO,MAAM,WAAW,qJAgBvB,CAAC;AAEF,eAAO,MAAM,WAAW,qJA2CvB,CAAC"}
@@ -11,7 +11,6 @@ var __assign = (this && this.__assign) || function () {
11
11
  };
12
12
  import React from 'react';
13
13
  import ReactPlayer from 'react-player';
14
- import { nanoid } from 'nanoid';
15
14
  import { AttachmentActions as DefaultAttachmentActions } from './AttachmentActions';
16
15
  import { Audio as DefaultAudio } from './Audio';
17
16
  import { Card as DefaultCard } from './Card';
@@ -44,20 +43,20 @@ export var renderAttachmentWithinContainer = function (props) {
44
43
  ? 'actions'
45
44
  : '';
46
45
  }
47
- return (React.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, key: (isGalleryAttachmentType(attachment) ? '' : (attachment === null || attachment === void 0 ? void 0 : attachment.id) || nanoid()) + "-" + ((attachment === null || attachment === void 0 ? void 0 : attachment.type) || 'none') + " " }, children));
46
+ return (React.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));
48
47
  };
49
48
  export var renderAttachmentActions = function (props) {
50
49
  var _a;
51
50
  var actionHandler = props.actionHandler, attachment = props.attachment, _b = props.AttachmentActions, AttachmentActions = _b === void 0 ? DefaultAttachmentActions : _b;
52
51
  if (!((_a = attachment.actions) === null || _a === void 0 ? void 0 : _a.length))
53
52
  return null;
54
- return (React.createElement(AttachmentActions, __assign({}, attachment, { actionHandler: function (event, name, value) { return actionHandler === null || actionHandler === void 0 ? void 0 : actionHandler(event, name, value); }, actions: attachment.actions, id: attachment.id || '', key: "key-actions-" + attachment.id, text: attachment.text || '' })));
53
+ return (React.createElement(AttachmentActions, __assign({}, 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 || '' })));
55
54
  };
56
55
  export var renderGallery = function (props) {
57
56
  var attachment = props.attachment, _a = props.Gallery, Gallery = _a === void 0 ? DefaultGallery : _a;
58
57
  return renderAttachmentWithinContainer({
59
58
  attachment: attachment,
60
- children: React.createElement(Gallery, { images: attachment.images || [], key: 'gallery' }),
59
+ children: React.createElement(Gallery, { images: attachment.images || [] }),
61
60
  componentType: 'gallery',
62
61
  });
63
62
  };
@@ -66,7 +65,7 @@ export var renderImage = function (props) {
66
65
  if (attachment.actions && attachment.actions.length) {
67
66
  return renderAttachmentWithinContainer({
68
67
  attachment: attachment,
69
- children: (React.createElement("div", { className: 'str-chat__attachment', key: "key-image-" + attachment.id },
68
+ children: (React.createElement("div", { className: 'str-chat__attachment' },
70
69
  React.createElement(Image, __assign({}, attachment)),
71
70
  renderAttachmentActions(props))),
72
71
  componentType: 'image',
@@ -74,7 +73,7 @@ export var renderImage = function (props) {
74
73
  }
75
74
  return renderAttachmentWithinContainer({
76
75
  attachment: attachment,
77
- children: React.createElement(Image, __assign({}, attachment, { key: "key-image-" + attachment.id })),
76
+ children: React.createElement(Image, __assign({}, attachment)),
78
77
  componentType: 'image',
79
78
  });
80
79
  };
@@ -83,15 +82,15 @@ export var renderCard = function (props) {
83
82
  if (attachment.actions && attachment.actions.length) {
84
83
  return renderAttachmentWithinContainer({
85
84
  attachment: attachment,
86
- children: (React.createElement("div", { className: 'str-chat__attachment', key: "key-image-" + attachment.id },
87
- React.createElement(Card, __assign({}, attachment, { key: "key-card-" + attachment.id })),
85
+ children: (React.createElement("div", { className: 'str-chat__attachment' },
86
+ React.createElement(Card, __assign({}, attachment)),
88
87
  renderAttachmentActions(props))),
89
88
  componentType: 'card',
90
89
  });
91
90
  }
92
91
  return renderAttachmentWithinContainer({
93
92
  attachment: attachment,
94
- children: React.createElement(Card, __assign({}, attachment, { key: "key-card-" + attachment.id })),
93
+ children: React.createElement(Card, __assign({}, attachment)),
95
94
  componentType: 'card',
96
95
  });
97
96
  };
@@ -101,7 +100,7 @@ export var renderFile = function (props) {
101
100
  return null;
102
101
  return renderAttachmentWithinContainer({
103
102
  attachment: attachment,
104
- children: React.createElement(File, { attachment: attachment, key: "key-file-" + attachment.id }),
103
+ children: React.createElement(File, { attachment: attachment }),
105
104
  componentType: 'file',
106
105
  });
107
106
  };
@@ -109,7 +108,7 @@ export var renderAudio = function (props) {
109
108
  var attachment = props.attachment, _a = props.Audio, Audio = _a === void 0 ? DefaultAudio : _a;
110
109
  return renderAttachmentWithinContainer({
111
110
  attachment: attachment,
112
- children: (React.createElement("div", { className: 'str-chat__attachment', key: "key-video-" + attachment.id },
111
+ children: (React.createElement("div", { className: 'str-chat__attachment' },
113
112
  React.createElement(Audio, { og: attachment }))),
114
113
  componentType: 'audio',
115
114
  });
@@ -120,7 +119,7 @@ export var renderMedia = function (props) {
120
119
  if ((_a = attachment.actions) === null || _a === void 0 ? void 0 : _a.length) {
121
120
  return renderAttachmentWithinContainer({
122
121
  attachment: attachment,
123
- children: (React.createElement("div", { className: 'str-chat__attachment str-chat__attachment-media', key: "key-video-" + attachment.id },
122
+ children: (React.createElement("div", { className: 'str-chat__attachment str-chat__attachment-media' },
124
123
  React.createElement("div", { className: 'str-chat__player-wrapper' },
125
124
  React.createElement(Media, { className: 'react-player', controls: true, height: '100%', url: attachment.asset_url, width: '100%' })),
126
125
  renderAttachmentActions(props))),
@@ -129,7 +128,7 @@ export var renderMedia = function (props) {
129
128
  }
130
129
  return renderAttachmentWithinContainer({
131
130
  attachment: attachment,
132
- children: (React.createElement("div", { className: 'str-chat__player-wrapper', key: "key-video-" + attachment.id },
131
+ children: (React.createElement("div", { className: 'str-chat__player-wrapper' },
133
132
  React.createElement(Media, { className: 'react-player', controls: true, height: '100%', url: attachment.asset_url, width: '100%' }))),
134
133
  componentType: 'media',
135
134
  });
@@ -1 +1 @@
1
- {"version":3,"file":"usePrependMessagesCount.d.ts","sourceRoot":"","sources":["../../../../src/components/MessageList/hooks/usePrependMessagesCount.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAE1E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAEtE,wBAAgB,yBAAyB,CACvC,kBAAkB,SAAS,yBAAyB,GAAG,yBAAyB,EAChF,QAAQ,EAAE,aAAa,CAAC,kBAAkB,CAAC,EAAE,EAAE,gBAAgB,EAAE,OAAO,UAsCzE"}
1
+ {"version":3,"file":"usePrependMessagesCount.d.ts","sourceRoot":"","sources":["../../../../src/components/MessageList/hooks/usePrependMessagesCount.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAE1E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAEtE,wBAAgB,yBAAyB,CACvC,kBAAkB,SAAS,yBAAyB,GAAG,yBAAyB,EAChF,QAAQ,EAAE,aAAa,CAAC,kBAAkB,CAAC,EAAE,EAAE,gBAAgB,EAAE,OAAO,UAwCzE"}
@@ -1,15 +1,16 @@
1
1
  import { useMemo, useRef } from 'react';
2
2
  export function usePrependedMessagesCount(messages, hasDateSeparator) {
3
- var _a;
4
3
  var firstRealMessageIndex = hasDateSeparator ? 1 : 0;
5
- var currentFirstMessageId = (_a = messages === null || messages === void 0 ? void 0 : messages[firstRealMessageIndex]) === null || _a === void 0 ? void 0 : _a.id;
6
- var firstMessageId = useRef(currentFirstMessageId);
7
- var earliestMessageId = useRef(currentFirstMessageId);
4
+ var firstMessageId = useRef();
5
+ var earliestMessageId = useRef();
8
6
  var previousNumItemsPrepended = useRef(0);
9
7
  var numItemsPrepended = useMemo(function () {
8
+ var _a;
10
9
  if (!messages || !messages.length) {
10
+ previousNumItemsPrepended.current = 0;
11
11
  return 0;
12
12
  }
13
+ var currentFirstMessageId = (_a = messages === null || messages === void 0 ? void 0 : messages[firstRealMessageIndex]) === null || _a === void 0 ? void 0 : _a.id;
13
14
  // if no new messages were prepended, return early (same amount as before)
14
15
  if (currentFirstMessageId === earliestMessageId.current) {
15
16
  return previousNumItemsPrepended.current;
@@ -26,8 +27,9 @@ export function usePrependedMessagesCount(messages, hasDateSeparator) {
26
27
  return i;
27
28
  }
28
29
  }
29
- // if no match has found, we have jumped
30
+ // if no match has found, we have jumped - reset the prepend item count.
30
31
  firstMessageId.current = currentFirstMessageId;
32
+ previousNumItemsPrepended.current = 0;
31
33
  return 0;
32
34
  // TODO: there's a bug here, the messages prop is the same array instance (something mutates it)
33
35
  // that's why the second dependency is necessary
package/dist/index.cjs.js CHANGED
@@ -4,7 +4,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var React = require('react');
6
6
  var ReactPlayer = require('react-player');
7
- var nanoid = require('nanoid');
8
7
  var sanitizeUrl = require('@braintree/sanitize-url');
9
8
  var Dayjs = require('dayjs');
10
9
  var calendar = require('dayjs/plugin/calendar');
@@ -32,6 +31,7 @@ var _defineProperty = require('@babel/runtime/helpers/defineProperty');
32
31
  var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
33
32
  var emojiRegex = require('emoji-regex');
34
33
  var linkify = require('linkifyjs');
34
+ var nanoid = require('nanoid');
35
35
  var RootReactMarkdown = require('react-markdown');
36
36
  var ReactMarkdown = require('react-markdown/with-html');
37
37
  var uniqBy = require('lodash.uniqby');
@@ -1148,20 +1148,20 @@ var renderAttachmentWithinContainer = function (props) {
1148
1148
  ? 'actions'
1149
1149
  : '';
1150
1150
  }
1151
- 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, key: (isGalleryAttachmentType(attachment) ? '' : (attachment === null || attachment === void 0 ? void 0 : attachment.id) || nanoid.nanoid()) + "-" + ((attachment === null || attachment === void 0 ? void 0 : attachment.type) || 'none') + " " }, children));
1151
+ 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));
1152
1152
  };
1153
1153
  var renderAttachmentActions = function (props) {
1154
1154
  var _a;
1155
1155
  var actionHandler = props.actionHandler, attachment = props.attachment, _b = props.AttachmentActions, AttachmentActions$1 = _b === void 0 ? AttachmentActions : _b;
1156
1156
  if (!((_a = attachment.actions) === null || _a === void 0 ? void 0 : _a.length))
1157
1157
  return null;
1158
- return (React__default['default'].createElement(AttachmentActions$1, __assign({}, attachment, { actionHandler: function (event, name, value) { return actionHandler === null || actionHandler === void 0 ? void 0 : actionHandler(event, name, value); }, actions: attachment.actions, id: attachment.id || '', key: "key-actions-" + attachment.id, text: attachment.text || '' })));
1158
+ return (React__default['default'].createElement(AttachmentActions$1, __assign({}, 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 || '' })));
1159
1159
  };
1160
1160
  var renderGallery = function (props) {
1161
1161
  var attachment = props.attachment, _a = props.Gallery, Gallery$1 = _a === void 0 ? Gallery : _a;
1162
1162
  return renderAttachmentWithinContainer({
1163
1163
  attachment: attachment,
1164
- children: React__default['default'].createElement(Gallery$1, { images: attachment.images || [], key: 'gallery' }),
1164
+ children: React__default['default'].createElement(Gallery$1, { images: attachment.images || [] }),
1165
1165
  componentType: 'gallery',
1166
1166
  });
1167
1167
  };
@@ -1170,7 +1170,7 @@ var renderImage = function (props) {
1170
1170
  if (attachment.actions && attachment.actions.length) {
1171
1171
  return renderAttachmentWithinContainer({
1172
1172
  attachment: attachment,
1173
- children: (React__default['default'].createElement("div", { className: 'str-chat__attachment', key: "key-image-" + attachment.id },
1173
+ children: (React__default['default'].createElement("div", { className: 'str-chat__attachment' },
1174
1174
  React__default['default'].createElement(Image, __assign({}, attachment)),
1175
1175
  renderAttachmentActions(props))),
1176
1176
  componentType: 'image',
@@ -1178,7 +1178,7 @@ var renderImage = function (props) {
1178
1178
  }
1179
1179
  return renderAttachmentWithinContainer({
1180
1180
  attachment: attachment,
1181
- children: React__default['default'].createElement(Image, __assign({}, attachment, { key: "key-image-" + attachment.id })),
1181
+ children: React__default['default'].createElement(Image, __assign({}, attachment)),
1182
1182
  componentType: 'image',
1183
1183
  });
1184
1184
  };
@@ -1187,15 +1187,15 @@ var renderCard = function (props) {
1187
1187
  if (attachment.actions && attachment.actions.length) {
1188
1188
  return renderAttachmentWithinContainer({
1189
1189
  attachment: attachment,
1190
- children: (React__default['default'].createElement("div", { className: 'str-chat__attachment', key: "key-image-" + attachment.id },
1191
- React__default['default'].createElement(Card$1, __assign({}, attachment, { key: "key-card-" + attachment.id })),
1190
+ children: (React__default['default'].createElement("div", { className: 'str-chat__attachment' },
1191
+ React__default['default'].createElement(Card$1, __assign({}, attachment)),
1192
1192
  renderAttachmentActions(props))),
1193
1193
  componentType: 'card',
1194
1194
  });
1195
1195
  }
1196
1196
  return renderAttachmentWithinContainer({
1197
1197
  attachment: attachment,
1198
- children: React__default['default'].createElement(Card$1, __assign({}, attachment, { key: "key-card-" + attachment.id })),
1198
+ children: React__default['default'].createElement(Card$1, __assign({}, attachment)),
1199
1199
  componentType: 'card',
1200
1200
  });
1201
1201
  };
@@ -1205,7 +1205,7 @@ var renderFile = function (props) {
1205
1205
  return null;
1206
1206
  return renderAttachmentWithinContainer({
1207
1207
  attachment: attachment,
1208
- children: React__default['default'].createElement(File, { attachment: attachment, key: "key-file-" + attachment.id }),
1208
+ children: React__default['default'].createElement(File, { attachment: attachment }),
1209
1209
  componentType: 'file',
1210
1210
  });
1211
1211
  };
@@ -1213,7 +1213,7 @@ var renderAudio = function (props) {
1213
1213
  var attachment = props.attachment, _a = props.Audio, Audio$1 = _a === void 0 ? Audio : _a;
1214
1214
  return renderAttachmentWithinContainer({
1215
1215
  attachment: attachment,
1216
- children: (React__default['default'].createElement("div", { className: 'str-chat__attachment', key: "key-video-" + attachment.id },
1216
+ children: (React__default['default'].createElement("div", { className: 'str-chat__attachment' },
1217
1217
  React__default['default'].createElement(Audio$1, { og: attachment }))),
1218
1218
  componentType: 'audio',
1219
1219
  });
@@ -1224,7 +1224,7 @@ var renderMedia = function (props) {
1224
1224
  if ((_a = attachment.actions) === null || _a === void 0 ? void 0 : _a.length) {
1225
1225
  return renderAttachmentWithinContainer({
1226
1226
  attachment: attachment,
1227
- children: (React__default['default'].createElement("div", { className: 'str-chat__attachment str-chat__attachment-media', key: "key-video-" + attachment.id },
1227
+ children: (React__default['default'].createElement("div", { className: 'str-chat__attachment str-chat__attachment-media' },
1228
1228
  React__default['default'].createElement("div", { className: 'str-chat__player-wrapper' },
1229
1229
  React__default['default'].createElement(Media, { className: 'react-player', controls: true, height: '100%', url: attachment.asset_url, width: '100%' })),
1230
1230
  renderAttachmentActions(props))),
@@ -1233,7 +1233,7 @@ var renderMedia = function (props) {
1233
1233
  }
1234
1234
  return renderAttachmentWithinContainer({
1235
1235
  attachment: attachment,
1236
- children: (React__default['default'].createElement("div", { className: 'str-chat__player-wrapper', key: "key-video-" + attachment.id },
1236
+ children: (React__default['default'].createElement("div", { className: 'str-chat__player-wrapper' },
1237
1237
  React__default['default'].createElement(Media, { className: 'react-player', controls: true, height: '100%', url: attachment.asset_url, width: '100%' }))),
1238
1238
  componentType: 'media',
1239
1239
  });
@@ -1256,7 +1256,7 @@ var Attachment = function (props) {
1256
1256
  })), [
1257
1257
  gallery,
1258
1258
  ]) : attachments;
1259
- return (React__default['default'].createElement(React__default['default'].Fragment, null, newAttachments.map(function (attachment) {
1259
+ var getContent = function (attachment) {
1260
1260
  if (isGalleryAttachmentType(attachment)) {
1261
1261
  return renderGallery(__assign(__assign({}, rest), { attachment: attachment }));
1262
1262
  }
@@ -1273,7 +1273,8 @@ var Attachment = function (props) {
1273
1273
  return renderMedia(__assign(__assign({}, rest), { attachment: attachment }));
1274
1274
  }
1275
1275
  return renderCard(__assign(__assign({}, rest), { attachment: attachment }));
1276
- })));
1276
+ };
1277
+ 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))); })));
1277
1278
  };
1278
1279
 
1279
1280
  var Item = /*#__PURE__*/React__default['default'].forwardRef(function Item(props, innerRef) {
@@ -8396,7 +8397,7 @@ var UnMemoizedChannelList = function (props) {
8396
8397
  */
8397
8398
  var ChannelList = React__default['default'].memo(UnMemoizedChannelList);
8398
8399
 
8399
- var version = '9.5.1';
8400
+ var version = '9.5.2';
8400
8401
 
8401
8402
  var useChat = function (_a) {
8402
8403
  var _b, _c;
@@ -9816,16 +9817,17 @@ function useNewMessageNotification(messages, currentUserId, hasMoreNewer) {
9816
9817
  }
9817
9818
 
9818
9819
  function usePrependedMessagesCount(messages, hasDateSeparator) {
9819
- var _a;
9820
9820
  var firstRealMessageIndex = hasDateSeparator ? 1 : 0;
9821
- var currentFirstMessageId = (_a = messages === null || messages === void 0 ? void 0 : messages[firstRealMessageIndex]) === null || _a === void 0 ? void 0 : _a.id;
9822
- var firstMessageId = React.useRef(currentFirstMessageId);
9823
- var earliestMessageId = React.useRef(currentFirstMessageId);
9821
+ var firstMessageId = React.useRef();
9822
+ var earliestMessageId = React.useRef();
9824
9823
  var previousNumItemsPrepended = React.useRef(0);
9825
9824
  var numItemsPrepended = React.useMemo(function () {
9825
+ var _a;
9826
9826
  if (!messages || !messages.length) {
9827
+ previousNumItemsPrepended.current = 0;
9827
9828
  return 0;
9828
9829
  }
9830
+ var currentFirstMessageId = (_a = messages === null || messages === void 0 ? void 0 : messages[firstRealMessageIndex]) === null || _a === void 0 ? void 0 : _a.id;
9829
9831
  // if no new messages were prepended, return early (same amount as before)
9830
9832
  if (currentFirstMessageId === earliestMessageId.current) {
9831
9833
  return previousNumItemsPrepended.current;
@@ -9842,8 +9844,9 @@ function usePrependedMessagesCount(messages, hasDateSeparator) {
9842
9844
  return i;
9843
9845
  }
9844
9846
  }
9845
- // if no match has found, we have jumped
9847
+ // if no match has found, we have jumped - reset the prepend item count.
9846
9848
  firstMessageId.current = currentFirstMessageId;
9849
+ previousNumItemsPrepended.current = 0;
9847
9850
  return 0;
9848
9851
  // TODO: there's a bug here, the messages prop is the same array instance (something mutates it)
9849
9852
  // that's why the second dependency is necessary