stream-chat-react 9.5.1 → 9.5.3

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":"Channel.d.ts","sourceRoot":"","sources":["../../../src/components/Channel/Channel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EACZ,iBAAiB,EAOlB,MAAM,OAAO,CAAC;AAIf,OAAO,EAKL,OAAO,EACP,eAAe,EAEf,OAAO,IAAI,aAAa,EACxB,UAAU,EACV,cAAc,EAEf,MAAM,aAAa,CAAC;AASrB,OAAO,EAAE,eAAe,EAAuB,MAAM,6BAA6B,CAAC;AAGnF,OAAO,EAGL,0BAA0B,EAC3B,MAAM,YAAY,CAAC;AAcpB,OAAO,EAAE,qBAAqB,EAAqB,MAAM,gCAAgC,CAAC;AAE1F,OAAO,EAAe,iB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AC,kBAAkB,CAAC,CAAC,iBAAiB,CAAC,CAAC;IAC/E,sPAAsP;IACtP,cAAc,CAAC,EAAE,qBAAqB,CAAC,kBAAkB,CAAC,CAAC,gBAAgB,CAAC,CAAC;CAC9E,CAAC;AAquBF;;;;;;;;GAQG;AACH,eAAO,MAAM,OAAO,wNAA4D,CAAC"}
@@ -409,9 +409,10 @@ var ChannelInner = function (props) {
409
409
  };
410
410
  var isUserResponseArray = function (output) { var _a; return ((_a = output[0]) === null || _a === void 0 ? void 0 : _a.id) != null; };
411
411
  var doSendMessage = function (message, customMessageData) { return __awaiter(void 0, void 0, void 0, function () {
412
- var attachments, id, _a, mentioned_users, parent_id, text, mentions, messageData, messageResponse, error_1, stringError, parsedError;
413
- return __generator(this, function (_b) {
414
- switch (_b.label) {
412
+ var attachments, id, _a, mentioned_users, parent_id, text, mentions, messageData, messageResponse, existingMessage, i, msg, responseTimestamp, existingMessageTimestamp, responseIsTheNewest, error_1, stringError, parsedError;
413
+ var _b, _c;
414
+ return __generator(this, function (_d) {
415
+ switch (_d.label) {
415
416
  case 0:
416
417
  attachments = message.attachments, id = message.id, _a = message.mentioned_users, mentioned_users = _a === void 0 ? [] : _a, parent_id = message.parent_id, text = message.text;
417
418
  mentions = isUserResponseArray(mentioned_users)
@@ -421,29 +422,43 @@ var ChannelInner = function (props) {
421
422
  })
422
423
  : mentioned_users;
423
424
  messageData = __assign({ 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);
424
- _b.label = 1;
425
+ _d.label = 1;
425
426
  case 1:
426
- _b.trys.push([1, 6, , 7]);
427
+ _d.trys.push([1, 6, , 7]);
427
428
  messageResponse = void 0;
428
429
  if (!doSendMessageRequest) return [3 /*break*/, 3];
429
430
  return [4 /*yield*/, doSendMessageRequest(channel.cid, messageData)];
430
431
  case 2:
431
- messageResponse = _b.sent();
432
+ messageResponse = _d.sent();
432
433
  return [3 /*break*/, 5];
433
434
  case 3: return [4 /*yield*/, channel.sendMessage(messageData)];
434
435
  case 4:
435
- messageResponse = _b.sent();
436
- _b.label = 5;
436
+ messageResponse = _d.sent();
437
+ _d.label = 5;
437
438
  case 5:
438
- // replace it after send is completed
439
- if (messageResponse === null || messageResponse === void 0 ? void 0 : messageResponse.message) {
439
+ existingMessage = void 0;
440
+ for (i = channel.state.messages.length - 1; i >= 0; i--) {
441
+ msg = channel.state.messages[i];
442
+ if (msg.id === messageData.id) {
443
+ existingMessage = msg;
444
+ break;
445
+ }
446
+ }
447
+ responseTimestamp = new Date(((_b = messageResponse === null || messageResponse === void 0 ? void 0 : messageResponse.message) === null || _b === void 0 ? void 0 : _b.updated_at) || 0).getTime();
448
+ existingMessageTimestamp = ((_c = existingMessage === null || existingMessage === void 0 ? void 0 : existingMessage.updated_at) === null || _c === void 0 ? void 0 : _c.getTime()) || 0;
449
+ responseIsTheNewest = responseTimestamp > existingMessageTimestamp;
450
+ // Replace the message payload after send is completed
451
+ // 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.
452
+ // Always override existing message in status "sending"
453
+ if ((messageResponse === null || messageResponse === void 0 ? void 0 : messageResponse.message) &&
454
+ (responseIsTheNewest || (existingMessage === null || existingMessage === void 0 ? void 0 : existingMessage.status) === 'sending')) {
440
455
  updateMessage(__assign(__assign({}, messageResponse.message), { status: 'received' }));
441
456
  }
442
457
  if (quotedMessage && parent_id === (quotedMessage === null || quotedMessage === void 0 ? void 0 : quotedMessage.parent_id))
443
458
  setQuotedMessage(undefined);
444
459
  return [3 /*break*/, 7];
445
460
  case 6:
446
- error_1 = _b.sent();
461
+ error_1 = _d.sent();
447
462
  stringError = JSON.stringify(error_1);
448
463
  parsedError = stringError ? JSON.parse(stringError) : {};
449
464
  updateMessage(__assign(__assign({}, message), { error: parsedError, errorStatusCode: parsedError.status || undefined, status: 'failed' }));
@@ -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) {
@@ -7210,9 +7211,10 @@ var ChannelInner = function (props) {
7210
7211
  };
7211
7212
  var isUserResponseArray = function (output) { var _a; return ((_a = output[0]) === null || _a === void 0 ? void 0 : _a.id) != null; };
7212
7213
  var doSendMessage = function (message, customMessageData) { return __awaiter(void 0, void 0, void 0, function () {
7213
- var attachments, id, _a, mentioned_users, parent_id, text, mentions, messageData, messageResponse, error_1, stringError, parsedError;
7214
- return __generator(this, function (_b) {
7215
- switch (_b.label) {
7214
+ var attachments, id, _a, mentioned_users, parent_id, text, mentions, messageData, messageResponse, existingMessage, i, msg, responseTimestamp, existingMessageTimestamp, responseIsTheNewest, error_1, stringError, parsedError;
7215
+ var _b, _c;
7216
+ return __generator(this, function (_d) {
7217
+ switch (_d.label) {
7216
7218
  case 0:
7217
7219
  attachments = message.attachments, id = message.id, _a = message.mentioned_users, mentioned_users = _a === void 0 ? [] : _a, parent_id = message.parent_id, text = message.text;
7218
7220
  mentions = isUserResponseArray(mentioned_users)
@@ -7222,29 +7224,43 @@ var ChannelInner = function (props) {
7222
7224
  })
7223
7225
  : mentioned_users;
7224
7226
  messageData = __assign({ 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);
7225
- _b.label = 1;
7227
+ _d.label = 1;
7226
7228
  case 1:
7227
- _b.trys.push([1, 6, , 7]);
7229
+ _d.trys.push([1, 6, , 7]);
7228
7230
  messageResponse = void 0;
7229
7231
  if (!doSendMessageRequest) return [3 /*break*/, 3];
7230
7232
  return [4 /*yield*/, doSendMessageRequest(channel.cid, messageData)];
7231
7233
  case 2:
7232
- messageResponse = _b.sent();
7234
+ messageResponse = _d.sent();
7233
7235
  return [3 /*break*/, 5];
7234
7236
  case 3: return [4 /*yield*/, channel.sendMessage(messageData)];
7235
7237
  case 4:
7236
- messageResponse = _b.sent();
7237
- _b.label = 5;
7238
+ messageResponse = _d.sent();
7239
+ _d.label = 5;
7238
7240
  case 5:
7239
- // replace it after send is completed
7240
- if (messageResponse === null || messageResponse === void 0 ? void 0 : messageResponse.message) {
7241
+ existingMessage = void 0;
7242
+ for (i = channel.state.messages.length - 1; i >= 0; i--) {
7243
+ msg = channel.state.messages[i];
7244
+ if (msg.id === messageData.id) {
7245
+ existingMessage = msg;
7246
+ break;
7247
+ }
7248
+ }
7249
+ responseTimestamp = new Date(((_b = messageResponse === null || messageResponse === void 0 ? void 0 : messageResponse.message) === null || _b === void 0 ? void 0 : _b.updated_at) || 0).getTime();
7250
+ existingMessageTimestamp = ((_c = existingMessage === null || existingMessage === void 0 ? void 0 : existingMessage.updated_at) === null || _c === void 0 ? void 0 : _c.getTime()) || 0;
7251
+ responseIsTheNewest = responseTimestamp > existingMessageTimestamp;
7252
+ // Replace the message payload after send is completed
7253
+ // 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.
7254
+ // Always override existing message in status "sending"
7255
+ if ((messageResponse === null || messageResponse === void 0 ? void 0 : messageResponse.message) &&
7256
+ (responseIsTheNewest || (existingMessage === null || existingMessage === void 0 ? void 0 : existingMessage.status) === 'sending')) {
7241
7257
  updateMessage(__assign(__assign({}, messageResponse.message), { status: 'received' }));
7242
7258
  }
7243
7259
  if (quotedMessage && parent_id === (quotedMessage === null || quotedMessage === void 0 ? void 0 : quotedMessage.parent_id))
7244
7260
  setQuotedMessage(undefined);
7245
7261
  return [3 /*break*/, 7];
7246
7262
  case 6:
7247
- error_1 = _b.sent();
7263
+ error_1 = _d.sent();
7248
7264
  stringError = JSON.stringify(error_1);
7249
7265
  parsedError = stringError ? JSON.parse(stringError) : {};
7250
7266
  updateMessage(__assign(__assign({}, message), { error: parsedError, errorStatusCode: parsedError.status || undefined, status: 'failed' }));
@@ -8396,7 +8412,7 @@ var UnMemoizedChannelList = function (props) {
8396
8412
  */
8397
8413
  var ChannelList = React__default['default'].memo(UnMemoizedChannelList);
8398
8414
 
8399
- var version = '9.5.1';
8415
+ var version = '9.5.3';
8400
8416
 
8401
8417
  var useChat = function (_a) {
8402
8418
  var _b, _c;
@@ -9816,16 +9832,17 @@ function useNewMessageNotification(messages, currentUserId, hasMoreNewer) {
9816
9832
  }
9817
9833
 
9818
9834
  function usePrependedMessagesCount(messages, hasDateSeparator) {
9819
- var _a;
9820
9835
  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);
9836
+ var firstMessageId = React.useRef();
9837
+ var earliestMessageId = React.useRef();
9824
9838
  var previousNumItemsPrepended = React.useRef(0);
9825
9839
  var numItemsPrepended = React.useMemo(function () {
9840
+ var _a;
9826
9841
  if (!messages || !messages.length) {
9842
+ previousNumItemsPrepended.current = 0;
9827
9843
  return 0;
9828
9844
  }
9845
+ var currentFirstMessageId = (_a = messages === null || messages === void 0 ? void 0 : messages[firstRealMessageIndex]) === null || _a === void 0 ? void 0 : _a.id;
9829
9846
  // if no new messages were prepended, return early (same amount as before)
9830
9847
  if (currentFirstMessageId === earliestMessageId.current) {
9831
9848
  return previousNumItemsPrepended.current;
@@ -9842,8 +9859,9 @@ function usePrependedMessagesCount(messages, hasDateSeparator) {
9842
9859
  return i;
9843
9860
  }
9844
9861
  }
9845
- // if no match has found, we have jumped
9862
+ // if no match has found, we have jumped - reset the prepend item count.
9846
9863
  firstMessageId.current = currentFirstMessageId;
9864
+ previousNumItemsPrepended.current = 0;
9847
9865
  return 0;
9848
9866
  // TODO: there's a bug here, the messages prop is the same array instance (something mutates it)
9849
9867
  // that's why the second dependency is necessary