sceyt-chat-react-uikit 1.9.0-beta.9 → 1.9.0

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.
package/index.js CHANGED
@@ -11139,7 +11139,7 @@ var compressAndCacheImage = function compressAndCacheImage(url, cacheKey, maxWid
11139
11139
 
11140
11140
  var bytesToSize = function bytesToSize(bytes, decimals) {
11141
11141
  if (decimals === void 0) {
11142
- decimals = 2;
11142
+ decimals = 1;
11143
11143
  }
11144
11144
  if (bytes === 0) return '0 Bytes';
11145
11145
  var k = 1000;
@@ -11495,6 +11495,11 @@ var clearVideoPreparation = function clearVideoPreparation(tid) {
11495
11495
  }
11496
11496
  preparations["delete"](tid);
11497
11497
  };
11498
+ var beginAttachmentPreparation = beginVideoPreparation;
11499
+ var completeAttachmentPreparation = completeVideoPreparation;
11500
+ var failAttachmentPreparation = failVideoPreparation;
11501
+ var waitForAttachmentPreparation = waitForVideoPreparation;
11502
+ var clearAttachmentPreparation = clearVideoPreparation;
11498
11503
 
11499
11504
  var LOAD_LATEST_MESSAGES = 'LOAD_LATEST_MESSAGES';
11500
11505
  var LOAD_AROUND_MESSAGE = 'LOAD_AROUND_MESSAGE';
@@ -13434,6 +13439,21 @@ function addReactionToMessageOnMap(channelId, message, reaction, isSelf) {
13434
13439
  });
13435
13440
  }
13436
13441
  }
13442
+ var removeReactionFromTotals = function removeReactionFromTotals(reactionTotals, reactionKey) {
13443
+ if (reactionTotals === void 0) {
13444
+ reactionTotals = [];
13445
+ }
13446
+ return reactionTotals.reduce(function (totals, reactionTotal) {
13447
+ if (reactionTotal.key !== reactionKey) {
13448
+ totals.push(reactionTotal);
13449
+ } else if (reactionTotal.count > 1) {
13450
+ totals.push(_extends({}, reactionTotal, {
13451
+ count: reactionTotal.count - 1
13452
+ }));
13453
+ }
13454
+ return totals;
13455
+ }, []);
13456
+ };
13437
13457
  function removeReactionToMessageOnMap(channelId, message, reaction, isSelf) {
13438
13458
  if (messagesMap[channelId]) {
13439
13459
  var messageShouldBeUpdated = messagesMap[channelId][message.id];
@@ -13450,7 +13470,7 @@ function removeReactionToMessageOnMap(channelId, message, reaction, isSelf) {
13450
13470
  delete messagesMap[channelId][message.tid];
13451
13471
  }
13452
13472
  messagesMap[channelId][message.id || message.tid] = _extends({}, messageShouldBeUpdated, {
13453
- reactionTotals: message.reactionTotals || messageShouldBeUpdated.reactionTotals || [],
13473
+ reactionTotals: removeReactionFromTotals(messageShouldBeUpdated.reactionTotals, reaction.key),
13454
13474
  userReactions: userReactions
13455
13475
  });
13456
13476
  }
@@ -13744,9 +13764,10 @@ var hydrateDraftMessages = function hydrateDraftMessages() {
13744
13764
  type: data.type || attachment.mimeType || 'application/octet-stream',
13745
13765
  lastModified: attachment.lastModified || Date.now()
13746
13766
  }) : data;
13767
+ var canRestorePreviewUrl = attachment.type === attachmentTypes.image || attachment.type === attachmentTypes.video || attachment.type === attachmentTypes.voice;
13747
13768
  return _extends({}, attachment, {
13748
13769
  data: restoredData,
13749
- attachmentUrl: restoredData instanceof Blob && typeof URL !== 'undefined' ? URL.createObjectURL(restoredData) : attachment.attachmentUrl
13770
+ attachmentUrl: canRestorePreviewUrl && restoredData instanceof Blob && typeof URL !== 'undefined' ? URL.createObjectURL(restoredData) : undefined
13750
13771
  });
13751
13772
  });
13752
13773
  draftMessagesMap[channelId] = _extends({}, draft, {
@@ -14203,7 +14224,7 @@ var messageSlice = createSlice({
14203
14224
  });
14204
14225
  }
14205
14226
  return _extends({}, msg, {
14206
- reactionTotals: message.reactionTotals || msg.reactionTotals || [],
14227
+ reactionTotals: removeReactionFromTotals(msg.reactionTotals, reaction.key),
14207
14228
  userReactions: userReactions
14208
14229
  });
14209
14230
  }
@@ -14321,6 +14342,7 @@ var messageSlice = createSlice({
14321
14342
  },
14322
14343
  requestPinnedMessagesListClose: function requestPinnedMessagesListClose(state) {
14323
14344
  if (state.pinnedMessagesListOpen) {
14345
+ state.pinnedMessagesListOpen = false;
14324
14346
  state.pinnedMessagesListCloseRequested = true;
14325
14347
  }
14326
14348
  },
@@ -17508,12 +17530,15 @@ var hasLivePendingAttachment = function hasLivePendingAttachment(message) {
17508
17530
  var retractDeletedPendingMessage = function retractDeletedPendingMessage(channel, messageId) {
17509
17531
  return channel.deleteMessageById(messageId, false);
17510
17532
  };
17511
- var applyPreparedVideoAttachments = function applyPreparedVideoAttachments(attachments) {
17533
+ var applyPreparedMediaAttachments = function applyPreparedMediaAttachments(attachments, clearPreparation) {
17534
+ if (clearPreparation === void 0) {
17535
+ clearPreparation = true;
17536
+ }
17512
17537
  try {
17513
17538
  return Promise.resolve(Promise.all(attachments.map(function (attachment) {
17514
17539
  try {
17515
17540
  if (!attachment.tid) return Promise.resolve();
17516
- return Promise.resolve(waitForVideoPreparation(attachment.tid, VIDEO_PREPARATION_TIMEOUT_MS)).then(function (prepared) {
17541
+ return Promise.resolve(waitForAttachmentPreparation(attachment.tid, VIDEO_PREPARATION_TIMEOUT_MS)).then(function (prepared) {
17517
17542
  if ((prepared === null || prepared === void 0 ? void 0 : prepared.status) === 'ready' && prepared.metadata) {
17518
17543
  attachment.url = prepared.file;
17519
17544
  attachment.data = prepared.file;
@@ -17522,7 +17547,9 @@ var applyPreparedVideoAttachments = function applyPreparedVideoAttachments(attac
17522
17547
  attachment.metadata = prepared.metadata;
17523
17548
  attachment.videoPreviewBlob = prepared.videoPreviewBlob;
17524
17549
  }
17525
- clearVideoPreparation(attachment.tid);
17550
+ if (clearPreparation) {
17551
+ clearAttachmentPreparation(attachment.tid);
17552
+ }
17526
17553
  });
17527
17554
  } catch (e) {
17528
17555
  return Promise.reject(e);
@@ -18461,7 +18488,7 @@ function sendMessage(action) {
18461
18488
  }) : [];
18462
18489
  customUploader = getCustomUploader();
18463
18490
  if (!(message.attachments && message.attachments.length)) {
18464
- _context13.n = 16;
18491
+ _context13.n = 14;
18465
18492
  break;
18466
18493
  }
18467
18494
  linkAttachment = null;
@@ -18474,7 +18501,7 @@ function sendMessage(action) {
18474
18501
  return att.type !== attachmentTypes.link;
18475
18502
  });
18476
18503
  if (!(mediaAttachments && mediaAttachments.length)) {
18477
- _context13.n = 12;
18504
+ _context13.n = 10;
18478
18505
  break;
18479
18506
  }
18480
18507
  _loop2 = /*#__PURE__*/_regenerator().m(function _callee3() {
@@ -18628,68 +18655,53 @@ function sendMessage(action) {
18628
18655
  if (customUploader) {
18629
18656
  messageAttachment.url = attachment.data;
18630
18657
  }
18631
- if (!sendAttachmentsAsSeparateMessage) {
18632
- _context11.n = 3;
18633
- break;
18634
- }
18635
- _messageBuilder = channel.createMessageBuilder();
18636
- _messageBuilder.setBody(i === 0 ? message.body : '').setAttachments([]).setBodyAttributes(i === 0 ? message.bodyAttributes : {}).setMentionUserIds(i === 0 ? mentionedUserIds : []).setType(message.type).setDisplayCount(message.type === exports.MESSAGE_TYPE.SYSTEM ? 0 : 1).setSilent(message.type === exports.MESSAGE_TYPE.SYSTEM).setMetadata(i === 0 ? JSON.stringify(message.metadata) : '');
18637
- if (channel.type === DEFAULT_CHANNEL_TYPE.DIRECT) {
18638
- _messageBuilder.setDisableMentionsCount(true);
18639
- }
18640
- if (message.parentMessage) {
18641
- _messageBuilder.setParentMessageId(message.parentMessage ? message.parentMessage.id : null);
18642
- }
18643
- if (message.repliedInThread) {
18644
- _messageBuilder.setReplyInThread();
18645
- }
18646
- if (i === 0 && canBeViewOnce(message)) {
18647
- _messageBuilder.setViewOnce(true);
18648
- _messageBuilder.setType(exports.MESSAGE_TYPE.VIEW_ONCE);
18649
- }
18650
- _messageToSend = action.type === RESEND_MESSAGE ? action.payload.message : _messageBuilder.create();
18651
- _sourceFile = getAttachmentSourceFile(attachment);
18652
- if (messageAttachment.tid && _sourceFile) {
18653
- setPendingAttachment(messageAttachment.tid, {
18654
- file: _sourceFile,
18655
- messageTid: _messageToSend.tid,
18656
- channelId: channel.id
18658
+ if (sendAttachmentsAsSeparateMessage) {
18659
+ _messageBuilder = channel.createMessageBuilder();
18660
+ _messageBuilder.setBody(i === 0 ? message.body : '').setAttachments([]).setBodyAttributes(i === 0 ? message.bodyAttributes : {}).setMentionUserIds(i === 0 ? mentionedUserIds : []).setType(message.type).setDisplayCount(message.type === exports.MESSAGE_TYPE.SYSTEM ? 0 : 1).setSilent(message.type === exports.MESSAGE_TYPE.SYSTEM).setMetadata(i === 0 ? JSON.stringify(message.metadata) : '');
18661
+ if (channel.type === DEFAULT_CHANNEL_TYPE.DIRECT) {
18662
+ _messageBuilder.setDisableMentionsCount(true);
18663
+ }
18664
+ if (message.parentMessage) {
18665
+ _messageBuilder.setParentMessageId(message.parentMessage ? message.parentMessage.id : null);
18666
+ }
18667
+ if (message.repliedInThread) {
18668
+ _messageBuilder.setReplyInThread();
18669
+ }
18670
+ if (i === 0 && canBeViewOnce(message)) {
18671
+ _messageBuilder.setViewOnce(true);
18672
+ _messageBuilder.setType(exports.MESSAGE_TYPE.VIEW_ONCE);
18673
+ }
18674
+ _messageToSend = action.type === RESEND_MESSAGE ? action.payload.message : _messageBuilder.create();
18675
+ _sourceFile = getAttachmentSourceFile(attachment);
18676
+ if (messageAttachment.tid && _sourceFile) {
18677
+ setPendingAttachment(messageAttachment.tid, {
18678
+ file: _sourceFile,
18679
+ messageTid: _messageToSend.tid,
18680
+ channelId: channel.id
18681
+ });
18682
+ }
18683
+ messageForSend = _extends({}, _messageToSend, {
18684
+ attachments: [messageAttachment],
18685
+ createdAt: new Date(Date.now())
18657
18686
  });
18687
+ messagesToSend.push(messageForSend);
18688
+ _pending = _extends({}, messageForSend, {
18689
+ attachments: [attachment],
18690
+ createdAt: new Date(Date.now()),
18691
+ mentionedUsers: message.mentionedUsers,
18692
+ parentMessage: message.parentMessage || null
18693
+ });
18694
+ pendingMessages.push(_pending);
18695
+ } else {
18696
+ attachmentsToSend.push(messageAttachment);
18658
18697
  }
18659
- messageForSend = _extends({}, _messageToSend, {
18660
- attachments: [messageAttachment],
18661
- createdAt: new Date(Date.now())
18662
- });
18663
- messagesToSend.push(messageForSend);
18664
- _pending = _extends({}, messageForSend, {
18665
- attachments: [attachment],
18666
- createdAt: new Date(Date.now()),
18667
- mentionedUsers: message.mentionedUsers,
18668
- parentMessage: message.parentMessage || null
18669
- });
18670
- pendingMessages.push(_pending);
18671
- if (!(action.type !== RESEND_MESSAGE)) {
18672
- _context11.n = 2;
18673
- break;
18674
- }
18675
- _context11.n = 1;
18676
- return effects.call(loadOGMetadataForLinkMessages, [_pending], true);
18677
- case 1:
18678
- _context11.n = 2;
18679
- return effects.call(updateMessage$1, action.type, _pending, channel.id, true, message);
18680
- case 2:
18681
- _context11.n = 4;
18682
- break;
18683
- case 3:
18684
- attachmentsToSend.push(messageAttachment);
18685
- case 4:
18686
18698
  if (!(!messageAttachment.cachedUrl && customUploader)) {
18687
- _context11.n = 5;
18699
+ _context11.n = 1;
18688
18700
  break;
18689
18701
  }
18690
- _context11.n = 5;
18702
+ _context11.n = 1;
18691
18703
  return effects.put(updateAttachmentUploadingStateAC(messageAttachment.type === attachmentTypes.video ? UPLOAD_STATE.PREPARING : UPLOAD_STATE.UPLOADING, messageAttachment.tid));
18692
- case 5:
18704
+ case 1:
18693
18705
  return _context11.a(2);
18694
18706
  }
18695
18707
  }, _callee3);
@@ -18706,60 +18718,48 @@ function sendMessage(action) {
18706
18718
  _context13.n = 7;
18707
18719
  break;
18708
18720
  case 9:
18709
- if (sendAttachmentsAsSeparateMessage) {
18710
- _context13.n = 12;
18711
- break;
18712
- }
18713
- messageBuilder = channel.createMessageBuilder();
18714
- messageBuilder.setBody(message.body).setBodyAttributes(message.bodyAttributes).setAttachments(message.attachments).setMentionUserIds(mentionedUserIds).setType(message.type).setDisplayCount(message.type === exports.MESSAGE_TYPE.SYSTEM ? 0 : 1).setSilent(message.type === exports.MESSAGE_TYPE.SYSTEM).setMetadata(JSON.stringify(message.metadata));
18715
- if (channel.type === DEFAULT_CHANNEL_TYPE.DIRECT) {
18716
- messageBuilder.setDisableMentionsCount(true);
18717
- }
18718
- if (message.parentMessage) {
18719
- messageBuilder.setParentMessageId(message.parentMessage ? message.parentMessage.id : null);
18720
- }
18721
- if (message.repliedInThread) {
18722
- messageBuilder.setReplyInThread();
18723
- }
18724
- if (canBeViewOnce(message)) {
18725
- messageBuilder.setViewOnce(true);
18726
- messageBuilder.setType(exports.MESSAGE_TYPE.VIEW_ONCE);
18727
- }
18728
- messageToSend = action.type === RESEND_MESSAGE ? action.payload.message : messageBuilder.create();
18729
- attachmentsToSend.forEach(function (messageAttachment) {
18730
- var sourceFile = getAttachmentSourceFile(messageAttachment);
18731
- if (messageAttachment.tid && sourceFile) {
18732
- setPendingAttachment(messageAttachment.tid, {
18733
- file: sourceFile,
18734
- messageTid: messageToSend.tid,
18735
- channelId: channel.id
18736
- });
18721
+ if (!sendAttachmentsAsSeparateMessage) {
18722
+ messageBuilder = channel.createMessageBuilder();
18723
+ messageBuilder.setBody(message.body).setBodyAttributes(message.bodyAttributes).setAttachments(message.attachments).setMentionUserIds(mentionedUserIds).setType(message.type).setDisplayCount(message.type === exports.MESSAGE_TYPE.SYSTEM ? 0 : 1).setSilent(message.type === exports.MESSAGE_TYPE.SYSTEM).setMetadata(JSON.stringify(message.metadata));
18724
+ if (channel.type === DEFAULT_CHANNEL_TYPE.DIRECT) {
18725
+ messageBuilder.setDisableMentionsCount(true);
18737
18726
  }
18738
- });
18739
- pending = _extends({}, messageToSend, {
18740
- attachments: message.attachments,
18741
- createdAt: new Date(Date.now()),
18742
- mentionedUsers: message.mentionedUsers,
18743
- parentMessage: message.parentMessage || null
18744
- });
18745
- pendingMessages.push(pending);
18746
- if (!(action.type !== RESEND_MESSAGE)) {
18747
- _context13.n = 11;
18748
- break;
18727
+ if (message.parentMessage) {
18728
+ messageBuilder.setParentMessageId(message.parentMessage ? message.parentMessage.id : null);
18729
+ }
18730
+ if (message.repliedInThread) {
18731
+ messageBuilder.setReplyInThread();
18732
+ }
18733
+ if (canBeViewOnce(message)) {
18734
+ messageBuilder.setViewOnce(true);
18735
+ messageBuilder.setType(exports.MESSAGE_TYPE.VIEW_ONCE);
18736
+ }
18737
+ messageToSend = action.type === RESEND_MESSAGE ? action.payload.message : messageBuilder.create();
18738
+ attachmentsToSend.forEach(function (messageAttachment) {
18739
+ var sourceFile = getAttachmentSourceFile(messageAttachment);
18740
+ if (messageAttachment.tid && sourceFile) {
18741
+ setPendingAttachment(messageAttachment.tid, {
18742
+ file: sourceFile,
18743
+ messageTid: messageToSend.tid,
18744
+ channelId: channel.id
18745
+ });
18746
+ }
18747
+ });
18748
+ pending = _extends({}, messageToSend, {
18749
+ attachments: message.attachments,
18750
+ createdAt: new Date(Date.now()),
18751
+ mentionedUsers: message.mentionedUsers,
18752
+ parentMessage: message.parentMessage || null
18753
+ });
18754
+ pendingMessages.push(pending);
18755
+ messageToSend = _extends({}, messageToSend, {
18756
+ attachments: attachmentsToSend
18757
+ });
18758
+ messagesToSend.push(messageToSend);
18749
18759
  }
18750
- _context13.n = 10;
18751
- return effects.call(loadOGMetadataForLinkMessages, [pending], true);
18752
18760
  case 10:
18753
- _context13.n = 11;
18754
- return effects.call(updateMessage$1, action.type, pending, channel.id, true, message);
18755
- case 11:
18756
- messageToSend = _extends({}, messageToSend, {
18757
- attachments: attachmentsToSend
18758
- });
18759
- messagesToSend.push(messageToSend);
18760
- case 12:
18761
18761
  _loop3 = /*#__PURE__*/_regenerator().m(function _callee4(_i2) {
18762
- var messageAttachment, messageToSend, pendingState, pendingAttachments, messageCopy, attachmentIndex, preparedVideoAttachment, _attachmentsToSend, linkAttachmentToSend, linkAttachmentBuilder, messageResponse, k, attachmentsToUpdate, currentAttachmentsMap, messageUpdateData, activeChannelId, messageToUpdate, resolvedLastMessage, channelUpdateParam, _channel2, _messageToSend2, isErrorResendable, _messageToSend$attach, _iterator2, _step2, att, _t, _t2;
18762
+ var messageAttachment, messageToSend, pendingState, pendingMessage, pendingAttachments, messageCopy, attachmentIndex, preparedVideoAttachment, _attachmentsToSend, linkAttachmentToSend, linkAttachmentBuilder, messageResponse, k, attachmentsToUpdate, currentAttachmentsMap, messageUpdateData, activeChannelId, messageToUpdate, resolvedLastMessage, channelUpdateParam, _channel2, _messageToSend2, isErrorResendable, _messageToSend$attach, _iterator2, _step2, att, _t, _t2;
18763
18763
  return _regenerator().w(function (_context12) {
18764
18764
  while (1) switch (_context12.p = _context12.n) {
18765
18765
  case 0:
@@ -18782,10 +18782,6 @@ function sendMessage(action) {
18782
18782
  messageToSend = _extends({}, messageToSend, pendingState);
18783
18783
  case 2:
18784
18784
  _context12.p = 2;
18785
- if (!(connectionState === CONNECTION_STATUS.CONNECTED)) {
18786
- _context12.n = 30;
18787
- break;
18788
- }
18789
18785
  if (!(messageToSend.tid && isPendingMessageDeleted(channel.id, messageToSend.tid))) {
18790
18786
  _context12.n = 3;
18791
18787
  break;
@@ -18793,83 +18789,108 @@ function sendMessage(action) {
18793
18789
  return _context12.a(2, 0);
18794
18790
  case 3:
18795
18791
  _context12.n = 4;
18796
- return effects.call(applyPreparedVideoAttachments, messageAttachment);
18792
+ return effects.call(applyPreparedMediaAttachments, messageAttachment, connectionState === CONNECTION_STATUS.CONNECTED);
18797
18793
  case 4:
18798
- pendingAttachments = messageAttachment.map(function (attachment) {
18799
- return _extends({}, attachment, {
18800
- data: attachment.data || attachment.url
18794
+ pendingMessage = pendingMessages[_i2];
18795
+ pendingAttachments = pendingMessage.attachments.map(function (pendingAttachment) {
18796
+ var preparedAttachment = messageAttachment.find(function (attachment) {
18797
+ return attachment.tid === pendingAttachment.tid;
18801
18798
  });
18799
+ return preparedAttachment ? _extends({}, pendingAttachment, preparedAttachment, {
18800
+ data: preparedAttachment.data || preparedAttachment.url
18801
+ }) : pendingAttachment;
18802
18802
  });
18803
+ pendingMessage.attachments = pendingAttachments;
18804
+ if (!(action.type !== RESEND_MESSAGE)) {
18805
+ _context12.n = 6;
18806
+ break;
18807
+ }
18808
+ _context12.n = 5;
18809
+ return effects.call(loadOGMetadataForLinkMessages, [pendingMessage], true);
18810
+ case 5:
18811
+ _context12.n = 6;
18812
+ return effects.call(updateMessage$1, action.type, pendingMessage, channel.id, true, message);
18813
+ case 6:
18814
+ if (!(connectionState === CONNECTION_STATUS.CONNECTED)) {
18815
+ _context12.n = 33;
18816
+ break;
18817
+ }
18818
+ if (!(messageToSend.tid && isPendingMessageDeleted(channel.id, messageToSend.tid))) {
18819
+ _context12.n = 7;
18820
+ break;
18821
+ }
18822
+ return _context12.a(2, 0);
18823
+ case 7:
18803
18824
  updateMessageOnMap(channel.id, {
18804
18825
  messageId: messageToSend.tid,
18805
18826
  params: {
18806
18827
  attachments: pendingAttachments
18807
18828
  }
18808
18829
  });
18809
- _context12.n = 5;
18830
+ _context12.n = 8;
18810
18831
  return effects.put(updateMessageAC(messageToSend.tid, {
18811
18832
  attachments: pendingAttachments
18812
18833
  }));
18813
- case 5:
18834
+ case 8:
18814
18835
  messageCopy = JSON.parse(JSON.stringify(messagesToSend[_i2]));
18815
18836
  if (!(messageToSend.tid && isPendingMessageDeleted(channel.id, messageToSend.tid))) {
18816
- _context12.n = 6;
18837
+ _context12.n = 9;
18817
18838
  break;
18818
18839
  }
18819
18840
  return _context12.a(2, 0);
18820
- case 6:
18841
+ case 9:
18821
18842
  if (customUploader) {
18822
- _context12.n = 10;
18843
+ _context12.n = 13;
18823
18844
  break;
18824
18845
  }
18825
18846
  attachmentIndex = 0;
18826
- case 7:
18847
+ case 10:
18827
18848
  if (!(attachmentIndex < messageAttachment.length)) {
18828
- _context12.n = 10;
18849
+ _context12.n = 13;
18829
18850
  break;
18830
18851
  }
18831
18852
  if (!(messageAttachment[attachmentIndex].type === attachmentTypes.video)) {
18832
- _context12.n = 9;
18853
+ _context12.n = 12;
18833
18854
  break;
18834
18855
  }
18835
- _context12.n = 8;
18856
+ _context12.n = 11;
18836
18857
  return effects.call(prepareAndUploadVideoPreview, messageAttachment[attachmentIndex], message.type);
18837
- case 8:
18858
+ case 11:
18838
18859
  preparedVideoAttachment = _context12.v;
18839
18860
  messageAttachment[attachmentIndex] = _extends({}, messageAttachment[attachmentIndex], preparedVideoAttachment);
18840
18861
  if (!messageAttachment[attachmentIndex].upload) {
18841
- _context12.n = 9;
18862
+ _context12.n = 12;
18842
18863
  break;
18843
18864
  }
18844
- _context12.n = 9;
18865
+ _context12.n = 12;
18845
18866
  return effects.put(updateAttachmentUploadingStateAC(UPLOAD_STATE.UPLOADING, messageAttachment[attachmentIndex].tid));
18846
- case 9:
18867
+ case 12:
18847
18868
  attachmentIndex++;
18848
- _context12.n = 7;
18869
+ _context12.n = 10;
18849
18870
  break;
18850
- case 10:
18871
+ case 13:
18851
18872
  if (!(messageToSend.tid && isPendingMessageDeleted(channel.id, messageToSend.tid))) {
18852
- _context12.n = 11;
18873
+ _context12.n = 14;
18853
18874
  break;
18854
18875
  }
18855
18876
  return _context12.a(2, 0);
18856
- case 11:
18877
+ case 14:
18857
18878
  _attachmentsToSend = messageAttachment;
18858
18879
  if (!customUploader) {
18859
- _context12.n = 13;
18880
+ _context12.n = 16;
18860
18881
  break;
18861
18882
  }
18862
- _context12.n = 12;
18883
+ _context12.n = 15;
18863
18884
  return effects.call(handleUploadAttachments, messageAttachment || [], messageCopy, channel);
18864
- case 12:
18885
+ case 15:
18865
18886
  _attachmentsToSend = _context12.v;
18866
- case 13:
18887
+ case 16:
18867
18888
  if (!(messageToSend.tid && isPendingMessageDeleted(channel.id, messageToSend.tid))) {
18868
- _context12.n = 14;
18889
+ _context12.n = 17;
18869
18890
  break;
18870
18891
  }
18871
18892
  return _context12.a(2, 0);
18872
- case 14:
18893
+ case 17:
18873
18894
  linkAttachmentToSend = null;
18874
18895
  if (_i2 === 0 && linkAttachment) {
18875
18896
  linkAttachmentBuilder = channel.createAttachmentBuilder(linkAttachment.data, linkAttachment.type);
@@ -18884,61 +18905,61 @@ function sendMessage(action) {
18884
18905
  attachments: [].concat(_attachmentsToSend)
18885
18906
  });
18886
18907
  }
18887
- _context12.n = 15;
18908
+ _context12.n = 18;
18888
18909
  return effects.call(channel.sendMessage, messageToSend);
18889
- case 15:
18910
+ case 18:
18890
18911
  messageResponse = _context12.v;
18891
18912
  if (!(messageToSend.tid && isPendingMessageDeleted(channel.id, messageToSend.tid))) {
18892
- _context12.n = 20;
18913
+ _context12.n = 23;
18893
18914
  break;
18894
18915
  }
18895
18916
  if (!(messageResponse !== null && messageResponse !== void 0 && messageResponse.id && typeof channel.deleteMessageById === 'function')) {
18896
- _context12.n = 19;
18917
+ _context12.n = 22;
18897
18918
  break;
18898
18919
  }
18899
- _context12.p = 16;
18900
- _context12.n = 17;
18920
+ _context12.p = 19;
18921
+ _context12.n = 20;
18901
18922
  return effects.call(retractDeletedPendingMessage, channel, messageResponse.id);
18902
- case 17:
18903
- _context12.n = 19;
18923
+ case 20:
18924
+ _context12.n = 22;
18904
18925
  break;
18905
- case 18:
18906
- _context12.p = 18;
18926
+ case 21:
18927
+ _context12.p = 21;
18907
18928
  _t = _context12.v;
18908
18929
  log.warn('Unable to retract a deleted pending message:', _t);
18909
- case 19:
18930
+ case 22:
18910
18931
  return _context12.a(2, 0);
18911
- case 20:
18932
+ case 23:
18912
18933
  if (messageToSend.tid) {
18913
18934
  autoResendAttempts["delete"](messageToSend.tid);
18914
18935
  }
18915
18936
  if (!customUploader) {
18916
- _context12.n = 25;
18937
+ _context12.n = 28;
18917
18938
  break;
18918
18939
  }
18919
18940
  k = 0;
18920
- case 21:
18941
+ case 24:
18921
18942
  if (!(k < messageAttachment.length)) {
18922
- _context12.n = 25;
18943
+ _context12.n = 28;
18923
18944
  break;
18924
18945
  }
18925
18946
  messageResponse.attachments[k] = _extends({}, messageResponse.attachments[k], {
18926
18947
  user: JSON.parse(JSON.stringify(messageResponse.user)),
18927
18948
  tid: messageAttachment[k].tid
18928
18949
  });
18929
- _context12.n = 22;
18950
+ _context12.n = 25;
18930
18951
  return effects.put(removeAttachmentProgressAC(messageAttachment[k].tid));
18931
- case 22:
18932
- _context12.n = 23;
18952
+ case 25:
18953
+ _context12.n = 26;
18933
18954
  return effects.put(removeAttachmentUploadingStateAC(messageAttachment[k].tid));
18934
- case 23:
18955
+ case 26:
18935
18956
  deletePendingAttachment(messageAttachment[k].tid);
18936
18957
  releaseBlobUrls(["compose_" + messageAttachment[k].tid]);
18937
- case 24:
18958
+ case 27:
18938
18959
  k++;
18939
- _context12.n = 21;
18960
+ _context12.n = 24;
18940
18961
  break;
18941
- case 25:
18962
+ case 28:
18942
18963
  attachmentsToUpdate = [];
18943
18964
  if (messageResponse.attachments && messageResponse.attachments.length > 0) {
18944
18965
  currentAttachmentsMap = {};
@@ -18989,27 +19010,27 @@ function sendMessage(action) {
18989
19010
  });
18990
19011
  activeChannelId = getActiveChannelId();
18991
19012
  if (!(activeChannelId === channel.id)) {
18992
- _context12.n = 26;
19013
+ _context12.n = 29;
18993
19014
  break;
18994
19015
  }
18995
- _context12.n = 26;
19016
+ _context12.n = 29;
18996
19017
  return effects.put(updateMessageAC(messageToSend.tid, messageUpdateData, true));
18997
- case 26:
19018
+ case 29:
18998
19019
  messageToUpdate = JSON.parse(JSON.stringify(_extends({}, messageResponse, {
18999
19020
  attachments: attachmentsToUpdate
19000
19021
  })));
19001
19022
  addConfirmedMessageToCache(channel.id, messageToUpdate);
19002
19023
  updateTabAttachmentCache(channel.id, attachmentsToUpdate, messageResponse.user);
19003
19024
  if (!channel.unread) {
19004
- _context12.n = 27;
19025
+ _context12.n = 30;
19005
19026
  break;
19006
19027
  }
19007
- _context12.n = 27;
19028
+ _context12.n = 30;
19008
19029
  return effects.put(markChannelAsReadAC(channel.id));
19009
- case 27:
19030
+ case 30:
19010
19031
  resolvedLastMessage = getResolvedChannelLastMessage(channel.id, messageToUpdate, messageToSend);
19011
19032
  if (!lastMessageNeedsUpdate(getReduxChannelLastMessage(channel.id), resolvedLastMessage)) {
19012
- _context12.n = 29;
19033
+ _context12.n = 32;
19013
19034
  break;
19014
19035
  }
19015
19036
  updateChannelLastMessageOnAllChannels(channel.id, resolvedLastMessage);
@@ -19017,90 +19038,90 @@ function sendMessage(action) {
19017
19038
  lastMessage: resolvedLastMessage,
19018
19039
  lastReactedMessage: null
19019
19040
  };
19020
- _context12.n = 28;
19041
+ _context12.n = 31;
19021
19042
  return effects.put(updateChannelDataAC(channel.id, channelUpdateParam, true));
19022
- case 28:
19043
+ case 31:
19023
19044
  updateChannelOnAllChannels(channel.id, channelUpdateParam);
19024
- case 29:
19025
- _context12.n = 31;
19045
+ case 32:
19046
+ _context12.n = 34;
19026
19047
  break;
19027
- case 30:
19048
+ case 33:
19028
19049
  throw new Error('Connection required to send message');
19029
- case 31:
19030
- _context12.n = 37;
19050
+ case 34:
19051
+ _context12.n = 40;
19031
19052
  break;
19032
- case 32:
19033
- _context12.p = 32;
19053
+ case 35:
19054
+ _context12.p = 35;
19034
19055
  _t2 = _context12.v;
19035
19056
  if (!(messageToSend.tid && isPendingMessageDeleted(channel.id, messageToSend.tid))) {
19036
- _context12.n = 33;
19057
+ _context12.n = 36;
19037
19058
  break;
19038
19059
  }
19039
19060
  return _context12.a(2, 0);
19040
- case 33:
19061
+ case 36:
19041
19062
  isErrorResendable = isResendableError(_t2 === null || _t2 === void 0 ? void 0 : _t2.type);
19042
19063
  if (!((_channel2 = channel) !== null && _channel2 !== void 0 && _channel2.id && (_messageToSend2 = messageToSend) !== null && _messageToSend2 !== void 0 && _messageToSend2.tid)) {
19043
- _context12.n = 37;
19064
+ _context12.n = 40;
19044
19065
  break;
19045
19066
  }
19046
19067
  log.error('Error on uploading attachment', messageToSend.tid, _t2);
19047
19068
  if (!((_messageToSend$attach = messageToSend.attachments) !== null && _messageToSend$attach !== void 0 && _messageToSend$attach.length)) {
19048
- _context12.n = 36;
19069
+ _context12.n = 39;
19049
19070
  break;
19050
19071
  }
19051
19072
  _iterator2 = _createForOfIteratorHelperLoose(messageToSend.attachments);
19052
- case 34:
19073
+ case 37:
19053
19074
  if ((_step2 = _iterator2()).done) {
19054
- _context12.n = 36;
19075
+ _context12.n = 39;
19055
19076
  break;
19056
19077
  }
19057
19078
  att = _step2.value;
19058
19079
  if (!att.tid) {
19059
- _context12.n = 35;
19080
+ _context12.n = 38;
19060
19081
  break;
19061
19082
  }
19062
- _context12.n = 35;
19083
+ _context12.n = 38;
19063
19084
  return effects.put(updateAttachmentUploadingStateAC(UPLOAD_STATE.FAIL, att.tid));
19064
- case 35:
19065
- _context12.n = 34;
19066
- break;
19067
- case 36:
19085
+ case 38:
19068
19086
  _context12.n = 37;
19087
+ break;
19088
+ case 39:
19089
+ _context12.n = 40;
19069
19090
  return effects.call(syncFailedMessageState, channel, messageToSend.tid, pendingMessages[_i2] || messageToSend, isErrorResendable);
19070
- case 37:
19091
+ case 40:
19071
19092
  return _context12.a(2);
19072
19093
  }
19073
- }, _callee4, null, [[16, 18], [2, 32]]);
19094
+ }, _callee4, null, [[19, 21], [2, 35]]);
19074
19095
  });
19075
19096
  _i2 = 0;
19076
- case 13:
19097
+ case 11:
19077
19098
  if (!(_i2 < messagesToSend.length)) {
19078
- _context13.n = 16;
19099
+ _context13.n = 14;
19079
19100
  break;
19080
19101
  }
19081
- return _context13.d(_regeneratorValues(_loop3(_i2)), 14);
19082
- case 14:
19102
+ return _context13.d(_regeneratorValues(_loop3(_i2)), 12);
19103
+ case 12:
19083
19104
  _ret = _context13.v;
19084
19105
  if (!(_ret === 0)) {
19085
- _context13.n = 15;
19106
+ _context13.n = 13;
19086
19107
  break;
19087
19108
  }
19088
- return _context13.a(3, 15);
19089
- case 15:
19109
+ return _context13.a(3, 13);
19110
+ case 13:
19090
19111
  _i2++;
19091
- _context13.n = 13;
19112
+ _context13.n = 11;
19092
19113
  break;
19093
- case 16:
19094
- _context13.n = 18;
19114
+ case 14:
19115
+ _context13.n = 16;
19095
19116
  break;
19096
- case 17:
19097
- _context13.p = 17;
19117
+ case 15:
19118
+ _context13.p = 15;
19098
19119
  _t3 = _context13.v;
19099
19120
  log.error('error on send message ... ', _t3);
19100
- case 18:
19121
+ case 16:
19101
19122
  return _context13.a(2);
19102
19123
  }
19103
- }, _marked1, null, [[1, 17]]);
19124
+ }, _marked1, null, [[1, 15]]);
19104
19125
  }
19105
19126
  function sendTextMessage(action) {
19106
19127
  var payload, message, connectionState, channelId, channel, sendMessageTid, pendingMessage, _channel3, SceytChatClient, createChannelData, mentionedUserIds, attachments, _attachments$, attachmentBuilder, att, messageBuilder, createdMessage, messageToSend, _messageResponse$atta, messageResponse, messageUpdateData, activeChannelId, stringifiedMessageUpdateData, messageToUpdate, resolvedLastMessage, shouldUpdateChannelList, channelUpdateParam, _channel4, isErrorResendable, _t4;
@@ -22306,7 +22327,8 @@ function deleteReaction(action) {
22306
22327
  }
22307
22328
  channelUpdateParam = {
22308
22329
  userMessageReactions: [],
22309
- lastReactedMessage: null
22330
+ lastReactedMessage: null,
22331
+ newReactions: []
22310
22332
  };
22311
22333
  _context40.n = 3;
22312
22334
  return effects.put(updateChannelDataAC(channel.id, channelUpdateParam));
@@ -23902,7 +23924,7 @@ function MessageSaga() {
23902
23924
  return effects.takeEvery(CANCEL_CHANNEL_MESSAGE_PROCESSES, cancelChannelMessageProcesses);
23903
23925
  case 22:
23904
23926
  _context65.n = 23;
23905
- return effects.takeEvery(GET_REACTIONS, getReactions);
23927
+ return effects.takeLatest(GET_REACTIONS, getReactions);
23906
23928
  case 23:
23907
23929
  _context65.n = 24;
23908
23930
  return effects.takeEvery(LOAD_MORE_REACTIONS, loadMoreReactions);
@@ -29557,9 +29579,16 @@ function updateChannel(action) {
29557
29579
  avatarUrl: avatarUrl,
29558
29580
  metadata: isJSON(metadata) ? JSON.parse(metadata) : metadata
29559
29581
  });
29582
+ _context28.n = 6;
29583
+ return effects.put(updateSearchedChannelDataAC(channelId, {
29584
+ subject: subject,
29585
+ avatarUrl: avatarUrl,
29586
+ metadata: isJSON(metadata) ? JSON.parse(metadata) : metadata
29587
+ }, getChannelGroupName(channel)));
29588
+ case 6:
29560
29589
  onUpdateChannel = getOnUpdateChannel();
29561
29590
  if (!onUpdateChannel) {
29562
- _context28.n = 7;
29591
+ _context28.n = 8;
29563
29592
  break;
29564
29593
  }
29565
29594
  fields = [];
@@ -29572,22 +29601,22 @@ function updateChannel(action) {
29572
29601
  if (JSON.stringify((_channel5 = channel) === null || _channel5 === void 0 ? void 0 : _channel5.metadata) !== metadata) {
29573
29602
  fields.push('metadata');
29574
29603
  }
29575
- _context28.n = 6;
29604
+ _context28.n = 7;
29576
29605
  return effects.call(getChannelFromMap, channelId);
29577
- case 6:
29606
+ case 7:
29578
29607
  updatedChannel = _context28.v;
29579
29608
  onUpdateChannel(updatedChannel, fields);
29580
- case 7:
29581
- _context28.n = 9;
29582
- break;
29583
29609
  case 8:
29584
- _context28.p = 8;
29610
+ _context28.n = 10;
29611
+ break;
29612
+ case 9:
29613
+ _context28.p = 9;
29585
29614
  _t26 = _context28.v;
29586
29615
  log.error('ERROR in update channel', _t26.message);
29587
- case 9:
29616
+ case 10:
29588
29617
  return _context28.a(2);
29589
29618
  }
29590
- }, _marked27$1, null, [[0, 8]]);
29619
+ }, _marked27$1, null, [[0, 9]]);
29591
29620
  }
29592
29621
  function checkUsersStatus() {
29593
29622
  var _SceytChatClient7, usersForUpdate, updatedUsers, usersToUpdateMap, update, updateData, _t27;
@@ -31515,11 +31544,38 @@ function MembersSaga$1() {
31515
31544
  var isPinnedMessageDeleted = function isPinnedMessageDeleted(message) {
31516
31545
  return (message === null || message === void 0 ? void 0 : message.state) === MESSAGE_STATUS.DELETE;
31517
31546
  };
31518
- var getPinnedMessagePreview = function getPinnedMessagePreview(message) {
31519
- var _message$body, _message$attachments;
31547
+ var getPinnedMessageBody = function getPinnedMessageBody(message, contactsMap, getFromContacts) {
31548
+ var _message$bodyAttribut;
31549
+ if (contactsMap === void 0) {
31550
+ contactsMap = {};
31551
+ }
31552
+ if (getFromContacts === void 0) {
31553
+ getFromContacts = false;
31554
+ }
31555
+ var body = (message === null || message === void 0 ? void 0 : message.body) || '';
31556
+ if (!body || !(message !== null && message !== void 0 && (_message$bodyAttribut = message.bodyAttributes) !== null && _message$bodyAttribut !== void 0 && _message$bodyAttribut.length)) return body;
31557
+ var formattedBody = MessageTextFormat({
31558
+ text: body,
31559
+ message: message,
31560
+ contactsMap: contactsMap,
31561
+ getFromContacts: getFromContacts,
31562
+ asSampleText: true,
31563
+ accentColor: '',
31564
+ textSecondary: ''
31565
+ });
31566
+ return Array.isArray(formattedBody) ? formattedBody.join('') : String(formattedBody);
31567
+ };
31568
+ var getPinnedMessagePreview = function getPinnedMessagePreview(message, contactsMap, getFromContacts) {
31569
+ var _message$attachments;
31570
+ if (contactsMap === void 0) {
31571
+ contactsMap = {};
31572
+ }
31573
+ if (getFromContacts === void 0) {
31574
+ getFromContacts = false;
31575
+ }
31520
31576
  if (!message) return '';
31521
31577
  if (isPinnedMessageDeleted(message)) return 'Deleted message';
31522
- var body = (_message$body = message.body) === null || _message$body === void 0 ? void 0 : _message$body.trim();
31578
+ var body = getPinnedMessageBody(message, contactsMap, getFromContacts).trim();
31523
31579
  if (body) return body;
31524
31580
  if (message.pollDetails) return message.pollDetails.name || 'Poll';
31525
31581
  var attachment = (_message$attachments = message.attachments) === null || _message$attachments === void 0 ? void 0 : _message$attachments[0];
@@ -33918,16 +33974,13 @@ var ChannelMessageText = function ChannelMessageText(_ref2) {
33918
33974
  unsupportedMessage = _ref2.unsupportedMessage;
33919
33975
  var isViewOnce = (lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.type) === exports.MESSAGE_TYPE.VIEW_ONCE && (lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.viewOnce);
33920
33976
  var systemMessageActor = lastMessage.user ? lastMessage.user.id === user.id ? 'You' : makeUsername(lastMessage.user && contactsMap && contactsMap[lastMessage.user.id], lastMessage.user, getFromContacts, true) : '';
33921
- var audioRecording = React.useMemo(function () {
33922
- return getAudioRecordingFromMap(channel.id);
33923
- }, [channel.id, draftMessageText]);
33924
33977
  return /*#__PURE__*/React__default.createElement(MessageTextContainer, null, isTypingOrRecording && (/*#__PURE__*/React__default.createElement(TypingIndicator, null, !isDirectChannel && /*#__PURE__*/React__default.createElement(Points, {
33925
33978
  color: textPrimary
33926
33979
  }, ":"), typingOrRecording.isTyping ? 'typing' : 'recording', "...")), !isTypingOrRecording && (draftMessageText ? (/*#__PURE__*/React__default.createElement(DraftMessageText, {
33927
33980
  color: textSecondary
33928
33981
  }, !lastMessage.body && (_lastMessage$attachme = lastMessage.attachments) !== null && _lastMessage$attachme !== void 0 && _lastMessage$attachme.length ? LastMessageAttachments({
33929
33982
  lastMessage: lastMessage
33930
- }) : null, audioRecording && /*#__PURE__*/React__default.createElement(SvgVoiceIcon, null), (!((_lastMessage$attachme2 = lastMessage.attachments) !== null && _lastMessage$attachme2 !== void 0 && _lastMessage$attachme2.length) || lastMessage.body) && MessageTextFormat({
33983
+ }) : null, (!((_lastMessage$attachme2 = lastMessage.attachments) !== null && _lastMessage$attachme2 !== void 0 && _lastMessage$attachme2.length) || lastMessage.body) && MessageTextFormat({
33931
33984
  text: (_lastMessage$attachme3 = lastMessage.attachments) !== null && _lastMessage$attachme3 !== void 0 && _lastMessage$attachme3.length ? lastMessage.body : draftMessageText,
33932
33985
  message: lastMessage,
33933
33986
  contactsMap: contactsMap,
@@ -34064,10 +34117,11 @@ var Channel = function Channel(_ref3) {
34064
34117
  setDraftMessageText(undefined);
34065
34118
  setDraftMessage(undefined);
34066
34119
  } else {
34120
+ var _channelDraftMessage$5;
34067
34121
  setDraftMessageText(draftText);
34068
34122
  setDraftMessage({
34069
34123
  mentionedUsers: channelDraftMessage.mentionedUsers,
34070
- body: channelDraftMessage.text,
34124
+ body: (_channelDraftMessage$5 = channelDraftMessage.text) !== null && _channelDraftMessage$5 !== void 0 && _channelDraftMessage$5.trim() ? channelDraftMessage.text : '',
34071
34125
  bodyAttributes: channelDraftMessage.bodyAttributes,
34072
34126
  attachments: channelDraftMessage.attachments,
34073
34127
  viewOnce: channelDraftMessage.viewOnce,
@@ -34076,7 +34130,14 @@ var Channel = function Channel(_ref3) {
34076
34130
  }
34077
34131
  } else if (draftAudioRecording) {
34078
34132
  setDraftMessageText('Voice');
34079
- setDraftMessage(undefined);
34133
+ setDraftMessage({
34134
+ body: '',
34135
+ attachments: [{
34136
+ type: attachmentTypes.voice,
34137
+ data: draftAudioRecording.file,
34138
+ attachmentUrl: draftAudioRecording.objectUrl
34139
+ }]
34140
+ });
34080
34141
  }
34081
34142
  } else if (draftMessageText) {
34082
34143
  setDraftMessageText(undefined);
@@ -36535,6 +36596,7 @@ var ChannelList = function ChannelList(_ref2) {
36535
36596
  List = _ref2.List,
36536
36597
  ListItem = _ref2.ListItem,
36537
36598
  getSelectedChannel = _ref2.getSelectedChannel,
36599
+ onSearchValueChange = _ref2.onSearchValueChange,
36538
36600
  Profile = _ref2.Profile,
36539
36601
  CreateChannel = _ref2.CreateChannel,
36540
36602
  ChannelsTitle = _ref2.ChannelsTitle,
@@ -36663,10 +36725,13 @@ var ChannelList = function ChannelList(_ref2) {
36663
36725
  getMyChannels();
36664
36726
  };
36665
36727
  var handleSearchValueChange = function handleSearchValueChange(e) {
36666
- setSearchValue(e.target.value);
36728
+ var value = e.target.value;
36729
+ setSearchValue(value);
36730
+ onSearchValueChange === null || onSearchValueChange === void 0 ? void 0 : onSearchValueChange(value);
36667
36731
  };
36668
36732
  var getMyChannels = function getMyChannels() {
36669
36733
  setSearchValue('');
36734
+ onSearchValueChange === null || onSearchValueChange === void 0 ? void 0 : onSearchValueChange('');
36670
36735
  };
36671
36736
  var handleOpenProfile = function handleOpenProfile() {
36672
36737
  setProfileIsOpen(!profileIsOpen);
@@ -39780,6 +39845,7 @@ var VideoPreview = /*#__PURE__*/React.memo(function VideoPreview(_ref) {
39780
39845
  markPreferredSourceLoaded = _useProgressiveMediaS.markPreferredSourceLoaded;
39781
39846
  var isExtractingRef = React.useRef(false);
39782
39847
  var hasExtractionFailedRef = React.useRef(false);
39848
+ var previousVideoSourceRef = React.useRef(undefined);
39783
39849
  React.useEffect(function () {
39784
39850
  if (!videoThumb || downloadedPreviewImage) return;
39785
39851
  var cancelled = false;
@@ -39796,10 +39862,16 @@ var VideoPreview = /*#__PURE__*/React.memo(function VideoPreview(_ref) {
39796
39862
  }, [videoThumb, downloadedPreviewImage, dispatch, messageType]);
39797
39863
  React.useEffect(function () {
39798
39864
  var videoSource = src;
39799
- if (!videoSource || !shouldExtractVideoFirstFrame(file.metadata) || isExtractingRef.current || hasExtractionFailedRef.current) return;
39865
+ var canExtractFirstFrame = shouldExtractVideoFirstFrame(file.metadata);
39866
+ if (previousVideoSourceRef.current !== videoSource) {
39867
+ previousVideoSourceRef.current = videoSource;
39868
+ hasExtractionFailedRef.current = false;
39869
+ }
39870
+ if (!videoSource || !canExtractFirstFrame || isExtractingRef.current || hasExtractionFailedRef.current) {
39871
+ return;
39872
+ }
39800
39873
  if (attachmentVideoFirstFrame || isPreview && setVideoIsReadyToSend) return;
39801
39874
  var frameCacheKey = typeof file.url === 'string' ? file.url : undefined;
39802
- hasExtractionFailedRef.current = false;
39803
39875
  var checkCache = function checkCache() {
39804
39876
  try {
39805
39877
  var _exit = false;
@@ -40189,7 +40261,7 @@ var Attachment = function Attachment(_ref) {
40189
40261
  }
40190
40262
  }
40191
40263
  var fallbackImageSource = withPrefix && attachmentThumb ? "data:image/jpeg;base64," + attachmentThumb : attachmentThumb;
40192
- var preferredImageSource = attachment.attachmentUrl || attachmentUrlFromMap || attachmentUrl;
40264
+ var preferredImageSource = isPreview ? attachment.attachmentUrl || attachmentUrlFromMap || attachmentUrl : attachmentUrlFromMap || attachment.attachmentUrl || attachmentUrl;
40193
40265
  var _useProgressiveMediaS = useProgressiveMediaSource(preferredImageSource, fallbackImageSource),
40194
40266
  displayedImageSource = _useProgressiveMediaS.displayedSource,
40195
40267
  previousImageSource = _useProgressiveMediaS.previousSource,
@@ -40521,6 +40593,9 @@ var Attachment = function Attachment(_ref) {
40521
40593
  var _getVideoAttachmentCa = getVideoAttachmentCacheKeys(attachment.url, attachment.metadata),
40522
40594
  videoThumb = _getVideoAttachmentCa.videoThumb,
40523
40595
  originalVideoCacheKey = _getVideoAttachmentCa.originalVideo;
40596
+ if (sharedOriginalVideoDownload.state === 'completed' && originalVideoDownloadStartedRef.current) {
40597
+ originalVideoDownloadStartedRef.current = false;
40598
+ }
40524
40599
  if (typeof originalVideoUrlFromMap === 'string') {
40525
40600
  setAttachmentUrl(originalVideoUrlFromMap);
40526
40601
  setIsCached(true);
@@ -40599,7 +40674,7 @@ var Attachment = function Attachment(_ref) {
40599
40674
  return function () {
40600
40675
  cancelled = true;
40601
40676
  };
40602
- }, [attachment.id, attachment.type, attachment.url, attachment.metadata, attachment.attachmentUrl, isDetailsView, originalVideoUrlFromMap, connectionStatus, dispatch, messageType, attachment.size, videoDownloadRetry, isSharedOriginalVideoCancelled]);
40677
+ }, [attachment.id, attachment.type, attachment.url, attachment.metadata, attachment.attachmentUrl, isDetailsView, originalVideoUrlFromMap, connectionStatus, dispatch, messageType, attachment.size, videoDownloadRetry, isSharedOriginalVideoCancelled, sharedOriginalVideoDownload.state]);
40603
40678
  var handleResumeOriginalVideoDownload = function handleResumeOriginalVideoDownload(event) {
40604
40679
  event.stopPropagation();
40605
40680
  if (!attachment.url) return;
@@ -41206,7 +41281,7 @@ var Attachment = function Attachment(_ref) {
41206
41281
  }, _formatLargeText(isPreview ? attachment.data.name : attachment.name, fileAttachmentWidth ? fileAttachmentWidth / 12.5 : isPreview ? 18 : 30)), /*#__PURE__*/React__default.createElement(AttachmentSize, {
41207
41282
  color: selectedFileAttachmentsSizeColor || textSecondary,
41208
41283
  errorColor: errorColor
41209
- }, (isInUploadingState || downloadingFile) && sizeProgress ? bytesToSize(sizeProgress.loaded, 1) + " \u2022 " + bytesToSize(sizeProgress.total, 1) : (attachment.data && attachment.data.size || attachment.size) && bytesToSize(isPreview ? attachment.data.size : +attachment.size)))), isPreview && (/*#__PURE__*/React__default.createElement(RemoveChosenFile, {
41284
+ }, (isInUploadingState || downloadingFile) && sizeProgress ? bytesToSize(sizeProgress.loaded, 1) + " \u2022 " + bytesToSize(sizeProgress.total, 1) : (attachment.data && attachment.data.size || attachment.size) && bytesToSize(isPreview ? attachment.data.size : +attachment.size, 1)))), isPreview && (/*#__PURE__*/React__default.createElement(RemoveChosenFile, {
41210
41285
  "$backgroundColor": background,
41211
41286
  color: iconPrimary,
41212
41287
  onClick: function onClick() {
@@ -41317,7 +41392,7 @@ var AttachmentImg = styled__default.img(_templateObject13$3 || (_templateObject1
41317
41392
  }, function (props) {
41318
41393
  return props.$fadeIn && styled.css(_templateObject14$3 || (_templateObject14$3 = _taggedTemplateLiteralLoose(["\n opacity: 0;\n animation: ", " 100ms ease-in-out forwards;\n "])), mediaCrossFade);
41319
41394
  });
41320
- var VideoCont = styled__default.div(_templateObject15$2 || (_templateObject15$2 = _taggedTemplateLiteralLoose(["\n position: relative;\n cursor: pointer;\n width: 100%;\n height: ", ";\n"])), function (props) {
41395
+ var VideoCont = styled__default.div(_templateObject15$2 || (_templateObject15$2 = _taggedTemplateLiteralLoose(["\n position: relative;\n cursor: pointer;\n height: ", ";\n"])), function (props) {
41321
41396
  return props.isDetailsView && '100%';
41322
41397
  });
41323
41398
 
@@ -42565,7 +42640,7 @@ var SliderPopup = function SliderPopup(_ref) {
42565
42640
  };
42566
42641
  var handleClicks = React.useCallback(function (e) {
42567
42642
  var target = e.target;
42568
- if (!target.closest('.custom_carousel_item') && !target.closest('.custom_carousel_arrow')) {
42643
+ if (!target.closest('.slider-preview-media, .custom_video_player, .custom_carousel_arrow')) {
42569
42644
  if (currentFileType === 'image') {
42570
42645
  log.info('[MEDIA_IMAGE_SLIDER] outside click closing slider ' + JSON.stringify({
42571
42646
  channelId: channel.id,
@@ -43002,6 +43077,7 @@ var SliderPopup = function SliderPopup(_ref) {
43002
43077
  })))), isItemLoading(file.id) && file.type === 'image' && (/*#__PURE__*/React__default.createElement(ItemLoadingCont, null, /*#__PURE__*/React__default.createElement(UploadingIcon, {
43003
43078
  color: textOnPrimary
43004
43079
  }))), file.type === 'image' ? (/*#__PURE__*/React__default.createElement(React__default.Fragment, null, ((file.id === (currentFile === null || currentFile === void 0 ? void 0 : currentFile.id) ? currentAttachmentUrl : undefined) || attachmentUpdatedMap[getAttachmentURLWithVersion(file.url + '_original_image_url')] || getMediaThumbnailSource(file)) && (/*#__PURE__*/React__default.createElement("img", {
43080
+ className: 'slider-preview-media',
43005
43081
  loading: 'eager',
43006
43082
  decoding: 'async',
43007
43083
  draggable: false,
@@ -43116,7 +43192,7 @@ var IconWrapper = styled__default.span(_templateObject10$7 || (_templateObject10
43116
43192
  }, function (props) {
43117
43193
  return props.hideInMobile && "\n @media (max-width: 550px) {\n display: none;\n }\n ";
43118
43194
  });
43119
- var CarouselItem$1 = styled__default.div(_templateObject11$6 || (_templateObject11$6 = _taggedTemplateLiteralLoose(["\n position: relative;\n display: flex;\n width: calc(100% - 200px);\n height: calc(100% - 80px);\n max-width: calc(100% - 200px);\n max-height: calc(100vh - 140px);\n align-items: center;\n justify-content: center;\n z-index: 2;\n\n img,\n video {\n width: 100%;\n height: 100%;\n min-width: 0;\n min-height: 0;\n object-fit: contain;\n @media (max-width: 480px) {\n width: 100%;\n }\n }\n @media (max-width: 480px) {\n width: calc(100% - 100px);\n height: calc(100% - 48px);\n max-width: calc(100% - 100px);\n }\n\n img {\n display: block;\n }\n"])));
43195
+ var CarouselItem$1 = styled__default.div(_templateObject11$6 || (_templateObject11$6 = _taggedTemplateLiteralLoose(["\n position: relative;\n display: flex;\n width: calc(100% - 200px);\n height: calc(100% - 80px);\n max-width: calc(100% - 200px);\n max-height: calc(100vh - 140px);\n align-items: center;\n justify-content: center;\n z-index: 2;\n\n img,\n video {\n height: 100%;\n min-width: 0;\n min-height: 0;\n object-fit: contain;\n @media (max-width: 480px) {\n width: 100%;\n }\n }\n @media (max-width: 480px) {\n width: calc(100% - 100px);\n height: calc(100% - 48px);\n max-width: calc(100% - 100px);\n }\n\n img {\n display: block;\n }\n"])));
43120
43196
  var UploadCont$1 = styled__default.div(_templateObject12$5 || (_templateObject12$5 = _taggedTemplateLiteralLoose(["\n left: calc((100vw - 100%) / -2);\n top: calc((100vh - 100%) / -2);\n width: 100vw;\n height: 100vh;\n display: flex;\n align-items: center;\n justify-content: center;\n position: absolute;\n z-index: 1;\n"])));
43121
43197
  var ItemLoadingCont = styled__default.div(_templateObject13$5 || (_templateObject13$5 = _taggedTemplateLiteralLoose(["\n position: absolute;\n left: calc((100vw - 100%) / -2);\n top: calc((100vh - 100% + 60px) / -2);\n width: 100vw;\n height: 100vh;\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 1;\n"])));
43122
43198
  var ArrowButton = styled__default.button(_templateObject14$5 || (_templateObject14$5 = _taggedTemplateLiteralLoose(["\n min-width: 60px;\n max-width: 60px;\n height: 60px;\n margin-right: ", ";\n margin-left: ", ";\n border: none;\n color: ", ";\n background: transparent;\n box-sizing: border-box;\n border-radius: 50%;\n line-height: 1px;\n align-self: center;\n outline: none;\n cursor: pointer;\n visibility: ", ";\n position: absolute;\n top: 50%;\n transform: translateY(-50%);\n left: ", ";\n right: ", ";\n & > svg {\n width: 40px;\n height: 40px;\n }\n @media (max-width: 768px) {\n min-width: 36px;\n max-width: 36px;\n height: 36px;\n margin-right: ", ";\n margin-left: ", ";\n\n & > svg {\n width: 22px;\n height: 22px;\n }\n }\n @media (max-width: 450px) {\n min-width: 32px;\n max-width: 32px;\n height: 32px;\n\n & > svg {\n width: 20px;\n height: 20px;\n }\n }\n"])), function (props) {
@@ -43150,7 +43226,8 @@ var Message = function Message(_ref) {
43150
43226
  backgroundColor = _ref.backgroundColor,
43151
43227
  borderRadius = _ref.borderRadius,
43152
43228
  contactsMap = _ref.contactsMap,
43153
- setLastVisibleMessageId = _ref.setLastVisibleMessageId;
43229
+ setLastVisibleMessageId = _ref.setLastVisibleMessageId,
43230
+ renderPinnedMessagePreview = _ref.renderPinnedMessagePreview;
43154
43231
  var _useColor = useColors(),
43155
43232
  textOnPrimary = _useColor[THEME_COLORS.TEXT_ON_PRIMARY],
43156
43233
  overlayBackground = _useColor[THEME_COLORS.OVERLAY_BACKGROUND];
@@ -43168,9 +43245,13 @@ var Message = function Message(_ref) {
43168
43245
  var actorName = message.incoming ? makeUsername(message.user && contactsMap[message.user.id], message.user, getFromContacts) : 'You';
43169
43246
  var parentMessageId = ((_message$parentMessag = message.parentMessage) === null || _message$parentMessag === void 0 ? void 0 : _message$parentMessag.id) || ((_message$parentMessag2 = message.parentMessage) === null || _message$parentMessag2 === void 0 ? void 0 : _message$parentMessag2.tid) || message.parentMessageId || message.parentId;
43170
43247
  var pinnedMessagePreview = React.useMemo(function () {
43171
- return getPinnedMessagePreview(message.parentMessage);
43172
- }, [message.parentMessage]);
43248
+ return getPinnedMessagePreview(message.parentMessage, contactsMap, getFromContacts);
43249
+ }, [contactsMap, getFromContacts, message.parentMessage]);
43173
43250
  var pinnedMessageDeleted = isPinnedMessageDeleted(message.parentMessage);
43251
+ var customPinnedMessagePreview = pinnedMessageDeleted || !message.parentMessage ? null : renderPinnedMessagePreview === null || renderPinnedMessagePreview === void 0 ? void 0 : renderPinnedMessagePreview(message.parentMessage, {
43252
+ placement: 'system'
43253
+ });
43254
+ var pinnedPreview = customPinnedMessagePreview != null ? customPinnedMessagePreview : pinnedMessagePreview;
43174
43255
  var navigateToPinnedMessage = function navigateToPinnedMessage() {
43175
43256
  if (parentMessageId) navigateToMessage(parentMessageId);
43176
43257
  };
@@ -43207,7 +43288,7 @@ var Message = function Message(_ref) {
43207
43288
  onClick: navigateToPinnedMessage,
43208
43289
  disabled: !parentMessageId,
43209
43290
  "aria-label": parentMessageId ? 'Go to pinned message' : undefined
43210
- }, pinnedMessagePreview ? (/*#__PURE__*/React__default.createElement(React__default.Fragment, null, actorName + " pinned ", /*#__PURE__*/React__default.createElement(PinnedMessagePreview, null, pinnedMessageDeleted ? pinnedMessagePreview : "\"" + pinnedMessagePreview + "\""), !pinnedMessageDeleted && '.')) : actorName + " pinned a message.")) : (/*#__PURE__*/React__default.createElement("span", null, /*#__PURE__*/React__default.createElement(React__default.Fragment, null, actorName, message.body === 'CC' ? ' created this channel ' : message.body === 'CG' ? ' created this group' : message.body === 'AM' ? " added " + (!!(messageMetas && messageMetas.m) && messageMetas.m.slice(0, 5).map(function (mem) {
43291
+ }, pinnedPreview ? (/*#__PURE__*/React__default.createElement(React__default.Fragment, null, actorName + " pinned ", /*#__PURE__*/React__default.createElement(PinnedMessagePreview, null, pinnedMessageDeleted || customPinnedMessagePreview ? pinnedPreview : (/*#__PURE__*/React__default.createElement(React__default.Fragment, null, "\"", pinnedPreview, "\""))), !pinnedMessageDeleted && '.')) : actorName + " pinned a message.")) : (/*#__PURE__*/React__default.createElement("span", null, /*#__PURE__*/React__default.createElement(React__default.Fragment, null, actorName, message.body === 'CC' ? ' created this channel ' : message.body === 'CG' ? ' created this group' : message.body === 'AM' ? " added " + (!!(messageMetas && messageMetas.m) && messageMetas.m.slice(0, 5).map(function (mem) {
43211
43292
  return mem === user.id ? 'You' : " " + systemMessageUserName(mem, contactsMap[mem], message.mentionedUsers);
43212
43293
  })) + " " + (messageMetas && messageMetas.m && messageMetas.m.length > 5 ? "and " + (messageMetas.m.length - 5) + " more" : '') : message.body === 'RM' ? " removed " + (messageMetas && messageMetas.m && messageMetas.m.slice(0, 5).map(function (mem) {
43213
43294
  return mem === user.id ? 'You' : " " + systemMessageUserName(mem, contactsMap[mem], message.mentionedUsers);
@@ -43258,18 +43339,18 @@ var attachmentMetadata = function attachmentMetadata(attachment) {
43258
43339
  return {};
43259
43340
  }
43260
43341
  };
43261
- var preview = function preview(message) {
43342
+ var preview = function preview(message, contactsMap, getFromContacts) {
43262
43343
  var _message$attachments;
43263
43344
  if (isPinnedMessageDeleted(message)) return 'Deleted Message';
43264
43345
  if (message !== null && message !== void 0 && message.pollDetails) return "Poll: " + (message.pollDetails.name || message.body || 'Poll');
43265
43346
  var attachment = message === null || message === void 0 ? void 0 : (_message$attachments = message.attachments) === null || _message$attachments === void 0 ? void 0 : _message$attachments[0];
43266
- if (!attachment) return (message === null || message === void 0 ? void 0 : message.body) || (message !== null && message !== void 0 && message.forwardingDetails ? 'Shared content' : 'Message');
43347
+ if (!attachment) return getPinnedMessageBody(message, contactsMap, getFromContacts) || (message !== null && message !== void 0 && message.forwardingDetails ? 'Shared content' : 'Message');
43267
43348
  var metadata = attachmentMetadata(attachment);
43268
43349
  if (attachment.type === attachmentTypes.voice) {
43269
43350
  var duration = metadata.duration || metadata.dur || attachment.duration;
43270
43351
  return "Voice" + (duration ? ": " + formatDuration(duration) : '');
43271
43352
  }
43272
- if (message !== null && message !== void 0 && message.body) return message.body;
43353
+ if (message !== null && message !== void 0 && message.body) return getPinnedMessageBody(message, contactsMap, getFromContacts);
43273
43354
  if (attachment.type === attachmentTypes.image) return 'Photo';
43274
43355
  if (attachment.type === attachmentTypes.video) {
43275
43356
  return 'Video';
@@ -43301,10 +43382,13 @@ var PinnedMessagesBanner = function PinnedMessagesBanner(_ref) {
43301
43382
  var _active$message, _active$message2, _active$message3, _active$message3$atta, _active$message4;
43302
43383
  var channelId = _ref.channelId,
43303
43384
  pinIcon = _ref.pinIcon,
43304
- onOpenList = _ref.onOpenList;
43385
+ onOpenList = _ref.onOpenList,
43386
+ renderPinnedMessagePreview = _ref.renderPinnedMessagePreview;
43305
43387
  var dispatch = useDispatch();
43306
43388
  var pins = useSelector(pinnedMessagesSelector(channelId));
43307
43389
  var nextToken = useSelector(pinnedMessagesCursorSelector(channelId));
43390
+ var contactsMap = useSelector(contactsMapSelector);
43391
+ var getFromContacts = getShowOnlyContactUsers();
43308
43392
  var _useColor = useColors(),
43309
43393
  surface1 = _useColor[THEME_COLORS.SURFACE_1],
43310
43394
  textPrimary = _useColor[THEME_COLORS.TEXT_PRIMARY],
@@ -43377,6 +43461,9 @@ var PinnedMessagesBanner = function PinnedMessagesBanner(_ref) {
43377
43461
  });
43378
43462
  var linkPreviewImage = getLinkPreviewImage(attachment);
43379
43463
  var sourceMessageDeleted = isPinnedMessageDeleted(active.message);
43464
+ var customPinnedMessagePreview = sourceMessageDeleted ? null : renderPinnedMessagePreview === null || renderPinnedMessagePreview === void 0 ? void 0 : renderPinnedMessagePreview(active.message, {
43465
+ placement: 'banner'
43466
+ });
43380
43467
  var hasLeadingPreview = !sourceMessageDeleted && (hasAttachmentTile(attachmentForPreview) || (attachment === null || attachment === void 0 ? void 0 : attachment.type) === attachmentTypes.link);
43381
43468
  var markerFade = count <= 3 ? 'none' : index <= 1 ? 'top' : index >= count - 2 ? 'bottom' : 'both';
43382
43469
  var loadNextPage = function loadNextPage() {
@@ -43460,7 +43547,7 @@ var PinnedMessagesBanner = function PinnedMessagesBanner(_ref) {
43460
43547
  }, /*#__PURE__*/React__default.createElement("strong", null, "Pinned messages"), /*#__PURE__*/React__default.createElement(PinnedCopyPreview, {
43461
43548
  key: active.id,
43462
43549
  textPrimary: textPrimary
43463
- }, preview(active.message))), /*#__PURE__*/React__default.createElement(Controls$1, {
43550
+ }, customPinnedMessagePreview != null ? customPinnedMessagePreview : preview(active.message, contactsMap, getFromContacts))), /*#__PURE__*/React__default.createElement(Controls$1, {
43464
43551
  onClick: function onClick(event) {
43465
43552
  return event.stopPropagation();
43466
43553
  },
@@ -45726,12 +45813,14 @@ var PinnedMessagesList = function PinnedMessagesList(_ref) {
45726
45813
  };
45727
45814
  var positionNavigationControl = function positionNavigationControl(message, event) {
45728
45815
  var messageId = message.id || message.tid;
45729
- var messageContent = event.currentTarget.querySelector('.messageContent');
45816
+ var messageContent = event.querySelector('.messageContent');
45730
45817
  if (!messageId || !messageContent) return;
45731
- var rowBounds = event.currentTarget.getBoundingClientRect();
45818
+ var rowBounds = event.getBoundingClientRect();
45732
45819
  var contentBounds = messageContent.getBoundingClientRect();
45733
- var messageItem = event.currentTarget.querySelector('.message_item');
45734
- var bottom = messageItem ? Number.parseFloat(window.getComputedStyle(messageItem).marginBottom) || 0 : 0;
45820
+ var messageItem = event.querySelector('.message_item');
45821
+ var reactionContainer = event.querySelector('[data-reactions-container]');
45822
+ var itemMarginBottom = messageItem ? Number.parseFloat(window.getComputedStyle(messageItem).marginBottom) || 0 : 0;
45823
+ var bottom = itemMarginBottom + ((reactionContainer === null || reactionContainer === void 0 ? void 0 : reactionContainer.getBoundingClientRect().height) || 0);
45735
45824
  var left = message.incoming ? contentBounds.right - rowBounds.left + 8 : contentBounds.left - rowBounds.left - 36 - 8;
45736
45825
  setNavigationOffsets(function (current) {
45737
45826
  var _extends2;
@@ -45743,6 +45832,17 @@ var PinnedMessagesList = function PinnedMessagesList(_ref) {
45743
45832
  }, _extends2));
45744
45833
  });
45745
45834
  };
45835
+ React.useEffect(function () {
45836
+ if (pins) {
45837
+ for (var i = 0; i < pins.length; i++) {
45838
+ var pin = pins[i];
45839
+ var pinnedElement = document.querySelector("[data-pinned-message-id=\"" + pin.id + "\"]");
45840
+ if (pinnedElement) {
45841
+ positionNavigationControl(pin.message, pinnedElement);
45842
+ }
45843
+ }
45844
+ }
45845
+ }, [pins]);
45746
45846
  React.useLayoutEffect(function () {
45747
45847
  var element = itemsRef.current;
45748
45848
  if (!element) return;
@@ -45779,7 +45879,7 @@ var PinnedMessagesList = function PinnedMessagesList(_ref) {
45779
45879
  key: pin.id,
45780
45880
  "data-pinned-message-id": pin.id,
45781
45881
  onMouseEnter: function onMouseEnter(event) {
45782
- return positionNavigationControl(pin.message, event);
45882
+ return positionNavigationControl(pin.message, event.currentTarget);
45783
45883
  }
45784
45884
  }, renderMessage({
45785
45885
  message: pin.message,
@@ -47248,7 +47348,9 @@ function EmojisPopup(_ref2) {
47248
47348
  backgroundHovered = _useColor[THEME_COLORS.BACKGROUND_HOVERED],
47249
47349
  border = _useColor[THEME_COLORS.BORDER],
47250
47350
  iconPrimary = _useColor[THEME_COLORS.ICON_PRIMARY],
47251
- scrollbarThumbColor = _useColor[THEME_COLORS.SURFACE_2];
47351
+ scrollbarThumbColor = _useColor[THEME_COLORS.SURFACE_2],
47352
+ background = _useColor[THEME_COLORS.BACKGROUND];
47353
+ var theme = useSelector(themeSelector);
47252
47354
  var _useState = React.useState(false),
47253
47355
  rendered = _useState[0],
47254
47356
  setRendered = _useState[1];
@@ -47339,7 +47441,7 @@ function EmojisPopup(_ref2) {
47339
47441
  }, getEmojisCategoryTitle(activeCollection))), /*#__PURE__*/React__default.createElement(EmojiSection, {
47340
47442
  ref: emojiContainerRef,
47341
47443
  onScroll: handleEmojiListScroll,
47342
- scrollbarThumbColor: scrollbarThumbColor
47444
+ scrollbarThumbColor: theme === 'dark' ? background : scrollbarThumbColor
47343
47445
  }, /*#__PURE__*/React__default.createElement(AllEmojis, null, EMOJIS.map(function (emojiBigCollection, bigColIndex) {
47344
47446
  var mainCollectionKey = emojiBigCollection.key;
47345
47447
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, {
@@ -49326,6 +49428,8 @@ function ReactionsPopup(_ref) {
49326
49428
  reactionTotals = _ref.reactionTotals,
49327
49429
  reactionsDetailsPopupBorderRadius = _ref.reactionsDetailsPopupBorderRadius,
49328
49430
  reactionsDetailsPopupHeaderItemsStyle = _ref.reactionsDetailsPopupHeaderItemsStyle,
49431
+ _ref$popupZIndex = _ref.popupZIndex,
49432
+ popupZIndex = _ref$popupZIndex === void 0 ? 12 : _ref$popupZIndex,
49329
49433
  rtlDirection = _ref.rtlDirection,
49330
49434
  openUserProfile = _ref.openUserProfile;
49331
49435
  var _useColor = useColors(),
@@ -49347,6 +49451,13 @@ function ReactionsPopup(_ref) {
49347
49451
  var _useState = React.useState('all'),
49348
49452
  activeTabKey = _useState[0],
49349
49453
  setActiveTabKey = _useState[1];
49454
+ var reactionTotalsSignature = reactionTotals.map(function (_ref2) {
49455
+ var key = _ref2.key,
49456
+ count = _ref2.count,
49457
+ score = _ref2.score;
49458
+ return key + ":" + count + ":" + score;
49459
+ }).join('|');
49460
+ var reactionTotalsSignatureRef = React.useRef(reactionTotalsSignature);
49350
49461
  var _useState2 = React.useState(0),
49351
49462
  popupHeight = _useState2[0],
49352
49463
  setPopupHeight = _useState2[1];
@@ -49375,7 +49486,7 @@ function ReactionsPopup(_ref) {
49375
49486
  }
49376
49487
  };
49377
49488
  var handleClicks = function handleClicks(e) {
49378
- if (e.target.closest('.reactions_popup')) {
49489
+ if (e.target.closest('.reactions_popup') || e.target.closest('[data-reactions-container]')) {
49379
49490
  return;
49380
49491
  }
49381
49492
  if (closeIsApproved) {
@@ -49407,6 +49518,19 @@ function ReactionsPopup(_ref) {
49407
49518
  handleReactionsPopupClose();
49408
49519
  }
49409
49520
  }, [reactionTotals]);
49521
+ React.useEffect(function () {
49522
+ if (reactionTotalsSignatureRef.current === reactionTotalsSignature || !reactionTotals.length) {
49523
+ return;
49524
+ }
49525
+ reactionTotalsSignatureRef.current = reactionTotalsSignature;
49526
+ var nextActiveTabKey = activeTabKey !== 'all' && reactionTotals.some(function (reaction) {
49527
+ return reaction.key === activeTabKey;
49528
+ }) ? activeTabKey : 'all';
49529
+ if (nextActiveTabKey !== activeTabKey) {
49530
+ setActiveTabKey(nextActiveTabKey);
49531
+ }
49532
+ handleGetReactions(nextActiveTabKey === 'all' ? undefined : nextActiveTabKey);
49533
+ }, [activeTabKey, reactionTotals, reactionTotalsSignature]);
49410
49534
  var reactionsHeight = React.useMemo(function () {
49411
49535
  return reactions.length * 50 + 45;
49412
49536
  }, [reactions]);
@@ -49440,9 +49564,9 @@ function ReactionsPopup(_ref) {
49440
49564
  bottom: bottom,
49441
49565
  left: left,
49442
49566
  right: right,
49443
- zIndex: 12
49567
+ zIndex: popupZIndex
49444
49568
  };
49445
- }, [popupVerticalPosition, anchorTop, anchorBottom, horizontalPositions, rtlDirection]);
49569
+ }, [popupVerticalPosition, anchorTop, anchorBottom, horizontalPositions, popupZIndex, rtlDirection]);
49446
49570
  return /*#__PURE__*/reactDom.createPortal(/*#__PURE__*/React__default.createElement(Container$i, {
49447
49571
  ref: popupRef,
49448
49572
  popupVerticalPosition: popupVerticalPosition,
@@ -49613,9 +49737,11 @@ var MessageReactions = function MessageReactions(_ref) {
49613
49737
  reactionsContainerPadding = _ref.reactionsContainerPadding,
49614
49738
  reactionsDetailsPopupBorderRadius = _ref.reactionsDetailsPopupBorderRadius,
49615
49739
  reactionsDetailsPopupHeaderItemsStyle = _ref.reactionsDetailsPopupHeaderItemsStyle,
49740
+ popupZIndex = _ref.popupZIndex,
49616
49741
  onToggleReactionsPopup = _ref.onToggleReactionsPopup,
49617
49742
  onReactionAddDelete = _ref.onReactionAddDelete,
49618
49743
  onOpenUserProfile = _ref.onOpenUserProfile;
49744
+ var messageId = message.id || message.tid;
49619
49745
  var enableTransitionRef = React__default.useCallback(function (el) {
49620
49746
  if (!el) return;
49621
49747
  window.requestAnimationFrame(function () {
@@ -49629,15 +49755,17 @@ var MessageReactions = function MessageReactions(_ref) {
49629
49755
  anchorTop: reactionsAnchorTop,
49630
49756
  anchorBottom: reactionsAnchorBottom,
49631
49757
  reactionTotals: message.reactionTotals || [],
49632
- messageId: message.id,
49758
+ messageId: messageId,
49633
49759
  handleReactionsPopupClose: onToggleReactionsPopup,
49634
49760
  rtlDirection: rtlDirection,
49635
49761
  handleAddDeleteEmoji: onReactionAddDelete,
49636
49762
  reactionsDetailsPopupBorderRadius: reactionsDetailsPopupBorderRadius,
49637
- reactionsDetailsPopupHeaderItemsStyle: reactionsDetailsPopupHeaderItemsStyle
49763
+ reactionsDetailsPopupHeaderItemsStyle: reactionsDetailsPopupHeaderItemsStyle,
49764
+ popupZIndex: popupZIndex
49638
49765
  })), /*#__PURE__*/React__default.createElement(ReactionsContainer, {
49639
49766
  ref: enableTransitionRef,
49640
- id: message.id + "_reactions_container",
49767
+ id: messageId + "_reactions_container",
49768
+ "data-reactions-container": true,
49641
49769
  border: reactionsContainerBorder,
49642
49770
  boxShadow: reactionsContainerBoxShadow,
49643
49771
  borderRadius: reactionsContainerBorderRadius,
@@ -50788,9 +50916,10 @@ var MESSAGE_ACTIONS_HOVER_DELAY = 450;
50788
50916
  var MESSAGE_ACTIONS_FLIP_THRESHOLD = 110;
50789
50917
  var MAX_SELECTED_MESSAGES = 30;
50790
50918
  var EMOJI_POPUP_THRESHOLD = 300;
50919
+ var PIN_TYPE_PERSONAL$1 = 1;
50791
50920
  var lastMediaItemClickTime = 0;
50792
50921
  var Message$1 = function Message(_ref) {
50793
- var _tabIsActiveRef$curre, _message$pinDetails, _message$reactionTota;
50922
+ var _tabIsActiveRef$curre, _message$pinDetails, _channel$members, _message$reactionTota;
50794
50923
  var message = _ref.message,
50795
50924
  channel = _ref.channel,
50796
50925
  MessageActionsMenu = _ref.MessageActionsMenu,
@@ -51021,6 +51150,8 @@ var Message$1 = function Message(_ref) {
51021
51150
  }, [pins, message.id, message.tid]);
51022
51151
  var isPinned = !!((_message$pinDetails = message.pinDetails) !== null && _message$pinDetails !== void 0 && _message$pinDetails.pinned) || !!pinnedMessage;
51023
51152
  var canPinForAll = checkActionPermission('pinMessage');
51153
+ var user = getClient().user;
51154
+ var isSelfChannel = (channel === null || channel === void 0 ? void 0 : channel.type) === DEFAULT_CHANNEL_TYPE.DIRECT && (channel === null || channel === void 0 ? void 0 : channel.memberCount) === 1 && (channel === null || channel === void 0 ? void 0 : (_channel$members = channel.members) === null || _channel$members === void 0 ? void 0 : _channel$members.length) > 0 && (channel === null || channel === void 0 ? void 0 : channel.members[0].id) === (user === null || user === void 0 ? void 0 : user.id);
51024
51155
  var messageItemRef = React.useRef(null);
51025
51156
  var isVisible = useOnScreen(messageItemRef);
51026
51157
  var _useState = React.useState(false),
@@ -51038,14 +51169,14 @@ var Message$1 = function Message(_ref) {
51038
51169
  var prevMessageUserID = prevMessage ? getComparableUserId(prevMessage.user) : null;
51039
51170
  var current = moment(message.createdAt).startOf('day');
51040
51171
  var firstMessageInInterval = React.useMemo(function () {
51041
- return ifLatestAndHasNotPreview || !(prevMessage && current.diff(moment(prevMessage.createdAt).startOf('day'), 'days') === 0) || (prevMessage === null || prevMessage === void 0 ? void 0 : prevMessage.type) === exports.MESSAGE_TYPE.SYSTEM || unreadMessageId === prevMessage.id;
51042
- }, [prevMessage, unreadMessageId, ifLatestAndHasNotPreview]);
51172
+ return ifLatestAndHasNotPreview || !isPinnedMessagesList && !(prevMessage && current.diff(moment(prevMessage.createdAt).startOf('day'), 'days') === 0) || (prevMessage === null || prevMessage === void 0 ? void 0 : prevMessage.type) === exports.MESSAGE_TYPE.SYSTEM || unreadMessageId === (prevMessage === null || prevMessage === void 0 ? void 0 : prevMessage.id);
51173
+ }, [prevMessage, unreadMessageId, ifLatestAndHasNotPreview, isPinnedMessagesList]);
51043
51174
  var nextMessageUserID = nextMessage ? getComparableUserId(nextMessage.user) : null;
51044
51175
  var nextDay = nextMessage ? moment(nextMessage.createdAt).startOf('day') : null;
51045
51176
  var nextMessageFirstInInterval = !nextMessage || nextDay !== null && nextDay.diff(current, 'days') !== 0 || nextMessage.type === exports.MESSAGE_TYPE.SYSTEM || nextMessageStartsUnreadSection;
51046
51177
  var messageTimeVisible = showMessageTime && (showMessageTimeForEachMessage || !nextMessage);
51047
51178
  var messageStatusVisible = !message.incoming && showMessageStatus && message.state !== MESSAGE_STATUS.DELETE && (showMessageStatusForEachMessage || !nextMessage);
51048
- var renderAvatar = (!!prevMessageUserID || ifLatestAndHasNotPreview) && (prevMessageUserID !== messageUserID || firstMessageInInterval) && !(channel.type === DEFAULT_CHANNEL_TYPE.DIRECT && !showSenderNameOnDirectChannel) && !(!message.incoming && !showOwnAvatar);
51179
+ var renderAvatar = (!!prevMessageUserID || ifLatestAndHasNotPreview) && (prevMessageUserID !== messageUserID || firstMessageInInterval) && !(isPinnedMessagesList && channel.type === DEFAULT_CHANNEL_TYPE.DIRECT) && !(channel.type === DEFAULT_CHANNEL_TYPE.DIRECT && !showSenderNameOnDirectChannel) && !(!message.incoming && !showOwnAvatar);
51049
51180
  var selectionIsActive = selectedMessagesMap && selectedMessagesMap.size > 0;
51050
51181
  var isSelectedMessage = selectedMessagesMap && selectedMessagesMap.get(message.id || message.tid);
51051
51182
  var tooManySelected = selectedMessagesMap && selectedMessagesMap.size >= MAX_SELECTED_MESSAGES;
@@ -51098,11 +51229,16 @@ var Message$1 = function Message(_ref) {
51098
51229
  setMessageActionsShow(false);
51099
51230
  }, [channel.id, isPinnedMessagesList, message.id, message.tid, setInfoPopupOpen, setMessageActionsShow]);
51100
51231
  var handleTogglePinMessagePopup = React.useCallback(function () {
51232
+ if (isSelfChannel) {
51233
+ dispatch(pinMessageAC(channel.id, message, PIN_TYPE_PERSONAL$1));
51234
+ setMessageActionsShow(false);
51235
+ return;
51236
+ }
51101
51237
  setPinPopupOpen(function (prev) {
51102
51238
  return !prev;
51103
51239
  });
51104
51240
  setMessageActionsShow(false);
51105
- }, [setPinPopupOpen, setMessageActionsShow]);
51241
+ }, [channel.id, dispatch, isSelfChannel, message, setMessageActionsShow, setPinPopupOpen]);
51106
51242
  var handlePinMessage = React.useCallback(function (scope) {
51107
51243
  dispatch(pinMessageAC(channel.id, message, scope));
51108
51244
  setPinPopupOpen(false);
@@ -51169,10 +51305,10 @@ var Message$1 = function Message(_ref) {
51169
51305
  setMessageActionsShow(false);
51170
51306
  }, [message, contactsMap]);
51171
51307
  var handleToggleReactionsPopup = React.useCallback(function () {
51172
- var _messageItemRef$curre;
51173
- var reactionsContainer = document.getElementById(message.id + "_reactions_container");
51308
+ var _messageItemRef$curre, _messageItemRef$curre2;
51309
+ var reactionsContainer = (_messageItemRef$curre = messageItemRef.current) === null || _messageItemRef$curre === void 0 ? void 0 : _messageItemRef$curre.querySelector('[data-reactions-container]');
51174
51310
  var reactionsContPos = reactionsContainer === null || reactionsContainer === void 0 ? void 0 : reactionsContainer.getBoundingClientRect();
51175
- var bottomPos = (_messageItemRef$curre = messageItemRef.current) === null || _messageItemRef$curre === void 0 ? void 0 : _messageItemRef$curre.getBoundingClientRect().bottom;
51311
+ var bottomPos = (_messageItemRef$curre2 = messageItemRef.current) === null || _messageItemRef$curre2 === void 0 ? void 0 : _messageItemRef$curre2.getBoundingClientRect().bottom;
51176
51312
  var offsetBottom = bottomPos ? window.innerHeight - bottomPos : 0;
51177
51313
  setReactionsPopupPosition(offsetBottom);
51178
51314
  setReactionsPopupHorizontalPosition({
@@ -51185,15 +51321,15 @@ var Message$1 = function Message(_ref) {
51185
51321
  setReactionsPopupOpen(function (prev) {
51186
51322
  return !prev;
51187
51323
  });
51188
- }, [dispatch, message.id]);
51324
+ }, [dispatch, message.id, message.tid]);
51189
51325
  var handleMouseEnter = React.useCallback(function () {
51190
51326
  if (message.state !== MESSAGE_STATUS.DELETE && !selectionIsActive && !infoPopupOpen) {
51191
51327
  messageActionsTimeout.current = setTimeout(function () {
51192
- var _messageItemRef$curre2, _messageItemRef$curre3;
51328
+ var _messageItemRef$curre3, _messageItemRef$curre4;
51193
51329
  if (Date.now() - lastMediaItemClickTime < MESSAGE_ACTIONS_HOVER_DELAY * 2) {
51194
51330
  return;
51195
51331
  }
51196
- var msgTop = (_messageItemRef$curre2 = (_messageItemRef$curre3 = messageItemRef.current) === null || _messageItemRef$curre3 === void 0 ? void 0 : _messageItemRef$curre3.getBoundingClientRect().top) != null ? _messageItemRef$curre2 : 0;
51332
+ var msgTop = (_messageItemRef$curre3 = (_messageItemRef$curre4 = messageItemRef.current) === null || _messageItemRef$curre4 === void 0 ? void 0 : _messageItemRef$curre4.getBoundingClientRect().top) != null ? _messageItemRef$curre3 : 0;
51197
51333
  setMessageActionsBelow(msgTop < MESSAGE_ACTIONS_FLIP_THRESHOLD);
51198
51334
  setMessageActionsShow(true);
51199
51335
  dispatch(setMessageMenuOpenedAC(message.id || message.tid));
@@ -51296,6 +51432,7 @@ var Message$1 = function Message(_ref) {
51296
51432
  }
51297
51433
  }, [dispatch, selectionIsActive]);
51298
51434
  React.useEffect(function () {
51435
+ if (isPinnedMessagesList) return;
51299
51436
  if (isVisible) {
51300
51437
  if (setLastVisibleMessageId) {
51301
51438
  setLastVisibleMessageId(message);
@@ -51308,12 +51445,13 @@ var Message$1 = function Message(_ref) {
51308
51445
  } else {
51309
51446
  dispatch(removeVisibleMessageAC(message));
51310
51447
  }
51311
- }, [isVisible, setLastVisibleMessageId, message.id, handleSendReadMarker, channel.lastMessage, scrollToNewMessage.scrollToBottom, dispatch, message, isTabActive]);
51448
+ }, [isVisible, setLastVisibleMessageId, message.id, handleSendReadMarker, channel.lastMessage, scrollToNewMessage.scrollToBottom, dispatch, message, isTabActive, isPinnedMessagesList]);
51312
51449
  React.useEffect(function () {
51450
+ if (isPinnedMessagesList) return undefined;
51313
51451
  return function () {
51314
51452
  dispatch(removeVisibleMessageAC(message));
51315
51453
  };
51316
- }, [dispatch, message]);
51454
+ }, [dispatch, isPinnedMessagesList, message]);
51317
51455
  React.useEffect(function () {
51318
51456
  if (!isPinnedMessagesList && !isVisible && infoPopupOpen) {
51319
51457
  setInfoPopupOpen(false);
@@ -51361,7 +51499,7 @@ var Message$1 = function Message(_ref) {
51361
51499
  if (!reactionsPopupOpen) {
51362
51500
  return undefined;
51363
51501
  }
51364
- var scrollContainer = document.getElementById('scrollableDiv');
51502
+ var scrollContainer = document.getElementById(isPinnedMessagesList ? 'pinnedScrollableDiv' : 'scrollableDiv');
51365
51503
  if (!scrollContainer) {
51366
51504
  return undefined;
51367
51505
  }
@@ -51374,7 +51512,7 @@ var Message$1 = function Message(_ref) {
51374
51512
  return function () {
51375
51513
  scrollContainer.removeEventListener('scroll', handleChatScroll);
51376
51514
  };
51377
- }, [reactionsPopupOpen]);
51515
+ }, [isPinnedMessagesList, reactionsPopupOpen]);
51378
51516
  React.useEffect(function () {
51379
51517
  document.addEventListener('mousedown', handleClick);
51380
51518
  return function () {
@@ -51408,8 +51546,8 @@ var Message$1 = function Message(_ref) {
51408
51546
  if (!nextMessage || nextMessage.type === exports.MESSAGE_TYPE.SYSTEM) {
51409
51547
  spacingBottom = '';
51410
51548
  } else if (nextMessageStartsUnreadSection) {
51411
- spacingBottom = differentUserMessageSpacing || '16px';
51412
- } else if (nextMessageUserID && (nextMessageUserID !== messageUserID || nextMessageFirstInInterval)) {
51549
+ spacingBottom = isPinnedMessagesList ? '0' : differentUserMessageSpacing || '16px';
51550
+ } else if (nextMessageUserID && (nextMessageUserID !== messageUserID || nextMessageFirstInInterval && !isPinnedMessagesList)) {
51413
51551
  spacingBottom = differentUserMessageSpacing || '16px';
51414
51552
  }
51415
51553
  spacingTop = sameUserMessageSpacing || '6px';
@@ -51422,7 +51560,7 @@ var Message$1 = function Message(_ref) {
51422
51560
  bottom: reactionsMargin || spacingBottom,
51423
51561
  top: spacingTop
51424
51562
  };
51425
- }, [nextMessageUserID, messageUserID, nextMessageFirstInInterval, (_message$reactionTota = message.reactionTotals) === null || _message$reactionTota === void 0 ? void 0 : _message$reactionTota.length]);
51563
+ }, [nextMessageUserID, isPinnedMessagesList, messageUserID, nextMessageFirstInInterval, (_message$reactionTota = message.reactionTotals) === null || _message$reactionTota === void 0 ? void 0 : _message$reactionTota.length]);
51426
51564
  return /*#__PURE__*/React__default.createElement(MessageItem, {
51427
51565
  className: 'message_item',
51428
51566
  rtl: ownMessageOnRightSide && !message.incoming,
@@ -51457,7 +51595,7 @@ var Message$1 = function Message(_ref) {
51457
51595
  selectionIsActive: selectionIsActive,
51458
51596
  messageWidthPercent: messageWidthPercent,
51459
51597
  rtl: ownMessageOnRightSide && !message.incoming,
51460
- withAvatar: !(channel.type === DEFAULT_CHANNEL_TYPE.DIRECT && !showSenderNameOnDirectChannel) && !(!message.incoming && !showOwnAvatar),
51598
+ withAvatar: !(isPinnedMessagesList && channel.type === DEFAULT_CHANNEL_TYPE.DIRECT) && !(channel.type === DEFAULT_CHANNEL_TYPE.DIRECT && !showSenderNameOnDirectChannel) && !(!message.incoming && !showOwnAvatar),
51461
51599
  className: 'messageContent'
51462
51600
  }, message.state === MESSAGE_STATUS.FAILED && (/*#__PURE__*/React__default.createElement(FailedMessageIcon, {
51463
51601
  rtl: ownMessageOnRightSide && !message.incoming,
@@ -51467,6 +51605,7 @@ var Message$1 = function Message(_ref) {
51467
51605
  ifLatestAndHasNotPreview: ifLatestAndHasNotPreview,
51468
51606
  channel: channel,
51469
51607
  message: message,
51608
+ isPinnedMessagesList: isPinnedMessagesList,
51470
51609
  prevMessage: prevMessage,
51471
51610
  nextMessage: nextMessage,
51472
51611
  unreadMessageId: unreadMessageId,
@@ -51691,6 +51830,7 @@ var Message$1 = function Message(_ref) {
51691
51830
  reactionsContainerPadding: reactionsContainerPadding,
51692
51831
  reactionsDetailsPopupBorderRadius: reactionsDetailsPopupBorderRadius,
51693
51832
  reactionsDetailsPopupHeaderItemsStyle: reactionsDetailsPopupHeaderItemsStyle,
51833
+ popupZIndex: isPinnedMessagesList ? 30 : undefined,
51694
51834
  onToggleReactionsPopup: handleToggleReactionsPopup,
51695
51835
  onReactionAddDelete: handleReactionAddDelete,
51696
51836
  onOpenUserProfile: handleOpenUserProfile
@@ -52034,6 +52174,19 @@ var DEFAULT_MEDIA_MIME_TYPES = new Set(['image/jpeg', 'image/png', 'image/gif',
52034
52174
  var isDefaultSupportedMediaMimeType = function isDefaultSupportedMediaMimeType(mimeType) {
52035
52175
  return DEFAULT_MEDIA_MIME_TYPES.has(mimeType.toLowerCase());
52036
52176
  };
52177
+ var getClipboardFiles = function getClipboardFiles(clipboardData) {
52178
+ var files = Array.from(clipboardData.files || []);
52179
+ if (files.length) {
52180
+ return files;
52181
+ }
52182
+ return Array.from(clipboardData.items || []).filter(function (item) {
52183
+ return item.kind === 'file';
52184
+ }).map(function (item) {
52185
+ return item.getAsFile();
52186
+ }).filter(function (file) {
52187
+ return file !== null;
52188
+ });
52189
+ };
52037
52190
  var getMediaAttachmentValidationError = function getMediaAttachmentValidationError(file, _ref) {
52038
52191
  var _file$name$split$pop;
52039
52192
  var allowedExtensions = _ref.allowedExtensions,
@@ -52048,7 +52201,7 @@ var getMediaAttachmentValidationError = function getMediaAttachmentValidationErr
52048
52201
  });
52049
52202
  var extension = (_file$name$split$pop = file.name.split('.').pop()) === null || _file$name$split$pop === void 0 ? void 0 : _file$name$split$pop.toLowerCase();
52050
52203
  if (!extension || !supportedExtensions.includes(extension)) {
52051
- return invalidTypeMessage != null ? invalidTypeMessage : "Invalid file type. Allowed extensions are: " + supportedExtensions.join(', ') + ".";
52204
+ return invalidTypeMessage != null ? invalidTypeMessage : "Invalid file type.";
52052
52205
  }
52053
52206
  return null;
52054
52207
  };
@@ -52104,6 +52257,7 @@ var MessageList = function MessageList(_ref) {
52104
52257
  retractVoteIcon = _ref.retractVoteIcon,
52105
52258
  endVoteIcon = _ref.endVoteIcon,
52106
52259
  pinnedMessageIcon = _ref.pinnedMessageIcon,
52260
+ renderPinnedMessagePreview = _ref.renderPinnedMessagePreview,
52107
52261
  _ref$allowEditDeleteI = _ref.allowEditDeleteIncomingMessage,
52108
52262
  allowEditDeleteIncomingMessage = _ref$allowEditDeleteI === void 0 ? true : _ref$allowEditDeleteI,
52109
52263
  starIcon = _ref.starIcon,
@@ -52579,7 +52733,8 @@ var MessageList = function MessageList(_ref) {
52579
52733
  border: dateDividerBorder,
52580
52734
  backgroundColor: dateDividerBackgroundColor,
52581
52735
  borderRadius: dateDividerBorderRadius,
52582
- setLastVisibleMessageId: setLastVisibleMessageId
52736
+ setLastVisibleMessageId: setLastVisibleMessageId,
52737
+ renderPinnedMessagePreview: renderPinnedMessagePreview
52583
52738
  });
52584
52739
  }
52585
52740
  return /*#__PURE__*/React__default.createElement(MessageWrapper, {
@@ -52627,13 +52782,13 @@ var MessageList = function MessageList(_ref) {
52627
52782
  MessageActionsMenu: MessageActionsMenu,
52628
52783
  CustomMessageItem: CustomMessageItem,
52629
52784
  messageReaction: messageReaction,
52630
- editMessage: editMessage,
52785
+ editMessage: isPinnedMessagesList ? false : editMessage,
52631
52786
  copyMessage: copyMessage,
52632
- replyMessage: replyMessage,
52633
- replyMessageInThread: replyMessageInThread,
52787
+ replyMessage: isPinnedMessagesList ? false : replyMessage,
52788
+ replyMessageInThread: isPinnedMessagesList ? false : replyMessageInThread,
52634
52789
  deleteMessage: deleteMessage,
52635
52790
  selectMessage: selectMessage,
52636
- showInfoMessage: showInfoMessage,
52791
+ showInfoMessage: isPinnedMessagesList ? false : showInfoMessage,
52637
52792
  allowEditDeleteIncomingMessage: allowEditDeleteIncomingMessage,
52638
52793
  reportMessage: reportMessage,
52639
52794
  reactionIcon: reactionIcon,
@@ -52766,7 +52921,8 @@ var MessageList = function MessageList(_ref) {
52766
52921
  }, /*#__PURE__*/React__default.createElement(SvgChoseMedia, null)), "Drag & drop to send as media")))), /*#__PURE__*/React__default.createElement(React__default.Fragment, null, (channel === null || channel === void 0 ? void 0 : channel.id) && (/*#__PURE__*/React__default.createElement(PinnedMessagesBanner, {
52767
52922
  channelId: channel.id,
52768
52923
  pinIcon: pinnedMessageIcon,
52769
- onOpenList: openPinnedMessagesList
52924
+ onOpenList: openPinnedMessagesList,
52925
+ renderPinnedMessagePreview: renderPinnedMessagePreview
52770
52926
  })), /*#__PURE__*/React__default.createElement(ScrollViewport, null, isJumpingToItem && (/*#__PURE__*/React__default.createElement(JumpOverlay, null, /*#__PURE__*/React__default.createElement(JumpSpinner, {
52771
52927
  "$color": iconInactive
52772
52928
  }))), /*#__PURE__*/React__default.createElement(Container$j, {
@@ -52893,7 +53049,7 @@ var MessageList = function MessageList(_ref) {
52893
53049
  isUnreadMessage: false,
52894
53050
  nextMessageStartsUnreadSection: false,
52895
53051
  isHighlighted: false,
52896
- ifLatestAndHasNotPreview: false,
53052
+ ifLatestAndHasNotPreview: index === 0,
52897
53053
  registerInMessagesIndex: false,
52898
53054
  isPinnedMessagesList: true
52899
53055
  });
@@ -53021,6 +53177,7 @@ var MessagesContainer = function MessagesContainer(_ref) {
53021
53177
  retractVoteIcon = _ref.retractVoteIcon,
53022
53178
  endVoteIcon = _ref.endVoteIcon,
53023
53179
  pinnedMessageIcon = _ref.pinnedMessageIcon,
53180
+ renderPinnedMessagePreview = _ref.renderPinnedMessagePreview,
53024
53181
  reactionIconOrder = _ref.reactionIconOrder,
53025
53182
  openFrequentlyUsedReactions = _ref.openFrequentlyUsedReactions,
53026
53183
  fixEmojiCategoriesTitleOnTop = _ref.fixEmojiCategoriesTitleOnTop,
@@ -53188,6 +53345,7 @@ var MessagesContainer = function MessagesContainer(_ref) {
53188
53345
  retractVoteIcon: retractVoteIcon,
53189
53346
  endVoteIcon: endVoteIcon,
53190
53347
  pinnedMessageIcon: pinnedMessageIcon,
53348
+ renderPinnedMessagePreview: renderPinnedMessagePreview,
53191
53349
  reactionIconOrder: reactionIconOrder,
53192
53350
  openFrequentlyUsedReactions: openFrequentlyUsedReactions,
53193
53351
  fixEmojiCategoriesTitleOnTop: fixEmojiCategoriesTitleOnTop,
@@ -54810,7 +54968,9 @@ function EmojisPopup$1(_ref2) {
54810
54968
  textSecondary = _useColor[THEME_COLORS.TEXT_SECONDARY],
54811
54969
  textFootnote = _useColor[THEME_COLORS.TEXT_FOOTNOTE],
54812
54970
  border = _useColor[THEME_COLORS.BORDER],
54813
- scrollbarThumbColor = _useColor[THEME_COLORS.SURFACE_2];
54971
+ scrollbarThumbColor = _useColor[THEME_COLORS.SURFACE_2],
54972
+ background = _useColor[THEME_COLORS.BACKGROUND];
54973
+ var theme = useSelector(themeSelector);
54814
54974
  var richTextEditor;
54815
54975
  try {
54816
54976
  var _useLexicalComposerCo = LexicalComposerContext.useLexicalComposerContext(),
@@ -54889,6 +55049,7 @@ function EmojisPopup$1(_ref2) {
54889
55049
  }
54890
55050
  }, 300);
54891
55051
  }, []);
55052
+ console.log(theme, theme === 'dark' ? background : scrollbarThumbColor);
54892
55053
  return /*#__PURE__*/React__default.createElement(Container$k, {
54893
55054
  backgroundColor: backgroundSections,
54894
55055
  borderColor: border,
@@ -54921,7 +55082,7 @@ function EmojisPopup$1(_ref2) {
54921
55082
  }, getEmojisCategoryTitle(activeCollection))), /*#__PURE__*/React__default.createElement(EmojiSection$1, {
54922
55083
  ref: emojiContainerRef,
54923
55084
  onScroll: handleEmojiListScroll,
54924
- scrollbarThumbColor: scrollbarThumbColor
55085
+ scrollbarThumbColor: theme === 'dark' ? background : scrollbarThumbColor
54925
55086
  }, /*#__PURE__*/React__default.createElement(AllEmojis$1, null, EMOJIS.map(function (emojiBigCollection, bigColIndex) {
54926
55087
  var mainCollectionKey = emojiBigCollection.key;
54927
55088
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, {
@@ -55013,25 +55174,13 @@ var Emoji$1 = styled__default.li(_templateObject8$m || (_templateObject8$m = _ta
55013
55174
  return props.hoverBackgroundColor;
55014
55175
  });
55015
55176
 
55016
- var waitForImageAttachmentPreparation = function waitForImageAttachmentPreparation(attachments, preparations) {
55017
- try {
55018
- return Promise.resolve(Promise.all(attachments.filter(function (attachment) {
55019
- return attachment.type === attachmentTypes.image;
55020
- }).map(function (attachment) {
55021
- return attachment.tid ? preparations.get(attachment.tid) : undefined;
55022
- }))).then(function () {});
55023
- } catch (e) {
55024
- return Promise.reject(e);
55025
- }
55026
- };
55027
55177
  var mergePreparedAttachmentPatches = function mergePreparedAttachmentPatches(attachments, patches) {
55028
55178
  return attachments.map(function (attachment) {
55029
55179
  return _extends({}, attachment, attachment.tid ? patches.get(attachment.tid) : undefined);
55030
55180
  });
55031
55181
  };
55032
55182
  var getOutgoingAttachmentType = function getOutgoingAttachmentType(attachment) {
55033
- var _attachment$data, _attachment$data$type;
55034
- return attachment.type === attachmentTypes.file && (_attachment$data = attachment.data) !== null && _attachment$data !== void 0 && (_attachment$data$type = _attachment$data.type) !== null && _attachment$data$type !== void 0 && _attachment$data$type.startsWith('video/') ? attachmentTypes.video : attachment.type;
55183
+ return attachment.type;
55035
55184
  };
55036
55185
 
55037
55186
  var CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined';
@@ -55322,6 +55471,9 @@ var AudioRecord = function AudioRecord(_ref) {
55322
55471
  var recordButtonRef = React.useRef(null);
55323
55472
  var audioElements = React.useRef({});
55324
55473
  var intervalRef = React.useRef({});
55474
+ var isStoppingRef = React.useRef(false);
55475
+ var isStartingRef = React.useRef(false);
55476
+ var isRecordingRef = React.useRef(false);
55325
55477
  var currentRecordedFile = React.useMemo(function () {
55326
55478
  var current = getAudioRecordingFromMap(currentChannelId) || recordedFile;
55327
55479
  return current;
@@ -55399,17 +55551,13 @@ var AudioRecord = function AudioRecord(_ref) {
55399
55551
  setPlayAudio(false);
55400
55552
  clearInterval(intervalRef.current[id]);
55401
55553
  });
55402
- audio.addEventListener('error', function () {
55403
- var _audio$error;
55404
- log.error('Audio playback error:', (_audio$error = audio.error) === null || _audio$error === void 0 ? void 0 : _audio$error.message);
55405
- });
55406
55554
  audio.src = fileData.objectUrl;
55407
55555
  };
55408
55556
  var startRecording = function startRecording(cId) {
55409
55557
  try {
55410
55558
  var id = cId || currentChannelId;
55411
55559
  try {
55412
- if (recording) {
55560
+ if (recording || isRecordingRef.current) {
55413
55561
  stopRecording(true, id, false, recorder);
55414
55562
  } else if (currentRecordedFile) {
55415
55563
  if (!currentRecordedFile.dur) {
@@ -55425,8 +55573,16 @@ var AudioRecord = function AudioRecord(_ref) {
55425
55573
  dispatch(setChannelDraftMessageIsRemovedAC(id));
55426
55574
  sendRecordedFile(currentRecordedFile, id);
55427
55575
  } else {
55428
- if (!recorder) return Promise.resolve();
55576
+ if (!recorder) {
55577
+ return Promise.resolve();
55578
+ }
55579
+ if (isStartingRef.current) {
55580
+ return Promise.resolve();
55581
+ }
55582
+ isStartingRef.current = true;
55429
55583
  recorder.start().then(function () {
55584
+ isStartingRef.current = false;
55585
+ isRecordingRef.current = true;
55430
55586
  handleStartRecording();
55431
55587
  setAudioRecordingToMap(id, {
55432
55588
  file: null,
@@ -55515,17 +55671,19 @@ var AudioRecord = function AudioRecord(_ref) {
55515
55671
  };
55516
55672
  soundAllowed(stream);
55517
55673
  })["catch"](function (e) {
55674
+ isStartingRef.current = false;
55675
+ isRecordingRef.current = false;
55518
55676
  if ((e === null || e === void 0 ? void 0 : e.name) === 'NotAllowedError' || (e === null || e === void 0 ? void 0 : e.name) === 'PermissionDeniedError') {
55519
55677
  setMicrophonePermissionDenied(true);
55520
55678
  }
55521
- log.error(e);
55522
55679
  });
55523
55680
  }
55524
55681
  } catch (e) {
55682
+ isStartingRef.current = false;
55683
+ isRecordingRef.current = false;
55525
55684
  if ((e === null || e === void 0 ? void 0 : e.name) === 'NotAllowedError' || (e === null || e === void 0 ? void 0 : e.name) === 'PermissionDeniedError') {
55526
55685
  setMicrophonePermissionDenied(true);
55527
55686
  }
55528
- log.error(e);
55529
55687
  }
55530
55688
  return Promise.resolve();
55531
55689
  } catch (e) {
@@ -55533,7 +55691,12 @@ var AudioRecord = function AudioRecord(_ref) {
55533
55691
  }
55534
55692
  };
55535
55693
  var cancelRecording = React.useCallback(function () {
55694
+ if (isStoppingRef.current) {
55695
+ return;
55696
+ }
55536
55697
  handleStopRecording();
55698
+ isStartingRef.current = false;
55699
+ isRecordingRef.current = false;
55537
55700
  if (currentRecordedFile) {
55538
55701
  dispatch(setChannelDraftMessageIsRemovedAC(currentChannelId));
55539
55702
  if (currentRecordedFile.objectUrl && currentRecordedFile.objectUrl.startsWith('blob:')) {
@@ -55554,10 +55717,21 @@ var AudioRecord = function AudioRecord(_ref) {
55554
55717
  setShowRecording(false);
55555
55718
  }, [currentRecordedFile, currentChannelId, setShowRecording, setRecordedFile]);
55556
55719
  var stopRecording = React.useCallback(function (send, cId, draft, recorder) {
55720
+ var id = cId || channelId;
55721
+ if (isStoppingRef.current) {
55722
+ return;
55723
+ }
55724
+ if (!recorder) {
55725
+ return;
55726
+ }
55727
+ isStoppingRef.current = true;
55728
+ isStartingRef.current = false;
55729
+ isRecordingRef.current = false;
55557
55730
  handleStopRecording();
55558
55731
  shouldDraw = false;
55559
- var id = cId || channelId;
55560
- recorder === null || recorder === void 0 ? void 0 : recorder.stop().getMp3().then(function (_ref2) {
55732
+ Promise.resolve().then(function () {
55733
+ return recorder.stop().getMp3();
55734
+ }).then(function (_ref2) {
55561
55735
  var buffer = _ref2[0],
55562
55736
  blob = _ref2[1];
55563
55737
  var file = new File(buffer, 'record.mp3', {
@@ -55567,6 +55741,8 @@ var AudioRecord = function AudioRecord(_ref) {
55567
55741
  var audioContext = new (window.AudioContext || window.webkitAudioContext)();
55568
55742
  var reader = new FileReader();
55569
55743
  reader.onload = function (event) {
55744
+ var _event$target;
55745
+ var audioData = (_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.result;
55570
55746
  var closeDecodeContext = function closeDecodeContext() {
55571
55747
  if (audioContext.state !== 'closed') {
55572
55748
  audioContext.close()["catch"](function () {
@@ -55574,76 +55750,100 @@ var AudioRecord = function AudioRecord(_ref) {
55574
55750
  });
55575
55751
  }
55576
55752
  };
55577
- audioContext.decodeAudioData(event.target.result, function (audioBuffer) {
55753
+ var handleDecodeError = function handleDecodeError() {
55578
55754
  closeDecodeContext();
55579
- var numberOfSegments = 50;
55580
- var segmentSize = Math.floor(audioBuffer.length / numberOfSegments);
55581
- var waveform = [];
55582
- for (var i = 0; i < numberOfSegments; i++) {
55583
- var start = i * segmentSize;
55584
- var end = start + segmentSize;
55585
- var segment = audioBuffer.getChannelData(0).slice(start, end);
55586
- var maxAmplitude = 0;
55587
- for (var j = 0; j < segment.length; j++) {
55588
- var val = segment[j];
55589
- var absVal = val < 0 ? -val : val;
55590
- if (absVal > maxAmplitude) {
55591
- maxAmplitude = absVal;
55592
- }
55593
- }
55594
- waveform.push(Math.floor(maxAmplitude * 1000));
55595
- }
55596
55755
  setStartRecording(false);
55597
- var objectUrl = URL.createObjectURL(blob);
55598
- var durationInt = Math.round(audioBuffer.duration);
55599
- if (send) {
55600
- if (!durationInt) {
55601
- if (objectUrl.startsWith('blob:')) {
55602
- URL.revokeObjectURL(objectUrl);
55756
+ setShowRecording(false);
55757
+ removeAudioRecordingFromMap(id);
55758
+ dispatch(setChannelDraftMessageIsRemovedAC(id));
55759
+ isStoppingRef.current = false;
55760
+ };
55761
+ try {
55762
+ var decodeResult = audioContext.decodeAudioData(audioData, function (audioBuffer) {
55763
+ try {
55764
+ closeDecodeContext();
55765
+ var numberOfSegments = 50;
55766
+ var segmentSize = Math.floor(audioBuffer.length / numberOfSegments);
55767
+ var waveform = [];
55768
+ for (var i = 0; i < numberOfSegments; i++) {
55769
+ var start = i * segmentSize;
55770
+ var end = start + segmentSize;
55771
+ var segment = audioBuffer.getChannelData(0).slice(start, end);
55772
+ var maxAmplitude = 0;
55773
+ for (var j = 0; j < segment.length; j++) {
55774
+ var val = segment[j];
55775
+ var absVal = val < 0 ? -val : val;
55776
+ if (absVal > maxAmplitude) {
55777
+ maxAmplitude = absVal;
55778
+ }
55779
+ }
55780
+ waveform.push(Math.floor(maxAmplitude * 1000));
55603
55781
  }
55604
- setShowRecording(false);
55605
- removeAudioRecordingFromMap(id);
55606
- dispatch(setChannelDraftMessageIsRemovedAC(id));
55607
- return;
55608
- }
55609
- sendRecordedFile({
55610
- file: file,
55611
- objectUrl: objectUrl,
55612
- thumb: waveform,
55613
- dur: durationInt
55614
- }, id);
55615
- setShowRecording(false);
55616
- removeAudioRecordingFromMap(id);
55617
- dispatch(setChannelDraftMessageIsRemovedAC(id));
55618
- } else {
55619
- if (!draft) {
55620
- setRecordedFile({
55621
- file: file,
55622
- objectUrl: objectUrl,
55623
- thumb: waveform,
55624
- dur: durationInt
55625
- });
55626
- }
55627
- var audioRecording = {
55628
- file: file,
55629
- objectUrl: objectUrl,
55630
- thumb: waveform,
55631
- dur: durationInt
55632
- };
55633
- setAudioRecordingToMap(id, audioRecording);
55634
- if (draft) {
55635
- initAudioPlayback(draft, id, audioRecording);
55636
- }
55782
+ setStartRecording(false);
55783
+ var objectUrl = URL.createObjectURL(blob);
55784
+ var durationInt = Math.round(audioBuffer.duration);
55785
+ if (send) {
55786
+ if (!durationInt) {
55787
+ if (objectUrl.startsWith('blob:')) {
55788
+ URL.revokeObjectURL(objectUrl);
55789
+ }
55790
+ setShowRecording(false);
55791
+ removeAudioRecordingFromMap(id);
55792
+ dispatch(setChannelDraftMessageIsRemovedAC(id));
55793
+ isStoppingRef.current = false;
55794
+ return;
55795
+ }
55796
+ sendRecordedFile({
55797
+ file: file,
55798
+ objectUrl: objectUrl,
55799
+ thumb: waveform,
55800
+ dur: durationInt
55801
+ }, id);
55802
+ setShowRecording(false);
55803
+ removeAudioRecordingFromMap(id);
55804
+ dispatch(setChannelDraftMessageIsRemovedAC(id));
55805
+ } else {
55806
+ if (!draft) {
55807
+ setRecordedFile({
55808
+ file: file,
55809
+ objectUrl: objectUrl,
55810
+ thumb: waveform,
55811
+ dur: durationInt
55812
+ });
55813
+ }
55814
+ var audioRecording = {
55815
+ file: file,
55816
+ objectUrl: objectUrl,
55817
+ thumb: waveform,
55818
+ dur: durationInt
55819
+ };
55820
+ setAudioRecordingToMap(id, audioRecording);
55821
+ if (draft) {
55822
+ initAudioPlayback(draft, id, audioRecording);
55823
+ }
55824
+ }
55825
+ isStoppingRef.current = false;
55826
+ } catch (_unused) {}
55827
+ }, handleDecodeError);
55828
+ if (decodeResult && typeof decodeResult["catch"] === 'function') {
55829
+ decodeResult["catch"](function () {
55830
+ return undefined;
55831
+ });
55637
55832
  }
55638
- }, function (e) {
55639
- closeDecodeContext();
55640
- log.info('Error decoding audio data: ' + e.err);
55641
- });
55833
+ } catch (_unused2) {}
55834
+ };
55835
+ reader.onerror = function () {
55836
+ if (audioContext.state !== 'closed') {
55837
+ audioContext.close()["catch"](function () {
55838
+ return undefined;
55839
+ });
55840
+ }
55841
+ isStoppingRef.current = false;
55642
55842
  };
55643
55843
  reader.readAsArrayBuffer(blob);
55644
- })["catch"](function (e) {
55844
+ })["catch"](function () {
55845
+ isStoppingRef.current = false;
55645
55846
  handleStopRecording();
55646
- log.error(e);
55647
55847
  });
55648
55848
  }, [sendRecordedFile, setShowRecording, setAudioRecordingToMap, setRecordedFile, handleStopRecording, channelId]);
55649
55849
  var handlePlayPause = function handlePlayPause(cId) {
@@ -55660,8 +55860,7 @@ var AudioRecord = function AudioRecord(_ref) {
55660
55860
  setCurrentTimeSeconds(time);
55661
55861
  }
55662
55862
  }, 10);
55663
- audio.play()["catch"](function (e) {
55664
- log.error('Audio play failed:', e);
55863
+ audio.play()["catch"](function () {
55665
55864
  setPlayAudio(false);
55666
55865
  });
55667
55866
  } else {
@@ -55755,9 +55954,7 @@ var AudioRecord = function AudioRecord(_ref) {
55755
55954
  bitRate: 128
55756
55955
  });
55757
55956
  setRecorder(newRecorder);
55758
- } catch (e) {
55759
- log.error('Failed to init mic-recorder-to-mp3', e);
55760
- }
55957
+ } catch (_unused3) {}
55761
55958
  }
55762
55959
  } catch (e) {
55763
55960
  Promise.reject(e);
@@ -56414,6 +56611,52 @@ var SettingItem = styled__default.div(_templateObject9$k || (_templateObject9$k
56414
56611
  return props.color;
56415
56612
  });
56416
56613
 
56614
+ var getDraftHandoff = function getDraftHandoff(_ref) {
56615
+ var channelId = _ref.channelId,
56616
+ nextChannelId = _ref.nextChannelId,
56617
+ text = _ref.text,
56618
+ mentionedUsers = _ref.mentionedUsers,
56619
+ messageForReply = _ref.messageForReply,
56620
+ editorState = _ref.editorState,
56621
+ bodyAttributes = _ref.bodyAttributes,
56622
+ attachments = _ref.attachments,
56623
+ viewOnce = _ref.viewOnce;
56624
+ if (!channelId || channelId === nextChannelId) {
56625
+ return null;
56626
+ }
56627
+ if (text.trim() || attachments.length) {
56628
+ return {
56629
+ channelId: channelId,
56630
+ draft: {
56631
+ text: text,
56632
+ mentionedUsers: mentionedUsers,
56633
+ messageForReply: messageForReply,
56634
+ editorState: editorState,
56635
+ bodyAttributes: bodyAttributes,
56636
+ attachments: attachments,
56637
+ viewOnce: viewOnce
56638
+ },
56639
+ persist: true
56640
+ };
56641
+ }
56642
+ if (messageForReply) {
56643
+ return {
56644
+ channelId: channelId,
56645
+ draft: {
56646
+ text: '',
56647
+ mentionedUsers: mentionedUsers,
56648
+ messageForReply: messageForReply,
56649
+ editorState: editorState,
56650
+ bodyAttributes: bodyAttributes,
56651
+ attachments: [],
56652
+ viewOnce: false
56653
+ },
56654
+ persist: false
56655
+ };
56656
+ }
56657
+ return null;
56658
+ };
56659
+
56417
56660
  var _templateObject$Z, _templateObject2$V, _templateObject3$L, _templateObject4$E, _templateObject5$A, _templateObject6$v, _templateObject7$r, _templateObject8$o, _templateObject9$l, _templateObject0$j, _templateObject1$f, _templateObject10$d, _templateObject11$a, _templateObject12$9, _templateObject13$7, _templateObject14$6, _templateObject15$4, _templateObject16$3, _templateObject17$3, _templateObject18$3, _templateObject19$3, _templateObject20$3, _templateObject21$3, _templateObject22$2, _templateObject23$2, _templateObject24$2, _templateObject25$2, _templateObject26$2, _templateObject27$2, _templateObject28$2, _templateObject29$2, _templateObject30$2, _templateObject31$1, _templateObject32$1, _templateObject33$1, _templateObject34$1, _templateObject35$1, _templateObject36$1, _templateObject37$1, _templateObject38$1, _templateObject39$1, _templateObject40$1, _templateObject41$1, _templateObject42, _templateObject43, _templateObject44, _templateObject45, _templateObject46;
56418
56661
  function AutoFocusPlugin(_ref) {
56419
56662
  var messageForReply = _ref.messageForReply;
@@ -56478,8 +56721,9 @@ function ClearEditorPlugin(_ref2) {
56478
56721
  function onError(error) {
56479
56722
  log.error(error);
56480
56723
  }
56481
- var prevActiveChannelId;
56482
56724
  var attachmentsUpdate = [];
56725
+ var UNSUPPORTED_PASTED_FILE_MESSAGE = 'This file format is not supported.';
56726
+ var useComposerLayoutEffect = CAN_USE_DOM ? React.useLayoutEffect : React.useEffect;
56483
56727
  var SendMessageInput = function SendMessageInput(_ref3) {
56484
56728
  var _linkPreview$metadata9, _linkPreview$metadata0, _linkPreview$metadata1, _linkPreview$metadata10, _linkPreview$metadata11, _linkPreview$metadata12, _linkPreview$metadata13, _linkPreview$metadata14, _linkPreview$metadata15, _linkPreview$metadata16, _linkPreview$metadata17, _linkPreview$metadata18, _linkPreview$metadata19, _linkPreview$metadata20, _linkPreview$metadata21, _pollOptions$choosePo, _getAudioRecordingFro2;
56485
56729
  var handleAttachmentSelected = _ref3.handleAttachmentSelected,
@@ -56608,101 +56852,116 @@ var SendMessageInput = function SendMessageInput(_ref3) {
56608
56852
  var _useState = React.useState(false),
56609
56853
  showRecording = _useState[0],
56610
56854
  setShowRecording = _useState[1];
56855
+ var _useState2 = React.useState(0),
56856
+ setAudioRecordingRevision = _useState2[1];
56857
+ var handleShowRecording = React.useCallback(function (start) {
56858
+ setShowRecording(start);
56859
+ setAudioRecordingRevision(function (revision) {
56860
+ return revision + 1;
56861
+ });
56862
+ }, []);
56611
56863
  var _usePermissions = usePermissions(activeChannel.userRole),
56612
56864
  checkActionPermission = _usePermissions[0];
56613
- var _useState2 = React.useState(false),
56614
- listenerIsAdded = _useState2[0],
56615
- setListenerIsAdded = _useState2[1];
56616
- var _useState3 = React.useState(''),
56617
- messageText = _useState3[0],
56618
- setMessageText = _useState3[1];
56865
+ var _useState3 = React.useState(false),
56866
+ listenerIsAdded = _useState3[0],
56867
+ setListenerIsAdded = _useState3[1];
56619
56868
  var _useState4 = React.useState(''),
56620
- editMessageText = _useState4[0],
56621
- setEditMessageText = _useState4[1];
56622
- var _useState5 = React.useState(null),
56623
- restoredEditMessage = _useState5[0],
56624
- setRestoredEditMessage = _useState5[1];
56625
- var _useState6 = React.useState({}),
56626
- readyVideoAttachments = _useState6[0],
56627
- setReadyVideoAttachments = _useState6[1];
56628
- var _useState7 = React.useState(false),
56629
- showChooseAttachmentType = _useState7[0],
56630
- setShowChooseAttachmentType = _useState7[1];
56869
+ messageText = _useState4[0],
56870
+ setMessageText = _useState4[1];
56871
+ var _useState5 = React.useState(''),
56872
+ editMessageText = _useState5[0],
56873
+ setEditMessageText = _useState5[1];
56874
+ var _useState6 = React.useState(null),
56875
+ restoredEditMessage = _useState6[0],
56876
+ setRestoredEditMessage = _useState6[1];
56877
+ var _useState7 = React.useState({}),
56878
+ readyVideoAttachments = _useState7[0],
56879
+ setReadyVideoAttachments = _useState7[1];
56631
56880
  var _useState8 = React.useState(false),
56632
- isEmojisOpened = _useState8[0],
56633
- setIsEmojisOpened = _useState8[1];
56881
+ showChooseAttachmentType = _useState8[0],
56882
+ setShowChooseAttachmentType = _useState8[1];
56634
56883
  var _useState9 = React.useState(false),
56635
- emojisInRightSide = _useState9[0],
56636
- setEmojisInRightSide = _useState9[1];
56637
- var _useState0 = React.useState(0),
56638
- emojisPopupLeftPosition = _useState0[0],
56639
- setEmojisPopupLeftPosition = _useState0[1];
56884
+ isEmojisOpened = _useState9[0],
56885
+ setIsEmojisOpened = _useState9[1];
56886
+ var _useState0 = React.useState(false),
56887
+ emojisInRightSide = _useState0[0],
56888
+ setEmojisInRightSide = _useState0[1];
56640
56889
  var _useState1 = React.useState(0),
56641
- emojisPopupBottomPosition = _useState1[0],
56642
- setEmojisPopupBottomPosition = _useState1[1];
56643
- var _useState10 = React.useState(false),
56644
- addAttachmentsInRightSide = _useState10[0],
56645
- setAddAttachmentsInRightSide = _useState10[1];
56890
+ emojisPopupLeftPosition = _useState1[0],
56891
+ setEmojisPopupLeftPosition = _useState1[1];
56892
+ var _useState10 = React.useState(0),
56893
+ emojisPopupBottomPosition = _useState10[0],
56894
+ setEmojisPopupBottomPosition = _useState10[1];
56646
56895
  var _useState11 = React.useState(false),
56647
- showPoll = _useState11[0],
56648
- setShowPoll = _useState11[1];
56649
- var _useState12 = React.useState({
56896
+ addAttachmentsInRightSide = _useState11[0],
56897
+ setAddAttachmentsInRightSide = _useState11[1];
56898
+ var _useState12 = React.useState(false),
56899
+ showPoll = _useState12[0],
56900
+ setShowPoll = _useState12[1];
56901
+ var _useState13 = React.useState({
56650
56902
  clear: false
56651
56903
  }),
56652
- shouldClearEditor = _useState12[0],
56653
- setShouldClearEditor = _useState12[1];
56654
- var _useState13 = React.useState([]),
56655
- messageBodyAttributes = _useState13[0],
56656
- setMessageBodyAttributes = _useState13[1];
56904
+ shouldClearEditor = _useState13[0],
56905
+ setShouldClearEditor = _useState13[1];
56657
56906
  var _useState14 = React.useState([]),
56658
- mentionedUsers = _useState14[0],
56659
- setMentionedUsers = _useState14[1];
56660
- var _useState15 = React.useState(''),
56661
- browser = _useState15[0],
56662
- setBrowser = _useState15[1];
56663
- var _useState16 = React.useState(false),
56664
- mentionsIsOpen = _useState16[0],
56665
- setMentionsIsOpen = _useState16[1];
56666
- var _useState17 = React.useState(),
56667
- inputContainerHeight = _useState17[0],
56668
- setInputContainerHeight = _useState17[1];
56669
- var selectedText = React.useRef(null);
56907
+ messageBodyAttributes = _useState14[0],
56908
+ setMessageBodyAttributes = _useState14[1];
56909
+ var _useState15 = React.useState([]),
56910
+ mentionedUsers = _useState15[0],
56911
+ setMentionedUsers = _useState15[1];
56912
+ var _useState16 = React.useState(''),
56913
+ browser = _useState16[0],
56914
+ setBrowser = _useState16[1];
56915
+ var _useState17 = React.useState(false),
56916
+ mentionsIsOpen = _useState17[0],
56917
+ setMentionsIsOpen = _useState17[1];
56670
56918
  var _useState18 = React.useState(),
56671
- typingTimout = _useState18[0],
56672
- setTypingTimout = _useState18[1];
56919
+ inputContainerHeight = _useState18[0],
56920
+ setInputContainerHeight = _useState18[1];
56921
+ var selectedText = React.useRef(null);
56673
56922
  var _useState19 = React.useState(),
56674
- inTypingStateTimout = _useState19[0],
56675
- setInTypingStateTimout = _useState19[1];
56676
- var _useState20 = React.useState(false),
56677
- inTypingState = _useState20[0],
56678
- setInTypingState = _useState20[1];
56923
+ typingTimout = _useState19[0],
56924
+ setTypingTimout = _useState19[1];
56925
+ var _useState20 = React.useState(),
56926
+ inTypingStateTimout = _useState20[0],
56927
+ setInTypingStateTimout = _useState20[1];
56679
56928
  var _useState21 = React.useState(false),
56680
- sendMessageIsActive = _useState21[0],
56681
- setSendMessageIsActive = _useState21[1];
56682
- var _useState22 = React.useState([]),
56683
- attachments = _useState22[0],
56684
- setAttachments = _useState22[1];
56929
+ inTypingState = _useState21[0],
56930
+ setInTypingState = _useState21[1];
56931
+ var _useState22 = React.useState(false),
56932
+ sendMessageIsActive = _useState22[0],
56933
+ setSendMessageIsActive = _useState22[1];
56685
56934
  var _useState23 = React.useState(false),
56686
- forwardPopupOpen = _useState23[0],
56687
- setForwardPopupOpen = _useState23[1];
56688
- var _useState24 = React.useState(false),
56689
- deletePopupOpen = _useState24[0],
56690
- setDeletePopupOpen = _useState24[1];
56935
+ isSendMessageInFlight = _useState23[0],
56936
+ setIsSendMessageInFlight = _useState23[1];
56937
+ var _useState24 = React.useState([]),
56938
+ attachments = _useState24[0],
56939
+ setAttachments = _useState24[1];
56940
+ var attachmentsRef = React.useRef([]);
56691
56941
  var _useState25 = React.useState(false),
56692
- isIncomingMessage = _useState25[0],
56693
- setIsIncomingMessage = _useState25[1];
56694
- var _useState26 = React.useState('.jpg,.jpeg,.png,.gif,.mp4,.mov,.avi,.wmv,.flv,.webm,.jfif'),
56695
- mediaExtensions = _useState26[0],
56696
- setMediaExtensions = _useState26[1];
56697
- var _useState27 = React.useState(''),
56698
- uploadErrorMessage = _useState27[0],
56699
- setUploadErrorMessage = _useState27[1];
56700
- var _useState28 = React.useState(false),
56701
- viewOnce = _useState28[0],
56702
- setViewOnce = _useState28[1];
56703
- var _useState29 = React.useState(areDraftMessagesHydrated()),
56704
- draftsHydrated = _useState29[0],
56705
- setDraftsHydrated = _useState29[1];
56942
+ forwardPopupOpen = _useState25[0],
56943
+ setForwardPopupOpen = _useState25[1];
56944
+ var _useState26 = React.useState(false),
56945
+ deletePopupOpen = _useState26[0],
56946
+ setDeletePopupOpen = _useState26[1];
56947
+ var _useState27 = React.useState(false),
56948
+ isIncomingMessage = _useState27[0],
56949
+ setIsIncomingMessage = _useState27[1];
56950
+ var _useState28 = React.useState('.jpg,.jpeg,.png,.gif,.mp4,.mov,.avi,.wmv,.flv,.webm,.jfif'),
56951
+ mediaExtensions = _useState28[0],
56952
+ setMediaExtensions = _useState28[1];
56953
+ var _useState29 = React.useState(''),
56954
+ uploadErrorMessage = _useState29[0],
56955
+ setUploadErrorMessage = _useState29[1];
56956
+ var _useState30 = React.useState(false),
56957
+ viewOnce = _useState30[0],
56958
+ setViewOnce = _useState30[1];
56959
+ var _useState31 = React.useState(areDraftMessagesHydrated()),
56960
+ draftsHydrated = _useState31[0],
56961
+ setDraftsHydrated = _useState31[1];
56962
+ var _useState32 = React.useState(activeChannel.id || ''),
56963
+ composerChannelId = _useState32[0],
56964
+ setComposerChannelId = _useState32[1];
56706
56965
  var typingOrRecordingIndicator = useSelector(typingOrRecordingIndicatorArraySelector(activeChannel.id));
56707
56966
  var contactsMap = useSelector(contactsMapSelector);
56708
56967
  var connectionStatus = useSelector(connectionStatusSelector, reactRedux.shallowEqual);
@@ -56715,40 +56974,47 @@ var SendMessageInput = function SendMessageInput(_ref3) {
56715
56974
  var metadataDebounceRef = React.useRef(null);
56716
56975
  var attachmentPreparationPromisesRef = React.useRef(new Map());
56717
56976
  var preparedAttachmentPatchesRef = React.useRef(new Map());
56977
+ var isSendMessageInFlightRef = React.useRef(false);
56718
56978
  var sendMessageWrapperRef = React.useRef(null);
56719
56979
  var restoringDraftRef = React.useRef(false);
56720
56980
  var restoredDraftChannelIdRef = React.useRef(null);
56721
56981
  var isNavigatingChannelRef = React.useRef(false);
56722
- var _useState30 = React.useState(),
56723
- realEditorState = _useState30[0],
56724
- setRealEditorState = _useState30[1];
56725
- var _useState31 = React.useState(null),
56726
- floatingAnchorElem = _useState31[0],
56727
- setFloatingAnchorElem = _useState31[1];
56728
- var _useState32 = React.useState(false),
56729
- isSmallWidthViewport = _useState32[0],
56730
- setIsSmallWidthViewport = _useState32[1];
56731
- var _useState33 = React.useState(false),
56732
- isScrolling = _useState33[0],
56733
- setIsScrolling = _useState33[1];
56982
+ var releaseSendMessageLock = function releaseSendMessageLock() {
56983
+ Promise.resolve().then(function () {
56984
+ isSendMessageInFlightRef.current = false;
56985
+ setIsSendMessageInFlight(false);
56986
+ });
56987
+ };
56988
+ var _useState33 = React.useState(),
56989
+ realEditorState = _useState33[0],
56990
+ setRealEditorState = _useState33[1];
56734
56991
  var _useState34 = React.useState(null),
56735
- linkPreview = _useState34[0],
56736
- setLinkPreview = _useState34[1];
56737
- var _useState35 = React.useState(null),
56738
- detectedUrl = _useState35[0],
56739
- setDetectedUrl = _useState35[1];
56740
- var _useState36 = React.useState(new Set()),
56741
- dismissedUrls = _useState36[0],
56742
- setDismissedUrls = _useState36[1];
56743
- var _useState37 = React.useState(false),
56744
- isClosingPreview = _useState37[0],
56745
- setIsClosingPreview = _useState37[1];
56746
- var _useState38 = React.useState(false),
56747
- replyLinkPreviewImageFailed = _useState38[0],
56748
- setReplyLinkPreviewImageFailed = _useState38[1];
56749
- var _useState39 = React.useState(false),
56750
- linkPreviewImageFailed = _useState39[0],
56751
- setLinkPreviewImageFailed = _useState39[1];
56992
+ floatingAnchorElem = _useState34[0],
56993
+ setFloatingAnchorElem = _useState34[1];
56994
+ var _useState35 = React.useState(false),
56995
+ isSmallWidthViewport = _useState35[0],
56996
+ setIsSmallWidthViewport = _useState35[1];
56997
+ var _useState36 = React.useState(false),
56998
+ isScrolling = _useState36[0],
56999
+ setIsScrolling = _useState36[1];
57000
+ var _useState37 = React.useState(null),
57001
+ linkPreview = _useState37[0],
57002
+ setLinkPreview = _useState37[1];
57003
+ var _useState38 = React.useState(null),
57004
+ detectedUrl = _useState38[0],
57005
+ setDetectedUrl = _useState38[1];
57006
+ var _useState39 = React.useState(new Set()),
57007
+ dismissedUrls = _useState39[0],
57008
+ setDismissedUrls = _useState39[1];
57009
+ var _useState40 = React.useState(false),
57010
+ isClosingPreview = _useState40[0],
57011
+ setIsClosingPreview = _useState40[1];
57012
+ var _useState41 = React.useState(false),
57013
+ replyLinkPreviewImageFailed = _useState41[0],
57014
+ setReplyLinkPreviewImageFailed = _useState41[1];
57015
+ var _useState42 = React.useState(false),
57016
+ linkPreviewImageFailed = _useState42[0],
57017
+ setLinkPreviewImageFailed = _useState42[1];
56752
57018
  var addAttachmentByMenu = showChooseFileAttachment && showChooseMediaAttachment;
56753
57019
  var linkify = new LinkifyIt();
56754
57020
  var oGMetadata = useSelector(function (state) {
@@ -56759,8 +57025,52 @@ var SendMessageInput = function SendMessageInput(_ref3) {
56759
57025
  return setDraftsHydrated(areDraftMessagesHydrated());
56760
57026
  });
56761
57027
  }, []);
57028
+ useComposerLayoutEffect(function () {
57029
+ var nextChannelId = activeChannel.id || '';
57030
+ if (composerChannelId === nextChannelId) {
57031
+ return;
57032
+ }
57033
+ if (draftsHydrated) {
57034
+ var handoff = getDraftHandoff({
57035
+ channelId: composerChannelId,
57036
+ nextChannelId: nextChannelId,
57037
+ text: messageText,
57038
+ mentionedUsers: mentionedUsers,
57039
+ messageForReply: messageForReply,
57040
+ editorState: realEditorState,
57041
+ bodyAttributes: messageBodyAttributes,
57042
+ attachments: attachments,
57043
+ viewOnce: viewOnce
57044
+ });
57045
+ if (handoff) {
57046
+ setDraftMessageToMap(handoff.channelId, handoff.draft, {
57047
+ persist: handoff.persist
57048
+ });
57049
+ }
57050
+ }
57051
+ restoringDraftRef.current = false;
57052
+ restoredDraftChannelIdRef.current = null;
57053
+ isNavigatingChannelRef.current = !!messageForReply;
57054
+ setComposerChannelId(nextChannelId);
57055
+ setMessageText('');
57056
+ setEditMessageText('');
57057
+ setRestoredEditMessage(null);
57058
+ setMessageBodyAttributes([]);
57059
+ setMentionedUsers([]);
57060
+ setAttachments([]);
57061
+ attachmentsRef.current = [];
57062
+ setViewOnce(false);
57063
+ setSendMessageIsActive(false);
57064
+ setShouldClearEditor({
57065
+ clear: true
57066
+ });
57067
+ attachmentsUpdate = [];
57068
+ clearTimeout(typingTimout);
57069
+ dispatch(setMessageForReplyAC(null));
57070
+ dispatch(setMessageToEditAC(null));
57071
+ }, [activeChannel.id, composerChannelId]);
56762
57072
  React.useEffect(function () {
56763
- if (!draftsHydrated || !activeChannel.id) {
57073
+ if (!draftsHydrated || !activeChannel.id || composerChannelId !== activeChannel.id) {
56764
57074
  return;
56765
57075
  }
56766
57076
  var draftMessage = getDraftMessageFromMap(activeChannel.id);
@@ -56787,6 +57097,7 @@ var SendMessageInput = function SendMessageInput(_ref3) {
56787
57097
  setMessageText(draftMessage.text || '');
56788
57098
  setMentionedUsers(draftMessage.mentionedUsers || []);
56789
57099
  setAttachments(draftMessage.attachments || []);
57100
+ attachmentsRef.current = draftMessage.attachments || [];
56790
57101
  setViewOnce(!!draftMessage.viewOnce);
56791
57102
  if (draftMessage.messageForReply) dispatch(setMessageForReplyAC(draftMessage.messageForReply));
56792
57103
  setShouldClearEditor({
@@ -56794,7 +57105,27 @@ var SendMessageInput = function SendMessageInput(_ref3) {
56794
57105
  draftMessage: draftMessage
56795
57106
  });
56796
57107
  restoredDraftChannelIdRef.current = activeChannel.id;
56797
- }, [draftsHydrated, activeChannel.id]);
57108
+ }, [draftsHydrated, activeChannel.id, composerChannelId]);
57109
+ var setComposerMessageText = React.useCallback(function (text) {
57110
+ if (composerChannelId === activeChannel.id) {
57111
+ setMessageText(text);
57112
+ }
57113
+ }, [activeChannel.id, composerChannelId]);
57114
+ var setComposerEditMessageText = React.useCallback(function (text) {
57115
+ if (composerChannelId === activeChannel.id) {
57116
+ setEditMessageText(text);
57117
+ }
57118
+ }, [activeChannel.id, composerChannelId]);
57119
+ var setComposerMessageBodyAttributes = React.useCallback(function (attributes) {
57120
+ if (composerChannelId === activeChannel.id) {
57121
+ setMessageBodyAttributes(attributes);
57122
+ }
57123
+ }, [activeChannel.id, composerChannelId]);
57124
+ var setComposerMentionedUsers = React.useCallback(function (users) {
57125
+ if (composerChannelId === activeChannel.id) {
57126
+ setMentionedUsers(users);
57127
+ }
57128
+ }, [activeChannel.id, composerChannelId]);
56798
57129
  React.useEffect(function () {
56799
57130
  setReplyLinkPreviewImageFailed(false);
56800
57131
  }, [messageForReply === null || messageForReply === void 0 ? void 0 : messageForReply.id, messageForReply === null || messageForReply === void 0 ? void 0 : messageForReply.tid]);
@@ -56943,187 +57274,178 @@ var SendMessageInput = function SendMessageInput(_ref3) {
56943
57274
  var isEnter = (code === 'Enter' || code === 'NumpadEnter') && shiftKey === false;
56944
57275
  var isPoll = Boolean(pollDetails && pollDetails.options.length > 0 && pollDetails.name.trim());
56945
57276
  var messageTextForSend = isPoll ? pollDetails === null || pollDetails === void 0 ? void 0 : pollDetails.name.trim() : messageText.trim();
56946
- var shouldSend = (isEnter || type === 'click') && (messageToEdit || messageTextForSend || attachments.length && attachments.length > 0);
57277
+ var composerAttachments = attachmentsRef.current;
57278
+ var shouldSend = (isEnter || type === 'click') && (messageToEdit || messageTextForSend || composerAttachments.length && composerAttachments.length > 0);
56947
57279
  if (isEnter) {
56948
57280
  event.preventDefault();
56949
- if (!(messageTextForSend !== null && messageTextForSend !== void 0 && messageTextForSend.trim()) && !attachments.length && !messageToEdit) {
57281
+ if (!(messageTextForSend !== null && messageTextForSend !== void 0 && messageTextForSend.trim()) && !composerAttachments.length && !messageToEdit) {
56950
57282
  setShouldClearEditor({
56951
57283
  clear: true
56952
57284
  });
56953
57285
  }
56954
57286
  }
56955
- var _temp6 = function () {
56956
- if (shouldSend && !mentionsIsOpen) {
56957
- var _temp5 = function _temp5() {
56958
- setAttachments([]);
56959
- attachmentsUpdate = [];
56960
- removeDraftMessageFromMap(activeChannel.id);
56961
- dispatch(setChannelDraftMessageIsRemovedAC(activeChannel.id));
56962
- setViewOnce(false);
56963
- handleCloseReply();
56964
- setShouldClearEditor({
56965
- clear: true
56966
- });
56967
- setMentionedUsers([]);
56968
- setMessageBodyAttributes([]);
56969
- closePreviewWithAnimation(function () {
56970
- setDetectedUrl(null);
56971
- setDismissedUrls(new Set());
56972
- });
56973
- dispatch(setCloseSearchChannelsAC(true));
56974
- };
57287
+ if (shouldSend && !mentionsIsOpen) {
57288
+ if (isSendMessageInFlightRef.current) {
56975
57289
  event.preventDefault();
56976
57290
  event.stopPropagation();
56977
- var _temp4 = function () {
56978
- if (messageToEdit) {
56979
- handleEditMessage();
56980
- } else {
56981
- var _temp7 = function () {
56982
- if (messageTextForSend !== null && messageTextForSend !== void 0 && messageTextForSend.trim() || attachments.length && attachments.length > 0) {
56983
- var _temp2 = function _temp2() {
56984
- setMessageText('');
56985
- fileUploader.current.value = '';
56986
- if (inTypingState) {
56987
- handleSendTypingState(false);
56988
- }
56989
- clearTimeout(typingTimout);
56990
- setTypingTimout(undefined);
56991
- };
56992
- var _trimMessageBodyWithA = trimMessageBodyWithAttributes(messageText, messageBodyAttributes),
56993
- messageTexToSend = _trimMessageBodyWithA.body,
56994
- adjustedBodyAttributes = _trimMessageBodyWithA.bodyAttributes;
56995
- var messageToSend = {
56996
- body: messageTexToSend,
56997
- bodyAttributes: adjustedBodyAttributes,
56998
- mentionedUsers: [],
56999
- attachments: [],
57000
- type: 'text'
57001
- };
57002
- var mentionUsersToSend = [];
57003
- if (adjustedBodyAttributes && adjustedBodyAttributes.length) {
57004
- adjustedBodyAttributes.forEach(function (att) {
57005
- if (att.type === 'mention') {
57006
- var mentionsToFind = [].concat(mentionedUsers);
57007
- var draftMessage = getDraftMessageFromMap(activeChannel.id);
57008
- if (draftMessage) {
57009
- mentionsToFind = [].concat(draftMessage.mentionedUsers, mentionedUsers);
57010
- }
57011
- var mentionToAdd = mentionsToFind.find(function (mention) {
57012
- return mention.id === att.metadata;
57013
- });
57014
- mentionUsersToSend.push(mentionToAdd || {
57015
- id: att.metadata
57016
- });
57017
- }
57018
- });
57019
- }
57020
- messageToSend.mentionedUsers = mentionUsersToSend;
57021
- if (messageForReply) {
57022
- messageToSend.parentMessage = messageForReply;
57023
- }
57024
- var linkAttachment;
57025
- if (messageTexToSend) {
57026
- var _LinkifyIt$match;
57027
- var protocolMatch = /https?:\/\/\S+/.exec(messageTexToSend);
57028
- var linkifyMatchResult = !protocolMatch ? (_LinkifyIt$match = new LinkifyIt().match(messageTexToSend)) === null || _LinkifyIt$match === void 0 ? void 0 : _LinkifyIt$match[0] : null;
57029
- var url = protocolMatch ? protocolMatch[0] : linkifyMatchResult ? linkifyMatchResult.schema === '' ? linkifyMatchResult.url.replace(/^http:\/\//, 'https://') : linkifyMatchResult.url : null;
57030
- if (url) {
57031
- var urlMetadata = oGMetadata === null || oGMetadata === void 0 ? void 0 : oGMetadata[url];
57032
- var metadata = {};
57033
- if (urlMetadata) {
57034
- var _urlMetadata$og, _urlMetadata$og$favic, _urlMetadata$og2, _urlMetadata$og$descr, _urlMetadata$og3, _urlMetadata$og3$imag, _urlMetadata$og3$imag2, _urlMetadata$og4, _urlMetadata$og$title;
57035
- if (urlMetadata.imageWidth) metadata.szw = urlMetadata.imageWidth;
57036
- if (urlMetadata.imageHeight) metadata.szh = urlMetadata.imageHeight;
57037
- if ((_urlMetadata$og = urlMetadata.og) !== null && _urlMetadata$og !== void 0 && (_urlMetadata$og$favic = _urlMetadata$og.favicon) !== null && _urlMetadata$og$favic !== void 0 && _urlMetadata$og$favic.url) metadata.tur = urlMetadata.og.favicon.url;
57038
- if ((_urlMetadata$og2 = urlMetadata.og) !== null && _urlMetadata$og2 !== void 0 && _urlMetadata$og2.description) metadata.dsc = (_urlMetadata$og$descr = urlMetadata.og.description) === null || _urlMetadata$og$descr === void 0 ? void 0 : _urlMetadata$og$descr.slice(0, 200);
57039
- if ((_urlMetadata$og3 = urlMetadata.og) !== null && _urlMetadata$og3 !== void 0 && (_urlMetadata$og3$imag = _urlMetadata$og3.image) !== null && _urlMetadata$og3$imag !== void 0 && (_urlMetadata$og3$imag2 = _urlMetadata$og3$imag[0]) !== null && _urlMetadata$og3$imag2 !== void 0 && _urlMetadata$og3$imag2.url) metadata.iur = urlMetadata.og.image[0].url;
57040
- if ((_urlMetadata$og4 = urlMetadata.og) !== null && _urlMetadata$og4 !== void 0 && _urlMetadata$og4.title) metadata.ttl = (_urlMetadata$og$title = urlMetadata.og.title) === null || _urlMetadata$og$title === void 0 ? void 0 : _urlMetadata$og$title.slice(0, 100);
57041
- }
57042
- if (dismissedUrls.has(url)) {
57043
- metadata.hld = true;
57044
- }
57045
- linkAttachment = _extends({
57046
- type: attachmentTypes.link,
57047
- data: url,
57048
- upload: false
57049
- }, Object.keys(metadata).length > 0 ? {
57050
- metadata: metadata,
57051
- name: metadata.ttl
57052
- } : {
57053
- metadata: {
57054
- hld: true
57055
- }
57056
- });
57057
- }
57058
- }
57059
- if (hasSendableTextOrPoll(messageTexToSend, isPoll) && !attachments.length) {
57060
- if (linkAttachment) {
57061
- messageToSend.attachments = [linkAttachment];
57062
- }
57063
- if (isPoll) {
57064
- messageToSend.pollDetails = pollDetails;
57065
- messageToSend.type = 'poll';
57066
- messageToSend.body = messageTextForSend === null || messageTextForSend === void 0 ? void 0 : messageTextForSend.trim();
57067
- }
57068
- dispatch(sendTextMessageAC(messageToSend, activeChannel.id, connectionStatus));
57069
- }
57070
- var _temp = function () {
57071
- if (attachments.length) {
57072
- return Promise.resolve(waitForImageAttachmentPreparation(attachments, attachmentPreparationPromisesRef.current)).then(function () {
57073
- var sendAsSeparateMessage = getSendAttachmentsAsSeparateMessages();
57074
- messageToSend.attachments = mergePreparedAttachmentPatches(attachments, preparedAttachmentPatchesRef.current).map(function (preparedAttachment) {
57075
- return {
57076
- name: preparedAttachment.data.name,
57077
- data: preparedAttachment.data,
57078
- attachmentUrl: preparedAttachment.attachmentUrl,
57079
- tid: preparedAttachment.tid,
57080
- cachedUrl: preparedAttachment.cachedUrl,
57081
- upload: preparedAttachment.upload,
57082
- metadata: preparedAttachment.metadata,
57083
- type: getOutgoingAttachmentType(preparedAttachment),
57084
- size: preparedAttachment.size,
57085
- thumbnailState: preparedAttachment.thumbnailState
57086
- };
57087
- });
57088
- if (viewOnce && canShowViewOnceToggle) {
57089
- messageToSend.viewOnce = true;
57090
- }
57091
- var attachmentsToSent = [].concat(messageToSend.attachments);
57092
- if (linkAttachment && !messageToSend.viewOnce) {
57093
- attachmentsToSent.push(linkAttachment);
57094
- }
57095
- dispatch(sendMessageAC(_extends({}, messageToSend, {
57096
- attachments: attachmentsToSent
57097
- }), activeChannel.id, connectionStatus, sendAsSeparateMessage));
57098
- attachments.forEach(function (attachment) {
57099
- attachmentPreparationPromisesRef.current["delete"](attachment.tid);
57100
- preparedAttachmentPatchesRef.current["delete"](attachment.tid);
57101
- });
57102
- });
57103
- }
57104
- }();
57105
- return _temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp);
57291
+ return Promise.resolve();
57292
+ }
57293
+ isSendMessageInFlightRef.current = true;
57294
+ setIsSendMessageInFlight(true);
57295
+ event.preventDefault();
57296
+ event.stopPropagation();
57297
+ if (messageToEdit) {
57298
+ handleEditMessage();
57299
+ } else if (messageTextForSend !== null && messageTextForSend !== void 0 && messageTextForSend.trim() || composerAttachments.length && composerAttachments.length > 0) {
57300
+ var _trimMessageBodyWithA = trimMessageBodyWithAttributes(messageText, messageBodyAttributes),
57301
+ messageTexToSend = _trimMessageBodyWithA.body,
57302
+ adjustedBodyAttributes = _trimMessageBodyWithA.bodyAttributes;
57303
+ var messageToSend = {
57304
+ body: messageTexToSend,
57305
+ bodyAttributes: adjustedBodyAttributes,
57306
+ mentionedUsers: [],
57307
+ attachments: [],
57308
+ type: 'text'
57309
+ };
57310
+ var mentionUsersToSend = [];
57311
+ if (adjustedBodyAttributes && adjustedBodyAttributes.length) {
57312
+ adjustedBodyAttributes.forEach(function (att) {
57313
+ if (att.type === 'mention') {
57314
+ var mentionsToFind = [].concat(mentionedUsers);
57315
+ var draftMessage = getDraftMessageFromMap(activeChannel.id);
57316
+ if (draftMessage) {
57317
+ mentionsToFind = [].concat(draftMessage.mentionedUsers, mentionedUsers);
57106
57318
  }
57107
- }();
57108
- if (_temp7 && _temp7.then) return _temp7.then(function () {});
57319
+ var mentionToAdd = mentionsToFind.find(function (mention) {
57320
+ return mention.id === att.metadata;
57321
+ });
57322
+ mentionUsersToSend.push(mentionToAdd || {
57323
+ id: att.metadata
57324
+ });
57325
+ }
57326
+ });
57327
+ }
57328
+ messageToSend.mentionedUsers = mentionUsersToSend;
57329
+ if (messageForReply) {
57330
+ messageToSend.parentMessage = messageForReply;
57331
+ }
57332
+ var linkAttachment;
57333
+ if (messageTexToSend) {
57334
+ var _LinkifyIt$match;
57335
+ var protocolMatch = /https?:\/\/\S+/.exec(messageTexToSend);
57336
+ var linkifyMatchResult = !protocolMatch ? (_LinkifyIt$match = new LinkifyIt().match(messageTexToSend)) === null || _LinkifyIt$match === void 0 ? void 0 : _LinkifyIt$match[0] : null;
57337
+ var url = protocolMatch ? protocolMatch[0] : linkifyMatchResult ? linkifyMatchResult.schema === '' ? linkifyMatchResult.url.replace(/^http:\/\//, 'https://') : linkifyMatchResult.url : null;
57338
+ if (url) {
57339
+ var urlMetadata = oGMetadata === null || oGMetadata === void 0 ? void 0 : oGMetadata[url];
57340
+ var metadata = {};
57341
+ if (urlMetadata) {
57342
+ var _urlMetadata$og, _urlMetadata$og$favic, _urlMetadata$og2, _urlMetadata$og$descr, _urlMetadata$og3, _urlMetadata$og3$imag, _urlMetadata$og3$imag2, _urlMetadata$og4, _urlMetadata$og$title;
57343
+ if (urlMetadata.imageWidth) metadata.szw = urlMetadata.imageWidth;
57344
+ if (urlMetadata.imageHeight) metadata.szh = urlMetadata.imageHeight;
57345
+ if ((_urlMetadata$og = urlMetadata.og) !== null && _urlMetadata$og !== void 0 && (_urlMetadata$og$favic = _urlMetadata$og.favicon) !== null && _urlMetadata$og$favic !== void 0 && _urlMetadata$og$favic.url) metadata.tur = urlMetadata.og.favicon.url;
57346
+ if ((_urlMetadata$og2 = urlMetadata.og) !== null && _urlMetadata$og2 !== void 0 && _urlMetadata$og2.description) metadata.dsc = (_urlMetadata$og$descr = urlMetadata.og.description) === null || _urlMetadata$og$descr === void 0 ? void 0 : _urlMetadata$og$descr.slice(0, 200);
57347
+ if ((_urlMetadata$og3 = urlMetadata.og) !== null && _urlMetadata$og3 !== void 0 && (_urlMetadata$og3$imag = _urlMetadata$og3.image) !== null && _urlMetadata$og3$imag !== void 0 && (_urlMetadata$og3$imag2 = _urlMetadata$og3$imag[0]) !== null && _urlMetadata$og3$imag2 !== void 0 && _urlMetadata$og3$imag2.url) metadata.iur = urlMetadata.og.image[0].url;
57348
+ if ((_urlMetadata$og4 = urlMetadata.og) !== null && _urlMetadata$og4 !== void 0 && _urlMetadata$og4.title) metadata.ttl = (_urlMetadata$og$title = urlMetadata.og.title) === null || _urlMetadata$og$title === void 0 ? void 0 : _urlMetadata$og$title.slice(0, 100);
57349
+ }
57350
+ if (dismissedUrls.has(url)) {
57351
+ metadata.hld = true;
57352
+ }
57353
+ linkAttachment = _extends({
57354
+ type: attachmentTypes.link,
57355
+ data: url,
57356
+ upload: false
57357
+ }, Object.keys(metadata).length > 0 ? {
57358
+ metadata: metadata,
57359
+ name: metadata.ttl
57360
+ } : {
57361
+ metadata: {
57362
+ hld: true
57363
+ }
57364
+ });
57109
57365
  }
57110
- }();
57111
- return _temp4 && _temp4.then ? _temp4.then(_temp5) : _temp5(_temp4);
57112
- } else {
57113
- if (typingTimout) {
57114
- if (!inTypingStateTimout) {
57115
- handleSendTypingState(true, code);
57366
+ }
57367
+ if (hasSendableTextOrPoll(messageTexToSend, isPoll) && !composerAttachments.length) {
57368
+ if (linkAttachment) {
57369
+ messageToSend.attachments = [linkAttachment];
57116
57370
  }
57117
- clearTimeout(typingTimout);
57118
- } else {
57371
+ if (isPoll) {
57372
+ messageToSend.pollDetails = pollDetails;
57373
+ messageToSend.type = 'poll';
57374
+ messageToSend.body = messageTextForSend === null || messageTextForSend === void 0 ? void 0 : messageTextForSend.trim();
57375
+ }
57376
+ dispatch(sendTextMessageAC(messageToSend, activeChannel.id, connectionStatus));
57377
+ }
57378
+ if (composerAttachments.length) {
57379
+ var sendAsSeparateMessage = getSendAttachmentsAsSeparateMessages();
57380
+ messageToSend.attachments = mergePreparedAttachmentPatches(composerAttachments, preparedAttachmentPatchesRef.current).map(function (preparedAttachment) {
57381
+ return {
57382
+ name: preparedAttachment.data.name,
57383
+ data: preparedAttachment.data,
57384
+ attachmentUrl: preparedAttachment.attachmentUrl,
57385
+ tid: preparedAttachment.tid,
57386
+ cachedUrl: preparedAttachment.cachedUrl,
57387
+ upload: preparedAttachment.upload,
57388
+ metadata: preparedAttachment.metadata,
57389
+ type: getOutgoingAttachmentType(preparedAttachment),
57390
+ size: preparedAttachment.size,
57391
+ thumbnailState: preparedAttachment.thumbnailState
57392
+ };
57393
+ });
57394
+ if (viewOnce && canShowViewOnceToggle) {
57395
+ messageToSend.viewOnce = true;
57396
+ }
57397
+ var attachmentsToSent = [].concat(messageToSend.attachments);
57398
+ if (linkAttachment && !messageToSend.viewOnce) {
57399
+ attachmentsToSent.push(linkAttachment);
57400
+ }
57401
+ dispatch(sendMessageAC(_extends({}, messageToSend, {
57402
+ attachments: attachmentsToSent
57403
+ }), activeChannel.id, connectionStatus, sendAsSeparateMessage));
57404
+ composerAttachments.forEach(function (attachment) {
57405
+ attachmentPreparationPromisesRef.current["delete"](attachment.tid);
57406
+ preparedAttachmentPatchesRef.current["delete"](attachment.tid);
57407
+ });
57408
+ }
57409
+ setMessageText('');
57410
+ fileUploader.current.value = '';
57411
+ if (inTypingState) {
57412
+ handleSendTypingState(false);
57413
+ }
57414
+ clearTimeout(typingTimout);
57415
+ setTypingTimout(undefined);
57416
+ }
57417
+ setAttachments([]);
57418
+ attachmentsRef.current = [];
57419
+ attachmentsUpdate = [];
57420
+ removeDraftMessageFromMap(activeChannel.id);
57421
+ dispatch(setChannelDraftMessageIsRemovedAC(activeChannel.id));
57422
+ setViewOnce(false);
57423
+ handleCloseReply();
57424
+ setShouldClearEditor({
57425
+ clear: true
57426
+ });
57427
+ setMentionedUsers([]);
57428
+ setMessageBodyAttributes([]);
57429
+ closePreviewWithAnimation(function () {
57430
+ setDetectedUrl(null);
57431
+ setDismissedUrls(new Set());
57432
+ });
57433
+ dispatch(setCloseSearchChannelsAC(true));
57434
+ releaseSendMessageLock();
57435
+ } else {
57436
+ if (typingTimout) {
57437
+ if (!inTypingStateTimout) {
57119
57438
  handleSendTypingState(true, code);
57120
57439
  }
57121
- setTypingTimout(setTimeout(function () {
57122
- setTypingTimout(0);
57123
- }, 2000));
57440
+ clearTimeout(typingTimout);
57441
+ } else {
57442
+ handleSendTypingState(true, code);
57124
57443
  }
57125
- }();
57126
- return Promise.resolve(_temp6 && _temp6.then ? _temp6.then(function () {}) : void 0);
57444
+ setTypingTimout(setTimeout(function () {
57445
+ setTypingTimout(0);
57446
+ }, 2000));
57447
+ }
57448
+ return Promise.resolve();
57127
57449
  } catch (e) {
57128
57450
  return Promise.reject(e);
57129
57451
  }
@@ -57227,25 +57549,27 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57227
57549
  };
57228
57550
  var removeUpload = function removeUpload(attachmentId) {
57229
57551
  if (attachmentId) {
57230
- var updatedAttachments = attachmentsUpdate.filter(function (item) {
57552
+ var updatedAttachments = attachmentsRef.current.filter(function (item) {
57231
57553
  return item.tid !== attachmentId;
57232
57554
  });
57233
- clearVideoPreparation(attachmentId);
57555
+ clearAttachmentPreparation(attachmentId);
57234
57556
  attachmentPreparationPromisesRef.current["delete"](attachmentId);
57235
57557
  preparedAttachmentPatchesRef.current["delete"](attachmentId);
57236
57558
  releaseBlobUrls(["compose_" + attachmentId]);
57237
57559
  setAttachments(updatedAttachments);
57560
+ attachmentsRef.current = updatedAttachments;
57238
57561
  attachmentsUpdate = updatedAttachments;
57239
57562
  } else {
57240
- attachmentsUpdate.forEach(function (attachment) {
57241
- return clearVideoPreparation(attachment.tid);
57563
+ attachmentsRef.current.forEach(function (attachment) {
57564
+ return clearAttachmentPreparation(attachment.tid);
57242
57565
  });
57243
57566
  attachmentPreparationPromisesRef.current.clear();
57244
57567
  preparedAttachmentPatchesRef.current.clear();
57245
- releaseBlobUrls(attachmentsUpdate.map(function (item) {
57568
+ releaseBlobUrls(attachmentsRef.current.map(function (item) {
57246
57569
  return "compose_" + item.tid;
57247
57570
  }));
57248
57571
  setAttachments([]);
57572
+ attachmentsRef.current = [];
57249
57573
  attachmentsUpdate = [];
57250
57574
  }
57251
57575
  if (attachmentsUpdate.length === 0) {
@@ -57311,14 +57635,14 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57311
57635
  filesToProcess.forEach(function (file) {
57312
57636
  try {
57313
57637
  var validationError = isMediaAttachment ? validateMediaAttachment(file) : null;
57314
- var _temp8 = function () {
57638
+ var _temp = function () {
57315
57639
  if (!validationError) {
57316
57640
  return Promise.resolve(handleAddAttachmentWithViewOnceCheck(file, isMediaAttachment)).then(function () {});
57317
57641
  } else {
57318
57642
  showFileUploadError(validationError);
57319
57643
  }
57320
57644
  }();
57321
- return Promise.resolve(_temp8 && _temp8.then ? _temp8.then(function () {}) : void 0);
57645
+ return Promise.resolve(_temp && _temp.then ? _temp.then(function () {}) : void 0);
57322
57646
  } catch (e) {
57323
57647
  return Promise.reject(e);
57324
57648
  }
@@ -57340,9 +57664,9 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57340
57664
  }
57341
57665
  var os = detectOS();
57342
57666
  if (!(os === 'Windows' && browser === 'Firefox')) {
57343
- if (e.clipboardData.files && e.clipboardData.files.length > 0) {
57667
+ var fileList = getClipboardFiles(e.clipboardData);
57668
+ if (fileList.length > 0) {
57344
57669
  e.preventDefault();
57345
- var fileList = Object.values(e.clipboardData.files);
57346
57670
  var remainingSlots = MAX_ATTACHMENTS - attachments.length;
57347
57671
  if (remainingSlots <= 0) {
57348
57672
  showFileUploadError("You have reached the maximum limit of " + MAX_ATTACHMENTS + " files");
@@ -57355,15 +57679,23 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57355
57679
  }
57356
57680
  filesToProcess.forEach(function (file) {
57357
57681
  try {
57358
- var validationError = validateMediaAttachment(file);
57359
- var _temp9 = function () {
57360
- if (!validationError) {
57682
+ var mediaValidationError = validateMediaAttachment(file);
57683
+ var canAddAsMedia = showChooseMediaAttachment && !mediaValidationError;
57684
+ var _temp3 = function () {
57685
+ if (canAddAsMedia) {
57361
57686
  return Promise.resolve(handleAddAttachmentWithViewOnceCheck(file, true)).then(function () {});
57362
57687
  } else {
57363
- showFileUploadError(validationError);
57688
+ var _temp4 = function () {
57689
+ if (showChooseFileAttachment) {
57690
+ return Promise.resolve(handleAddAttachmentWithViewOnceCheck(file, false)).then(function () {});
57691
+ } else {
57692
+ showFileUploadError(mediaValidationError || allowedMediaExtensionsErrorMessage || UNSUPPORTED_PASTED_FILE_MESSAGE);
57693
+ }
57694
+ }();
57695
+ if (_temp4 && _temp4.then) return _temp4.then(function () {});
57364
57696
  }
57365
57697
  }();
57366
- return Promise.resolve(_temp9 && _temp9.then ? _temp9.then(function () {}) : void 0);
57698
+ return Promise.resolve(_temp3 && _temp3.then ? _temp3.then(function () {}) : void 0);
57367
57699
  } catch (e) {
57368
57700
  return Promise.reject(e);
57369
57701
  }
@@ -57438,9 +57770,11 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57438
57770
  dispatch(clearSelectedMessagesAC());
57439
57771
  };
57440
57772
  var handleSetMentionMember = function handleSetMentionMember(mentionMember) {
57441
- setMentionedUsers(function (prevState) {
57442
- return [].concat(prevState, [mentionMember]);
57443
- });
57773
+ if (composerChannelId === activeChannel.id) {
57774
+ setMentionedUsers(function (prevState) {
57775
+ return [].concat(prevState, [mentionMember]);
57776
+ });
57777
+ }
57444
57778
  };
57445
57779
  var createComposePreviewUrl = function createComposePreviewUrl(attachmentTid, blob) {
57446
57780
  var url = URL.createObjectURL(blob);
@@ -57465,10 +57799,10 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57465
57799
  setPendingAttachment(tid, {
57466
57800
  file: file
57467
57801
  });
57468
- if (fileType === 'video') {
57469
- beginVideoPreparation(tid, file);
57802
+ if (fileType === 'image' || fileType === 'video') {
57803
+ beginAttachmentPreparation(tid, file);
57470
57804
  }
57471
- var type = fileType === 'video' && (!customUploader || isMediaAttachment) ? 'video' : isMediaAttachment && fileType === 'image' ? 'image' : 'file';
57805
+ var type = isMediaAttachment && fileType === 'video' ? attachmentTypes.video : isMediaAttachment && fileType === 'image' ? attachmentTypes.image : attachmentTypes.file;
57472
57806
  var attachment = _extends({
57473
57807
  data: file,
57474
57808
  name: file.name,
@@ -57482,29 +57816,37 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57482
57816
  attachmentUrl: createComposePreviewUrl(tid, file),
57483
57817
  metadata: customUploader ? {} : '{}'
57484
57818
  } : {});
57485
- setAttachments(function (prevState) {
57486
- return [].concat(prevState, [attachment]);
57487
- });
57819
+ var nextAttachments = [].concat(attachmentsRef.current, [attachment]);
57820
+ attachmentsRef.current = nextAttachments;
57821
+ setAttachments(nextAttachments);
57488
57822
  var updateAttachment = function updateAttachment(patch) {
57489
57823
  preparedAttachmentPatchesRef.current.set(tid, _extends({}, preparedAttachmentPatchesRef.current.get(tid), patch));
57490
- setAttachments(function (prevState) {
57491
- return prevState.map(function (current) {
57492
- return current.tid === tid ? _extends({}, current, patch) : current;
57493
- });
57824
+ var nextAttachments = attachmentsRef.current.map(function (current) {
57825
+ return current.tid === tid ? _extends({}, current, patch) : current;
57494
57826
  });
57827
+ attachmentsRef.current = nextAttachments;
57828
+ setAttachments(nextAttachments);
57495
57829
  };
57496
57830
  var preparationPromise = new Promise(function (resolve) {
57497
57831
  return setTimeout(function () {
57498
57832
  try {
57499
57833
  return Promise.resolve(_finallyRethrows(function () {
57500
- var _temp16 = function () {
57834
+ var _temp12 = function () {
57501
57835
  if (fileType === 'image') {
57502
- var _temp10 = _catch(function () {
57836
+ var _temp8 = _catch(function () {
57503
57837
  return Promise.resolve(createImageThumbnail(file)).then(function (_ref5) {
57504
57838
  var thumbnail = _ref5.thumbnail,
57505
57839
  imageWidth = _ref5.imageWidth,
57506
57840
  imageHeight = _ref5.imageHeight;
57507
- var _temp1 = function () {
57841
+ function _temp7() {
57842
+ completeAttachmentPreparation(tid, {
57843
+ file: preparedFile,
57844
+ metadata: metadata
57845
+ });
57846
+ }
57847
+ var preparedFile = file;
57848
+ var metadata;
57849
+ var _temp6 = function () {
57508
57850
  if (customUploader) {
57509
57851
  return Promise.resolve(resizeImage(file)).then(function (resizedFile) {
57510
57852
  var patch = {
@@ -57515,11 +57857,25 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57515
57857
  tmb: thumbnail
57516
57858
  }
57517
57859
  };
57518
- updateAttachment(patch);
57860
+ if (isMediaAttachment && resizedFile !== null && resizedFile !== void 0 && resizedFile.blob) {
57861
+ preparedFile = new File([resizedFile.blob], resizedFile.file.name, {
57862
+ type: file.type
57863
+ });
57864
+ patch.size = preparedFile.size;
57865
+ updateAttachment(_extends({}, patch, {
57866
+ data: preparedFile
57867
+ }));
57868
+ setPendingAttachment(tid, {
57869
+ file: preparedFile
57870
+ });
57871
+ } else {
57872
+ updateAttachment(patch);
57873
+ }
57874
+ metadata = patch.metadata;
57519
57875
  handleAttachmentImageForCache(_extends({}, attachment, patch));
57520
57876
  });
57521
57877
  } else {
57522
- var _temp17 = function () {
57878
+ var _temp13 = function () {
57523
57879
  if (isMediaAttachment && file.type !== 'image/gif') {
57524
57880
  return Promise.resolve(resizeImage(file)).then(function (resizedFileData) {
57525
57881
  var resizedFile = resizedFileData.blob ? new File([resizedFileData.blob], resizedFileData.file.name, {
@@ -57539,30 +57895,34 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57539
57895
  file: resizedFile
57540
57896
  });
57541
57897
  handleAttachmentImageForCache(_extends({}, attachment, patch));
57898
+ preparedFile = resizedFile;
57899
+ metadata = patch.metadata;
57542
57900
  });
57543
57901
  } else {
57902
+ metadata = JSON.stringify({
57903
+ tmb: thumbnail,
57904
+ szw: imageWidth,
57905
+ szh: imageHeight
57906
+ });
57544
57907
  updateAttachment({
57545
- metadata: JSON.stringify({
57546
- tmb: thumbnail,
57547
- szw: imageWidth,
57548
- szh: imageHeight
57549
- })
57908
+ metadata: metadata
57550
57909
  });
57551
57910
  }
57552
57911
  }();
57553
- if (_temp17 && _temp17.then) return _temp17.then(function () {});
57912
+ if (_temp13 && _temp13.then) return _temp13.then(function () {});
57554
57913
  }
57555
57914
  }();
57556
- if (_temp1 && _temp1.then) return _temp1.then(function () {});
57915
+ return _temp6 && _temp6.then ? _temp6.then(_temp7) : _temp7(_temp6);
57557
57916
  });
57558
57917
  }, function (error) {
57559
57918
  log.warn('Unable to prepare image attachment preview:', error);
57919
+ failAttachmentPreparation(tid);
57560
57920
  });
57561
- if (_temp10 && _temp10.then) return _temp10.then(function () {});
57921
+ if (_temp8 && _temp8.then) return _temp8.then(function () {});
57562
57922
  } else {
57563
- var _temp18 = function () {
57923
+ var _temp14 = function () {
57564
57924
  if (fileType === 'video') {
57565
- var _temp14 = function _temp14() {
57925
+ var _temp10 = function _temp10() {
57566
57926
  return Promise.resolve(remuxPromise).then(function (uploadFile) {
57567
57927
  if (uploadFile !== file) {
57568
57928
  updateAttachment({
@@ -57575,13 +57935,13 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57575
57935
  }
57576
57936
  if (metadata) {
57577
57937
  var _frame;
57578
- completeVideoPreparation(tid, {
57938
+ completeAttachmentPreparation(tid, {
57579
57939
  file: uploadFile,
57580
57940
  metadata: metadata,
57581
57941
  videoPreviewBlob: (_frame = frame) === null || _frame === void 0 ? void 0 : _frame.blob
57582
57942
  });
57583
57943
  } else {
57584
- failVideoPreparation(tid);
57944
+ failAttachmentPreparation(tid);
57585
57945
  updateAttachment({
57586
57946
  thumbnailState: 'failed'
57587
57947
  });
@@ -57592,8 +57952,8 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57592
57952
  var thumbnailSource = file;
57593
57953
  var metadata;
57594
57954
  var frame;
57595
- var _temp13 = _catch(function () {
57596
- function _temp12() {
57955
+ var _temp1 = _catch(function () {
57956
+ function _temp0() {
57597
57957
  var _frame2 = frame,
57598
57958
  thumb = _frame2.thumb,
57599
57959
  width = _frame2.width,
@@ -57617,7 +57977,7 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57617
57977
  dispatch(setUpdateMessageAttachmentAC(thumb, frame.frameBlobUrl));
57618
57978
  setVideoIsReadyToSend(tid);
57619
57979
  }
57620
- var _temp11 = _catch(function () {
57980
+ var _temp9 = _catch(function () {
57621
57981
  return Promise.resolve(getFrame(thumbnailSource, 0)).then(function (_getFrame) {
57622
57982
  frame = _getFrame;
57623
57983
  });
@@ -57629,17 +57989,17 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57629
57989
  });
57630
57990
  });
57631
57991
  });
57632
- return _temp11 && _temp11.then ? _temp11.then(_temp12) : _temp12(_temp11);
57992
+ return _temp9 && _temp9.then ? _temp9.then(_temp0) : _temp0(_temp9);
57633
57993
  }, function (error) {
57634
57994
  log.warn('Unable to generate video thumbnail:', error);
57635
57995
  });
57636
- return _temp13 && _temp13.then ? _temp13.then(_temp14) : _temp14(_temp13);
57996
+ return _temp1 && _temp1.then ? _temp1.then(_temp10) : _temp10(_temp1);
57637
57997
  }
57638
57998
  }();
57639
- if (_temp18 && _temp18.then) return _temp18.then(function () {});
57999
+ if (_temp14 && _temp14.then) return _temp14.then(function () {});
57640
58000
  }
57641
58001
  }();
57642
- if (_temp16 && _temp16.then) return _temp16.then(function () {});
58002
+ if (_temp12 && _temp12.then) return _temp12.then(function () {});
57643
58003
  }, function (_wasThrown, _result) {
57644
58004
  resolve();
57645
58005
  if (_wasThrown) throw _result;
@@ -57650,7 +58010,7 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57650
58010
  }
57651
58011
  }, 0);
57652
58012
  });
57653
- if (fileType === 'image') {
58013
+ if (fileType === 'image' || fileType === 'video') {
57654
58014
  attachmentPreparationPromisesRef.current.set(tid, preparationPromise);
57655
58015
  }
57656
58016
  return Promise.resolve();
@@ -57697,14 +58057,14 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57697
58057
  filesToProcess.forEach(function (file) {
57698
58058
  try {
57699
58059
  var validationError = isMediaAttachment ? validateMediaAttachment(file) : null;
57700
- var _temp19 = function () {
58060
+ var _temp15 = function () {
57701
58061
  if (!validationError) {
57702
58062
  return Promise.resolve(handleAddAttachmentWithViewOnceCheck(file, isMediaAttachment)).then(function () {});
57703
58063
  } else {
57704
58064
  showFileUploadError(validationError);
57705
58065
  }
57706
58066
  }();
57707
- return Promise.resolve(_temp19 && _temp19.then ? _temp19.then(function () {}) : void 0);
58067
+ return Promise.resolve(_temp15 && _temp15.then ? _temp15.then(function () {}) : void 0);
57708
58068
  } catch (e) {
57709
58069
  return Promise.reject(e);
57710
58070
  }
@@ -57776,59 +58136,6 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57776
58136
  };
57777
58137
  }, [isSmallWidthViewport]);
57778
58138
  React.useEffect(function () {
57779
- if (prevActiveChannelId && activeChannel.id && prevActiveChannelId !== activeChannel.id) {
57780
- setMessageText('');
57781
- if (messageForReply) {
57782
- isNavigatingChannelRef.current = true;
57783
- handleCloseReply(true);
57784
- }
57785
- setAttachments([]);
57786
- attachmentsUpdate = [];
57787
- handleCloseEditMode(!!messageToEdit);
57788
- clearTimeout(typingTimout);
57789
- var draftMessage = getDraftMessageFromMap(activeChannel.id);
57790
- if (draftMessage) {
57791
- restoringDraftRef.current = true;
57792
- if (draftMessage.messageToEdit) {
57793
- var _ref6, _draftMessage$editMes2, _draftMessage$editBod2, _draftMessage$mention2;
57794
- var restoredText = (_ref6 = (_draftMessage$editMes2 = draftMessage.editMessageText) != null ? _draftMessage$editMes2 : draftMessage.messageToEdit.body) != null ? _ref6 : '';
57795
- var restoredEdit = _extends({}, draftMessage.messageToEdit, {
57796
- body: restoredText,
57797
- bodyAttributes: (_draftMessage$editBod2 = draftMessage.editBodyAttributes) != null ? _draftMessage$editBod2 : draftMessage.messageToEdit.bodyAttributes,
57798
- mentionedUsers: (_draftMessage$mention2 = draftMessage.mentionedUsers) != null ? _draftMessage$mention2 : draftMessage.messageToEdit.mentionedUsers
57799
- });
57800
- setEditMessageText(restoredText);
57801
- setMessageBodyAttributes(restoredEdit.bodyAttributes || []);
57802
- setMentionedUsers(restoredEdit.mentionedUsers || []);
57803
- setRestoredEditMessage(restoredEdit);
57804
- dispatch(setMessageToEditAC(draftMessage.messageToEdit));
57805
- restoredDraftChannelIdRef.current = activeChannel.id;
57806
- }
57807
- if (!draftMessage.messageToEdit) {
57808
- if (draftMessage.messageForReply) {
57809
- dispatch(setMessageForReplyAC(draftMessage.messageForReply));
57810
- }
57811
- setMessageText(draftMessage.text);
57812
- setMentionedUsers(draftMessage.mentionedUsers);
57813
- setAttachments(draftMessage.attachments || []);
57814
- setViewOnce(!!draftMessage.viewOnce);
57815
- restoredDraftChannelIdRef.current = activeChannel.id;
57816
- setShouldClearEditor({
57817
- clear: true,
57818
- draftMessage: draftMessage
57819
- });
57820
- }
57821
- } else {
57822
- setMentionedUsers([]);
57823
- setShouldClearEditor({
57824
- clear: true,
57825
- draftMessage: draftMessage
57826
- });
57827
- }
57828
- }
57829
- if (activeChannel.id) {
57830
- prevActiveChannelId = activeChannel.id;
57831
- }
57832
58139
  if (activeChannel.id && membersHasNext === undefined && !(activeChannel.type === DEFAULT_CHANNEL_TYPE.DIRECT && activeChannel.memberCount === 2)) {
57833
58140
  dispatch(getMembersAC(activeChannel.id));
57834
58141
  }
@@ -57837,6 +58144,9 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57837
58144
  if (!draftsHydrated) {
57838
58145
  return;
57839
58146
  }
58147
+ if (!activeChannel.id || composerChannelId !== activeChannel.id) {
58148
+ return;
58149
+ }
57840
58150
  if (restoringDraftRef.current) {
57841
58151
  restoringDraftRef.current = false;
57842
58152
  return;
@@ -57923,9 +58233,9 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57923
58233
  document.body.removeAttribute('onbeforeunload');
57924
58234
  }
57925
58235
  }
57926
- }, [messageText, attachments, editMessageText, readyVideoAttachments, messageBodyAttributes, messageToEdit, viewOnce, draftsHydrated]);
58236
+ }, [messageText, attachments, editMessageText, readyVideoAttachments, messageBodyAttributes, messageToEdit, viewOnce, draftsHydrated, activeChannel.id, composerChannelId]);
57927
58237
  useDidUpdate(function () {
57928
- if (!messageToEdit && mentionedUsers && mentionedUsers.length) {
58238
+ if (composerChannelId === activeChannel.id && !messageToEdit && mentionedUsers && mentionedUsers.length) {
57929
58239
  setDraftMessageToMap(activeChannel.id, {
57930
58240
  text: messageText,
57931
58241
  mentionedUsers: mentionedUsers,
@@ -57937,7 +58247,7 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57937
58247
  persist: !!(messageText.trim() || attachments.length)
57938
58248
  });
57939
58249
  }
57940
- }, [mentionedUsers]);
58250
+ }, [mentionedUsers, activeChannel.id, composerChannelId]);
57941
58251
  useDidUpdate(function () {
57942
58252
  var _getAudioRecordingFro;
57943
58253
  if (handleAttachmentSelected) {
@@ -57951,6 +58261,7 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57951
58261
  }
57952
58262
  }
57953
58263
  attachmentsUpdate = attachments;
58264
+ attachmentsRef.current = attachments;
57954
58265
  var hasAudioRecording = showRecording || ((_getAudioRecordingFro = getAudioRecordingFromMap(activeChannel === null || activeChannel === void 0 ? void 0 : activeChannel.id)) === null || _getAudioRecordingFro === void 0 ? void 0 : _getAudioRecordingFro.file);
57955
58266
  if (viewOnce && attachments.length !== 1 && !hasAudioRecording) {
57956
58267
  setViewOnce(false);
@@ -57984,6 +58295,9 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57984
58295
  });
57985
58296
  useDidUpdate(function () {
57986
58297
  var _draftMessagesMap$act;
58298
+ if (composerChannelId !== activeChannel.id) {
58299
+ return;
58300
+ }
57987
58301
  var persistedReply = (_draftMessagesMap$act = draftMessagesMap[activeChannel.id]) === null || _draftMessagesMap$act === void 0 ? void 0 : _draftMessagesMap$act.messageForReply;
57988
58302
  if (isNavigatingChannelRef.current) {
57989
58303
  isNavigatingChannelRef.current = false;
@@ -58011,7 +58325,7 @@ var SendMessageInput = function SendMessageInput(_ref3) {
58011
58325
  if (messageContRef && messageContRef.current) {
58012
58326
  dispatch(setSendMessageInputHeightAC(messageContRef.current.getBoundingClientRect().height));
58013
58327
  }
58014
- }, [messageForReply]);
58328
+ }, [messageForReply, activeChannel.id, composerChannelId]);
58015
58329
  useDidUpdate(function () {
58016
58330
  if (messageToEdit) {
58017
58331
  if (messageForReply) {
@@ -58044,7 +58358,6 @@ var SendMessageInput = function SendMessageInput(_ref3) {
58044
58358
  if (inputHeightTimeout) {
58045
58359
  clearTimeout(inputHeightTimeout);
58046
58360
  }
58047
- prevActiveChannelId = undefined;
58048
58361
  document.removeEventListener('mousedown', handleClick);
58049
58362
  if (messageContRef && messageContRef.current) {
58050
58363
  messageContRef.current.removeEventListener('paste', handlePastAttachments);
@@ -58102,16 +58415,21 @@ var SendMessageInput = function SendMessageInput(_ref3) {
58102
58415
  return linkPreview && linkPreview.metadata && !isDescriptionOnlySymbol((_linkPreview$metadata = linkPreview.metadata.og) === null || _linkPreview$metadata === void 0 ? void 0 : _linkPreview$metadata.description) && (((_linkPreview$metadata2 = linkPreview.metadata.og) === null || _linkPreview$metadata2 === void 0 ? void 0 : _linkPreview$metadata2.title) || ((_linkPreview$metadata3 = linkPreview.metadata.og) === null || _linkPreview$metadata3 === void 0 ? void 0 : _linkPreview$metadata3.description) || ((_linkPreview$metadata4 = linkPreview.metadata.og) === null || _linkPreview$metadata4 === void 0 ? void 0 : (_linkPreview$metadata5 = _linkPreview$metadata4.image) === null || _linkPreview$metadata5 === void 0 ? void 0 : (_linkPreview$metadata6 = _linkPreview$metadata5[0]) === null || _linkPreview$metadata6 === void 0 ? void 0 : _linkPreview$metadata6.url) || ((_linkPreview$metadata7 = linkPreview.metadata.og) === null || _linkPreview$metadata7 === void 0 ? void 0 : (_linkPreview$metadata8 = _linkPreview$metadata7.favicon) === null || _linkPreview$metadata8 === void 0 ? void 0 : _linkPreview$metadata8.url));
58103
58416
  }, [linkPreview]);
58104
58417
  React.useEffect(function () {
58105
- if (messageContRef && messageContRef.current) {
58106
- setTimeout(function () {
58107
- dispatch(setSendMessageInputHeightAC(messageContRef.current.getBoundingClientRect().height));
58108
- }, 301);
58109
- }
58418
+ if (!messageContRef.current) return undefined;
58419
+ var timeout = setTimeout(function () {
58420
+ var messageContainer = messageContRef.current;
58421
+ if (messageContainer) {
58422
+ dispatch(setSendMessageInputHeightAC(messageContainer.getBoundingClientRect().height));
58423
+ }
58424
+ }, 301);
58425
+ return function () {
58426
+ return clearTimeout(timeout);
58427
+ };
58110
58428
  }, [showLinkPreview]);
58111
58429
  return /*#__PURE__*/React__default.createElement(SendMessageWrapper, {
58112
58430
  ref: sendMessageWrapperRef,
58113
58431
  backgroundColor: backgroundColor || background,
58114
- "$hidden": pinnedMessagesListOpen && !messageToEdit && !messageForReply && !(selectedMessagesMap !== null && selectedMessagesMap !== void 0 && selectedMessagesMap.size)
58432
+ "$hidden": pinnedMessagesListOpen && !(selectedMessagesMap && selectedMessagesMap.size > 0)
58115
58433
  }, /*#__PURE__*/React__default.createElement(Container$m, {
58116
58434
  margin: margin,
58117
58435
  padding: padding,
@@ -58458,11 +58776,11 @@ var SendMessageInput = function SendMessageInput(_ref3) {
58458
58776
  draftMessage: (restoredEditMessage === null || restoredEditMessage === void 0 ? void 0 : restoredEditMessage.id) === (messageToEdit === null || messageToEdit === void 0 ? void 0 : messageToEdit.id) ? restoredEditMessage : null,
58459
58777
  contactsMap: contactsMap,
58460
58778
  getFromContacts: getFromContacts,
58461
- setMentionedMember: setMentionedUsers
58779
+ setMentionedMember: setComposerMentionedUsers
58462
58780
  }), /*#__PURE__*/React__default.createElement(FormatMessagePlugin, {
58463
58781
  editorState: realEditorState,
58464
- setMessageBodyAttributes: setMessageBodyAttributes,
58465
- setMessageText: messageToEdit ? setEditMessageText : setMessageText,
58782
+ setMessageBodyAttributes: setComposerMessageBodyAttributes,
58783
+ setMessageText: messageToEdit ? setComposerEditMessageText : setComposerMessageText,
58466
58784
  messageToEdit: messageToEdit,
58467
58785
  activeChannelMembers: activeChannelMembers,
58468
58786
  contactsMap: contactsMap,
@@ -58505,11 +58823,11 @@ var SendMessageInput = function SendMessageInput(_ref3) {
58505
58823
  anchorElem: floatingAnchorElem
58506
58824
  })))))))), sendMessageIsActive || attachments.length > 0 || !voiceMessage && !((_getAudioRecordingFro2 = getAudioRecordingFromMap(activeChannel === null || activeChannel === void 0 ? void 0 : activeChannel.id)) !== null && _getAudioRecordingFro2 !== void 0 && _getAudioRecordingFro2.file) || messageToEdit ? (/*#__PURE__*/React__default.createElement(SendMessageButton, {
58507
58825
  isCustomButton: CustomSendMessageButton,
58508
- isActive: sendMessageIsActive,
58826
+ isActive: sendMessageIsActive && !isSendMessageInFlight,
58509
58827
  order: sendIconOrder,
58510
58828
  color: backgroundSections,
58511
58829
  height: inputContainerHeight || minHeight,
58512
- onClick: sendMessageIsActive ? handleSendEditMessage : null,
58830
+ onClick: sendMessageIsActive && !isSendMessageInFlight ? handleSendEditMessage : null,
58513
58831
  iconColor: accentColor,
58514
58832
  activeColor: accentColor
58515
58833
  }, CustomSendMessageButton || /*#__PURE__*/React__default.createElement(SvgSend, null))) : (/*#__PURE__*/React__default.createElement(SendMessageButton, {
@@ -58521,7 +58839,7 @@ var SendMessageInput = function SendMessageInput(_ref3) {
58521
58839
  activeColor: accentColor
58522
58840
  }, /*#__PURE__*/React__default.createElement(AudioRecord$1, {
58523
58841
  sendRecordedFile: sendRecordedFile,
58524
- setShowRecording: setShowRecording,
58842
+ setShowRecording: handleShowRecording,
58525
58843
  showRecording: showRecording,
58526
58844
  channelId: activeChannel.id,
58527
58845
  maxRecordingDuration: audioRecordingMaxDuration,
@@ -58533,10 +58851,14 @@ var SendMessageInput = function SendMessageInput(_ref3) {
58533
58851
  ViewOnceNotSelectedSVGIcon: ViewOnceNotSelectedSVGIcon
58534
58852
  }))))))))));
58535
58853
  };
58536
- var SendMessageWrapper = styled__default.div(_templateObject$Z || (_templateObject$Z = _taggedTemplateLiteralLoose(["\n visibility: ", ";\n pointer-events: ", ";\n background-color: ", ";\n position: relative;\n z-index: 10;\n"])), function (props) {
58854
+ var SendMessageWrapper = styled__default.div(_templateObject$Z || (_templateObject$Z = _taggedTemplateLiteralLoose(["\n visibility: ", ";\n pointer-events: ", ";\n max-height: ", ";\n overflow: ", ";\n background-color: ", ";\n position: relative;\n z-index: 10;\n"])), function (props) {
58537
58855
  return props.$hidden ? 'hidden' : 'visible';
58538
58856
  }, function (props) {
58539
58857
  return props.$hidden ? 'none' : 'auto';
58858
+ }, function (props) {
58859
+ return props.$hidden ? '40px' : 'none';
58860
+ }, function (props) {
58861
+ return props.$hidden ? 'hidden' : 'visible';
58540
58862
  }, function (props) {
58541
58863
  return props.backgroundColor;
58542
58864
  });
@@ -60452,7 +60774,7 @@ var Files = function Files(_ref) {
60452
60774
  fontSize: fileSizeFontSize,
60453
60775
  lineHeight: fileSizeLineHeight,
60454
60776
  color: filePreviewSizeColor || textSecondary
60455
- }, file.size ? bytesToSize(file.size) + " \u2022 " + formatChannelDetailsDate(file.createdAt) : formatChannelDetailsDate(file.createdAt))), /*#__PURE__*/React__default.createElement(DownloadWrapper, {
60777
+ }, file.size ? bytesToSize(file.size, 1) + " \u2022 " + formatChannelDetailsDate(file.createdAt) : formatChannelDetailsDate(file.createdAt))), /*#__PURE__*/React__default.createElement(DownloadWrapper, {
60456
60778
  visible: !!downloadingFilesMap[file.id],
60457
60779
  iconColor: accentColor,
60458
60780
  onClick: function onClick() {
@@ -64256,7 +64578,10 @@ var UnreadCount$2 = styled__default.span(_templateObject2$1c || (_templateObject
64256
64578
  return props.textColor || '#fff';
64257
64579
  });
64258
64580
 
64259
- var createOrGetDirectChannel = function createOrGetDirectChannel(user, callback) {
64581
+ var createOrGetDirectChannel = function createOrGetDirectChannel(user, callback, dontCreateIfNotExists) {
64582
+ if (dontCreateIfNotExists === void 0) {
64583
+ dontCreateIfNotExists = false;
64584
+ }
64260
64585
  try {
64261
64586
  if (user) {
64262
64587
  store.dispatch(createChannelAC({
@@ -64265,7 +64590,7 @@ var createOrGetDirectChannel = function createOrGetDirectChannel(user, callback)
64265
64590
  members: [_extends({}, user, {
64266
64591
  role: 'owner'
64267
64592
  })]
64268
- }, false, callback));
64593
+ }, dontCreateIfNotExists, callback));
64269
64594
  }
64270
64595
  return Promise.resolve();
64271
64596
  } catch (e) {