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.modern.js CHANGED
@@ -11119,7 +11119,7 @@ var compressAndCacheImage = function compressAndCacheImage(url, cacheKey, maxWid
11119
11119
 
11120
11120
  var bytesToSize = function bytesToSize(bytes, decimals) {
11121
11121
  if (decimals === void 0) {
11122
- decimals = 2;
11122
+ decimals = 1;
11123
11123
  }
11124
11124
  if (bytes === 0) return '0 Bytes';
11125
11125
  var k = 1000;
@@ -11475,6 +11475,11 @@ var clearVideoPreparation = function clearVideoPreparation(tid) {
11475
11475
  }
11476
11476
  preparations["delete"](tid);
11477
11477
  };
11478
+ var beginAttachmentPreparation = beginVideoPreparation;
11479
+ var completeAttachmentPreparation = completeVideoPreparation;
11480
+ var failAttachmentPreparation = failVideoPreparation;
11481
+ var waitForAttachmentPreparation = waitForVideoPreparation;
11482
+ var clearAttachmentPreparation = clearVideoPreparation;
11478
11483
 
11479
11484
  var LOAD_LATEST_MESSAGES = 'LOAD_LATEST_MESSAGES';
11480
11485
  var LOAD_AROUND_MESSAGE = 'LOAD_AROUND_MESSAGE';
@@ -13414,6 +13419,21 @@ function addReactionToMessageOnMap(channelId, message, reaction, isSelf) {
13414
13419
  });
13415
13420
  }
13416
13421
  }
13422
+ var removeReactionFromTotals = function removeReactionFromTotals(reactionTotals, reactionKey) {
13423
+ if (reactionTotals === void 0) {
13424
+ reactionTotals = [];
13425
+ }
13426
+ return reactionTotals.reduce(function (totals, reactionTotal) {
13427
+ if (reactionTotal.key !== reactionKey) {
13428
+ totals.push(reactionTotal);
13429
+ } else if (reactionTotal.count > 1) {
13430
+ totals.push(_extends({}, reactionTotal, {
13431
+ count: reactionTotal.count - 1
13432
+ }));
13433
+ }
13434
+ return totals;
13435
+ }, []);
13436
+ };
13417
13437
  function removeReactionToMessageOnMap(channelId, message, reaction, isSelf) {
13418
13438
  if (messagesMap[channelId]) {
13419
13439
  var messageShouldBeUpdated = messagesMap[channelId][message.id];
@@ -13430,7 +13450,7 @@ function removeReactionToMessageOnMap(channelId, message, reaction, isSelf) {
13430
13450
  delete messagesMap[channelId][message.tid];
13431
13451
  }
13432
13452
  messagesMap[channelId][message.id || message.tid] = _extends({}, messageShouldBeUpdated, {
13433
- reactionTotals: message.reactionTotals || messageShouldBeUpdated.reactionTotals || [],
13453
+ reactionTotals: removeReactionFromTotals(messageShouldBeUpdated.reactionTotals, reaction.key),
13434
13454
  userReactions: userReactions
13435
13455
  });
13436
13456
  }
@@ -13724,9 +13744,10 @@ var hydrateDraftMessages = function hydrateDraftMessages() {
13724
13744
  type: data.type || attachment.mimeType || 'application/octet-stream',
13725
13745
  lastModified: attachment.lastModified || Date.now()
13726
13746
  }) : data;
13747
+ var canRestorePreviewUrl = attachment.type === attachmentTypes.image || attachment.type === attachmentTypes.video || attachment.type === attachmentTypes.voice;
13727
13748
  return _extends({}, attachment, {
13728
13749
  data: restoredData,
13729
- attachmentUrl: restoredData instanceof Blob && typeof URL !== 'undefined' ? URL.createObjectURL(restoredData) : attachment.attachmentUrl
13750
+ attachmentUrl: canRestorePreviewUrl && restoredData instanceof Blob && typeof URL !== 'undefined' ? URL.createObjectURL(restoredData) : undefined
13730
13751
  });
13731
13752
  });
13732
13753
  draftMessagesMap[channelId] = _extends({}, draft, {
@@ -14183,7 +14204,7 @@ var messageSlice = createSlice({
14183
14204
  });
14184
14205
  }
14185
14206
  return _extends({}, msg, {
14186
- reactionTotals: message.reactionTotals || msg.reactionTotals || [],
14207
+ reactionTotals: removeReactionFromTotals(msg.reactionTotals, reaction.key),
14187
14208
  userReactions: userReactions
14188
14209
  });
14189
14210
  }
@@ -14301,6 +14322,7 @@ var messageSlice = createSlice({
14301
14322
  },
14302
14323
  requestPinnedMessagesListClose: function requestPinnedMessagesListClose(state) {
14303
14324
  if (state.pinnedMessagesListOpen) {
14325
+ state.pinnedMessagesListOpen = false;
14304
14326
  state.pinnedMessagesListCloseRequested = true;
14305
14327
  }
14306
14328
  },
@@ -17488,12 +17510,15 @@ var hasLivePendingAttachment = function hasLivePendingAttachment(message) {
17488
17510
  var retractDeletedPendingMessage = function retractDeletedPendingMessage(channel, messageId) {
17489
17511
  return channel.deleteMessageById(messageId, false);
17490
17512
  };
17491
- var applyPreparedVideoAttachments = function applyPreparedVideoAttachments(attachments) {
17513
+ var applyPreparedMediaAttachments = function applyPreparedMediaAttachments(attachments, clearPreparation) {
17514
+ if (clearPreparation === void 0) {
17515
+ clearPreparation = true;
17516
+ }
17492
17517
  try {
17493
17518
  return Promise.resolve(Promise.all(attachments.map(function (attachment) {
17494
17519
  try {
17495
17520
  if (!attachment.tid) return Promise.resolve();
17496
- return Promise.resolve(waitForVideoPreparation(attachment.tid, VIDEO_PREPARATION_TIMEOUT_MS)).then(function (prepared) {
17521
+ return Promise.resolve(waitForAttachmentPreparation(attachment.tid, VIDEO_PREPARATION_TIMEOUT_MS)).then(function (prepared) {
17497
17522
  if ((prepared === null || prepared === void 0 ? void 0 : prepared.status) === 'ready' && prepared.metadata) {
17498
17523
  attachment.url = prepared.file;
17499
17524
  attachment.data = prepared.file;
@@ -17502,7 +17527,9 @@ var applyPreparedVideoAttachments = function applyPreparedVideoAttachments(attac
17502
17527
  attachment.metadata = prepared.metadata;
17503
17528
  attachment.videoPreviewBlob = prepared.videoPreviewBlob;
17504
17529
  }
17505
- clearVideoPreparation(attachment.tid);
17530
+ if (clearPreparation) {
17531
+ clearAttachmentPreparation(attachment.tid);
17532
+ }
17506
17533
  });
17507
17534
  } catch (e) {
17508
17535
  return Promise.reject(e);
@@ -18441,7 +18468,7 @@ function sendMessage(action) {
18441
18468
  }) : [];
18442
18469
  customUploader = getCustomUploader();
18443
18470
  if (!(message.attachments && message.attachments.length)) {
18444
- _context13.n = 16;
18471
+ _context13.n = 14;
18445
18472
  break;
18446
18473
  }
18447
18474
  linkAttachment = null;
@@ -18454,7 +18481,7 @@ function sendMessage(action) {
18454
18481
  return att.type !== attachmentTypes.link;
18455
18482
  });
18456
18483
  if (!(mediaAttachments && mediaAttachments.length)) {
18457
- _context13.n = 12;
18484
+ _context13.n = 10;
18458
18485
  break;
18459
18486
  }
18460
18487
  _loop2 = /*#__PURE__*/_regenerator().m(function _callee3() {
@@ -18608,68 +18635,53 @@ function sendMessage(action) {
18608
18635
  if (customUploader) {
18609
18636
  messageAttachment.url = attachment.data;
18610
18637
  }
18611
- if (!sendAttachmentsAsSeparateMessage) {
18612
- _context11.n = 3;
18613
- break;
18614
- }
18615
- _messageBuilder = channel.createMessageBuilder();
18616
- _messageBuilder.setBody(i === 0 ? message.body : '').setAttachments([]).setBodyAttributes(i === 0 ? message.bodyAttributes : {}).setMentionUserIds(i === 0 ? mentionedUserIds : []).setType(message.type).setDisplayCount(message.type === MESSAGE_TYPE.SYSTEM ? 0 : 1).setSilent(message.type === MESSAGE_TYPE.SYSTEM).setMetadata(i === 0 ? JSON.stringify(message.metadata) : '');
18617
- if (channel.type === DEFAULT_CHANNEL_TYPE.DIRECT) {
18618
- _messageBuilder.setDisableMentionsCount(true);
18619
- }
18620
- if (message.parentMessage) {
18621
- _messageBuilder.setParentMessageId(message.parentMessage ? message.parentMessage.id : null);
18622
- }
18623
- if (message.repliedInThread) {
18624
- _messageBuilder.setReplyInThread();
18625
- }
18626
- if (i === 0 && canBeViewOnce(message)) {
18627
- _messageBuilder.setViewOnce(true);
18628
- _messageBuilder.setType(MESSAGE_TYPE.VIEW_ONCE);
18629
- }
18630
- _messageToSend = action.type === RESEND_MESSAGE ? action.payload.message : _messageBuilder.create();
18631
- _sourceFile = getAttachmentSourceFile(attachment);
18632
- if (messageAttachment.tid && _sourceFile) {
18633
- setPendingAttachment(messageAttachment.tid, {
18634
- file: _sourceFile,
18635
- messageTid: _messageToSend.tid,
18636
- channelId: channel.id
18638
+ if (sendAttachmentsAsSeparateMessage) {
18639
+ _messageBuilder = channel.createMessageBuilder();
18640
+ _messageBuilder.setBody(i === 0 ? message.body : '').setAttachments([]).setBodyAttributes(i === 0 ? message.bodyAttributes : {}).setMentionUserIds(i === 0 ? mentionedUserIds : []).setType(message.type).setDisplayCount(message.type === MESSAGE_TYPE.SYSTEM ? 0 : 1).setSilent(message.type === MESSAGE_TYPE.SYSTEM).setMetadata(i === 0 ? JSON.stringify(message.metadata) : '');
18641
+ if (channel.type === DEFAULT_CHANNEL_TYPE.DIRECT) {
18642
+ _messageBuilder.setDisableMentionsCount(true);
18643
+ }
18644
+ if (message.parentMessage) {
18645
+ _messageBuilder.setParentMessageId(message.parentMessage ? message.parentMessage.id : null);
18646
+ }
18647
+ if (message.repliedInThread) {
18648
+ _messageBuilder.setReplyInThread();
18649
+ }
18650
+ if (i === 0 && canBeViewOnce(message)) {
18651
+ _messageBuilder.setViewOnce(true);
18652
+ _messageBuilder.setType(MESSAGE_TYPE.VIEW_ONCE);
18653
+ }
18654
+ _messageToSend = action.type === RESEND_MESSAGE ? action.payload.message : _messageBuilder.create();
18655
+ _sourceFile = getAttachmentSourceFile(attachment);
18656
+ if (messageAttachment.tid && _sourceFile) {
18657
+ setPendingAttachment(messageAttachment.tid, {
18658
+ file: _sourceFile,
18659
+ messageTid: _messageToSend.tid,
18660
+ channelId: channel.id
18661
+ });
18662
+ }
18663
+ messageForSend = _extends({}, _messageToSend, {
18664
+ attachments: [messageAttachment],
18665
+ createdAt: new Date(Date.now())
18637
18666
  });
18667
+ messagesToSend.push(messageForSend);
18668
+ _pending = _extends({}, messageForSend, {
18669
+ attachments: [attachment],
18670
+ createdAt: new Date(Date.now()),
18671
+ mentionedUsers: message.mentionedUsers,
18672
+ parentMessage: message.parentMessage || null
18673
+ });
18674
+ pendingMessages.push(_pending);
18675
+ } else {
18676
+ attachmentsToSend.push(messageAttachment);
18638
18677
  }
18639
- messageForSend = _extends({}, _messageToSend, {
18640
- attachments: [messageAttachment],
18641
- createdAt: new Date(Date.now())
18642
- });
18643
- messagesToSend.push(messageForSend);
18644
- _pending = _extends({}, messageForSend, {
18645
- attachments: [attachment],
18646
- createdAt: new Date(Date.now()),
18647
- mentionedUsers: message.mentionedUsers,
18648
- parentMessage: message.parentMessage || null
18649
- });
18650
- pendingMessages.push(_pending);
18651
- if (!(action.type !== RESEND_MESSAGE)) {
18652
- _context11.n = 2;
18653
- break;
18654
- }
18655
- _context11.n = 1;
18656
- return call(loadOGMetadataForLinkMessages, [_pending], true);
18657
- case 1:
18658
- _context11.n = 2;
18659
- return call(updateMessage$1, action.type, _pending, channel.id, true, message);
18660
- case 2:
18661
- _context11.n = 4;
18662
- break;
18663
- case 3:
18664
- attachmentsToSend.push(messageAttachment);
18665
- case 4:
18666
18678
  if (!(!messageAttachment.cachedUrl && customUploader)) {
18667
- _context11.n = 5;
18679
+ _context11.n = 1;
18668
18680
  break;
18669
18681
  }
18670
- _context11.n = 5;
18682
+ _context11.n = 1;
18671
18683
  return put(updateAttachmentUploadingStateAC(messageAttachment.type === attachmentTypes.video ? UPLOAD_STATE.PREPARING : UPLOAD_STATE.UPLOADING, messageAttachment.tid));
18672
- case 5:
18684
+ case 1:
18673
18685
  return _context11.a(2);
18674
18686
  }
18675
18687
  }, _callee3);
@@ -18686,60 +18698,48 @@ function sendMessage(action) {
18686
18698
  _context13.n = 7;
18687
18699
  break;
18688
18700
  case 9:
18689
- if (sendAttachmentsAsSeparateMessage) {
18690
- _context13.n = 12;
18691
- break;
18692
- }
18693
- messageBuilder = channel.createMessageBuilder();
18694
- messageBuilder.setBody(message.body).setBodyAttributes(message.bodyAttributes).setAttachments(message.attachments).setMentionUserIds(mentionedUserIds).setType(message.type).setDisplayCount(message.type === MESSAGE_TYPE.SYSTEM ? 0 : 1).setSilent(message.type === MESSAGE_TYPE.SYSTEM).setMetadata(JSON.stringify(message.metadata));
18695
- if (channel.type === DEFAULT_CHANNEL_TYPE.DIRECT) {
18696
- messageBuilder.setDisableMentionsCount(true);
18697
- }
18698
- if (message.parentMessage) {
18699
- messageBuilder.setParentMessageId(message.parentMessage ? message.parentMessage.id : null);
18700
- }
18701
- if (message.repliedInThread) {
18702
- messageBuilder.setReplyInThread();
18703
- }
18704
- if (canBeViewOnce(message)) {
18705
- messageBuilder.setViewOnce(true);
18706
- messageBuilder.setType(MESSAGE_TYPE.VIEW_ONCE);
18707
- }
18708
- messageToSend = action.type === RESEND_MESSAGE ? action.payload.message : messageBuilder.create();
18709
- attachmentsToSend.forEach(function (messageAttachment) {
18710
- var sourceFile = getAttachmentSourceFile(messageAttachment);
18711
- if (messageAttachment.tid && sourceFile) {
18712
- setPendingAttachment(messageAttachment.tid, {
18713
- file: sourceFile,
18714
- messageTid: messageToSend.tid,
18715
- channelId: channel.id
18716
- });
18701
+ if (!sendAttachmentsAsSeparateMessage) {
18702
+ messageBuilder = channel.createMessageBuilder();
18703
+ messageBuilder.setBody(message.body).setBodyAttributes(message.bodyAttributes).setAttachments(message.attachments).setMentionUserIds(mentionedUserIds).setType(message.type).setDisplayCount(message.type === MESSAGE_TYPE.SYSTEM ? 0 : 1).setSilent(message.type === MESSAGE_TYPE.SYSTEM).setMetadata(JSON.stringify(message.metadata));
18704
+ if (channel.type === DEFAULT_CHANNEL_TYPE.DIRECT) {
18705
+ messageBuilder.setDisableMentionsCount(true);
18717
18706
  }
18718
- });
18719
- pending = _extends({}, messageToSend, {
18720
- attachments: message.attachments,
18721
- createdAt: new Date(Date.now()),
18722
- mentionedUsers: message.mentionedUsers,
18723
- parentMessage: message.parentMessage || null
18724
- });
18725
- pendingMessages.push(pending);
18726
- if (!(action.type !== RESEND_MESSAGE)) {
18727
- _context13.n = 11;
18728
- break;
18707
+ if (message.parentMessage) {
18708
+ messageBuilder.setParentMessageId(message.parentMessage ? message.parentMessage.id : null);
18709
+ }
18710
+ if (message.repliedInThread) {
18711
+ messageBuilder.setReplyInThread();
18712
+ }
18713
+ if (canBeViewOnce(message)) {
18714
+ messageBuilder.setViewOnce(true);
18715
+ messageBuilder.setType(MESSAGE_TYPE.VIEW_ONCE);
18716
+ }
18717
+ messageToSend = action.type === RESEND_MESSAGE ? action.payload.message : messageBuilder.create();
18718
+ attachmentsToSend.forEach(function (messageAttachment) {
18719
+ var sourceFile = getAttachmentSourceFile(messageAttachment);
18720
+ if (messageAttachment.tid && sourceFile) {
18721
+ setPendingAttachment(messageAttachment.tid, {
18722
+ file: sourceFile,
18723
+ messageTid: messageToSend.tid,
18724
+ channelId: channel.id
18725
+ });
18726
+ }
18727
+ });
18728
+ pending = _extends({}, messageToSend, {
18729
+ attachments: message.attachments,
18730
+ createdAt: new Date(Date.now()),
18731
+ mentionedUsers: message.mentionedUsers,
18732
+ parentMessage: message.parentMessage || null
18733
+ });
18734
+ pendingMessages.push(pending);
18735
+ messageToSend = _extends({}, messageToSend, {
18736
+ attachments: attachmentsToSend
18737
+ });
18738
+ messagesToSend.push(messageToSend);
18729
18739
  }
18730
- _context13.n = 10;
18731
- return call(loadOGMetadataForLinkMessages, [pending], true);
18732
18740
  case 10:
18733
- _context13.n = 11;
18734
- return call(updateMessage$1, action.type, pending, channel.id, true, message);
18735
- case 11:
18736
- messageToSend = _extends({}, messageToSend, {
18737
- attachments: attachmentsToSend
18738
- });
18739
- messagesToSend.push(messageToSend);
18740
- case 12:
18741
18741
  _loop3 = /*#__PURE__*/_regenerator().m(function _callee4(_i2) {
18742
- 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;
18742
+ 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;
18743
18743
  return _regenerator().w(function (_context12) {
18744
18744
  while (1) switch (_context12.p = _context12.n) {
18745
18745
  case 0:
@@ -18762,10 +18762,6 @@ function sendMessage(action) {
18762
18762
  messageToSend = _extends({}, messageToSend, pendingState);
18763
18763
  case 2:
18764
18764
  _context12.p = 2;
18765
- if (!(connectionState === CONNECTION_STATUS.CONNECTED)) {
18766
- _context12.n = 30;
18767
- break;
18768
- }
18769
18765
  if (!(messageToSend.tid && isPendingMessageDeleted(channel.id, messageToSend.tid))) {
18770
18766
  _context12.n = 3;
18771
18767
  break;
@@ -18773,83 +18769,108 @@ function sendMessage(action) {
18773
18769
  return _context12.a(2, 0);
18774
18770
  case 3:
18775
18771
  _context12.n = 4;
18776
- return call(applyPreparedVideoAttachments, messageAttachment);
18772
+ return call(applyPreparedMediaAttachments, messageAttachment, connectionState === CONNECTION_STATUS.CONNECTED);
18777
18773
  case 4:
18778
- pendingAttachments = messageAttachment.map(function (attachment) {
18779
- return _extends({}, attachment, {
18780
- data: attachment.data || attachment.url
18774
+ pendingMessage = pendingMessages[_i2];
18775
+ pendingAttachments = pendingMessage.attachments.map(function (pendingAttachment) {
18776
+ var preparedAttachment = messageAttachment.find(function (attachment) {
18777
+ return attachment.tid === pendingAttachment.tid;
18781
18778
  });
18779
+ return preparedAttachment ? _extends({}, pendingAttachment, preparedAttachment, {
18780
+ data: preparedAttachment.data || preparedAttachment.url
18781
+ }) : pendingAttachment;
18782
18782
  });
18783
+ pendingMessage.attachments = pendingAttachments;
18784
+ if (!(action.type !== RESEND_MESSAGE)) {
18785
+ _context12.n = 6;
18786
+ break;
18787
+ }
18788
+ _context12.n = 5;
18789
+ return call(loadOGMetadataForLinkMessages, [pendingMessage], true);
18790
+ case 5:
18791
+ _context12.n = 6;
18792
+ return call(updateMessage$1, action.type, pendingMessage, channel.id, true, message);
18793
+ case 6:
18794
+ if (!(connectionState === CONNECTION_STATUS.CONNECTED)) {
18795
+ _context12.n = 33;
18796
+ break;
18797
+ }
18798
+ if (!(messageToSend.tid && isPendingMessageDeleted(channel.id, messageToSend.tid))) {
18799
+ _context12.n = 7;
18800
+ break;
18801
+ }
18802
+ return _context12.a(2, 0);
18803
+ case 7:
18783
18804
  updateMessageOnMap(channel.id, {
18784
18805
  messageId: messageToSend.tid,
18785
18806
  params: {
18786
18807
  attachments: pendingAttachments
18787
18808
  }
18788
18809
  });
18789
- _context12.n = 5;
18810
+ _context12.n = 8;
18790
18811
  return put(updateMessageAC(messageToSend.tid, {
18791
18812
  attachments: pendingAttachments
18792
18813
  }));
18793
- case 5:
18814
+ case 8:
18794
18815
  messageCopy = JSON.parse(JSON.stringify(messagesToSend[_i2]));
18795
18816
  if (!(messageToSend.tid && isPendingMessageDeleted(channel.id, messageToSend.tid))) {
18796
- _context12.n = 6;
18817
+ _context12.n = 9;
18797
18818
  break;
18798
18819
  }
18799
18820
  return _context12.a(2, 0);
18800
- case 6:
18821
+ case 9:
18801
18822
  if (customUploader) {
18802
- _context12.n = 10;
18823
+ _context12.n = 13;
18803
18824
  break;
18804
18825
  }
18805
18826
  attachmentIndex = 0;
18806
- case 7:
18827
+ case 10:
18807
18828
  if (!(attachmentIndex < messageAttachment.length)) {
18808
- _context12.n = 10;
18829
+ _context12.n = 13;
18809
18830
  break;
18810
18831
  }
18811
18832
  if (!(messageAttachment[attachmentIndex].type === attachmentTypes.video)) {
18812
- _context12.n = 9;
18833
+ _context12.n = 12;
18813
18834
  break;
18814
18835
  }
18815
- _context12.n = 8;
18836
+ _context12.n = 11;
18816
18837
  return call(prepareAndUploadVideoPreview, messageAttachment[attachmentIndex], message.type);
18817
- case 8:
18838
+ case 11:
18818
18839
  preparedVideoAttachment = _context12.v;
18819
18840
  messageAttachment[attachmentIndex] = _extends({}, messageAttachment[attachmentIndex], preparedVideoAttachment);
18820
18841
  if (!messageAttachment[attachmentIndex].upload) {
18821
- _context12.n = 9;
18842
+ _context12.n = 12;
18822
18843
  break;
18823
18844
  }
18824
- _context12.n = 9;
18845
+ _context12.n = 12;
18825
18846
  return put(updateAttachmentUploadingStateAC(UPLOAD_STATE.UPLOADING, messageAttachment[attachmentIndex].tid));
18826
- case 9:
18847
+ case 12:
18827
18848
  attachmentIndex++;
18828
- _context12.n = 7;
18849
+ _context12.n = 10;
18829
18850
  break;
18830
- case 10:
18851
+ case 13:
18831
18852
  if (!(messageToSend.tid && isPendingMessageDeleted(channel.id, messageToSend.tid))) {
18832
- _context12.n = 11;
18853
+ _context12.n = 14;
18833
18854
  break;
18834
18855
  }
18835
18856
  return _context12.a(2, 0);
18836
- case 11:
18857
+ case 14:
18837
18858
  _attachmentsToSend = messageAttachment;
18838
18859
  if (!customUploader) {
18839
- _context12.n = 13;
18860
+ _context12.n = 16;
18840
18861
  break;
18841
18862
  }
18842
- _context12.n = 12;
18863
+ _context12.n = 15;
18843
18864
  return call(handleUploadAttachments, messageAttachment || [], messageCopy, channel);
18844
- case 12:
18865
+ case 15:
18845
18866
  _attachmentsToSend = _context12.v;
18846
- case 13:
18867
+ case 16:
18847
18868
  if (!(messageToSend.tid && isPendingMessageDeleted(channel.id, messageToSend.tid))) {
18848
- _context12.n = 14;
18869
+ _context12.n = 17;
18849
18870
  break;
18850
18871
  }
18851
18872
  return _context12.a(2, 0);
18852
- case 14:
18873
+ case 17:
18853
18874
  linkAttachmentToSend = null;
18854
18875
  if (_i2 === 0 && linkAttachment) {
18855
18876
  linkAttachmentBuilder = channel.createAttachmentBuilder(linkAttachment.data, linkAttachment.type);
@@ -18864,61 +18885,61 @@ function sendMessage(action) {
18864
18885
  attachments: [].concat(_attachmentsToSend)
18865
18886
  });
18866
18887
  }
18867
- _context12.n = 15;
18888
+ _context12.n = 18;
18868
18889
  return call(channel.sendMessage, messageToSend);
18869
- case 15:
18890
+ case 18:
18870
18891
  messageResponse = _context12.v;
18871
18892
  if (!(messageToSend.tid && isPendingMessageDeleted(channel.id, messageToSend.tid))) {
18872
- _context12.n = 20;
18893
+ _context12.n = 23;
18873
18894
  break;
18874
18895
  }
18875
18896
  if (!(messageResponse !== null && messageResponse !== void 0 && messageResponse.id && typeof channel.deleteMessageById === 'function')) {
18876
- _context12.n = 19;
18897
+ _context12.n = 22;
18877
18898
  break;
18878
18899
  }
18879
- _context12.p = 16;
18880
- _context12.n = 17;
18900
+ _context12.p = 19;
18901
+ _context12.n = 20;
18881
18902
  return call(retractDeletedPendingMessage, channel, messageResponse.id);
18882
- case 17:
18883
- _context12.n = 19;
18903
+ case 20:
18904
+ _context12.n = 22;
18884
18905
  break;
18885
- case 18:
18886
- _context12.p = 18;
18906
+ case 21:
18907
+ _context12.p = 21;
18887
18908
  _t = _context12.v;
18888
18909
  log.warn('Unable to retract a deleted pending message:', _t);
18889
- case 19:
18910
+ case 22:
18890
18911
  return _context12.a(2, 0);
18891
- case 20:
18912
+ case 23:
18892
18913
  if (messageToSend.tid) {
18893
18914
  autoResendAttempts["delete"](messageToSend.tid);
18894
18915
  }
18895
18916
  if (!customUploader) {
18896
- _context12.n = 25;
18917
+ _context12.n = 28;
18897
18918
  break;
18898
18919
  }
18899
18920
  k = 0;
18900
- case 21:
18921
+ case 24:
18901
18922
  if (!(k < messageAttachment.length)) {
18902
- _context12.n = 25;
18923
+ _context12.n = 28;
18903
18924
  break;
18904
18925
  }
18905
18926
  messageResponse.attachments[k] = _extends({}, messageResponse.attachments[k], {
18906
18927
  user: JSON.parse(JSON.stringify(messageResponse.user)),
18907
18928
  tid: messageAttachment[k].tid
18908
18929
  });
18909
- _context12.n = 22;
18930
+ _context12.n = 25;
18910
18931
  return put(removeAttachmentProgressAC(messageAttachment[k].tid));
18911
- case 22:
18912
- _context12.n = 23;
18932
+ case 25:
18933
+ _context12.n = 26;
18913
18934
  return put(removeAttachmentUploadingStateAC(messageAttachment[k].tid));
18914
- case 23:
18935
+ case 26:
18915
18936
  deletePendingAttachment(messageAttachment[k].tid);
18916
18937
  releaseBlobUrls(["compose_" + messageAttachment[k].tid]);
18917
- case 24:
18938
+ case 27:
18918
18939
  k++;
18919
- _context12.n = 21;
18940
+ _context12.n = 24;
18920
18941
  break;
18921
- case 25:
18942
+ case 28:
18922
18943
  attachmentsToUpdate = [];
18923
18944
  if (messageResponse.attachments && messageResponse.attachments.length > 0) {
18924
18945
  currentAttachmentsMap = {};
@@ -18969,27 +18990,27 @@ function sendMessage(action) {
18969
18990
  });
18970
18991
  activeChannelId = getActiveChannelId();
18971
18992
  if (!(activeChannelId === channel.id)) {
18972
- _context12.n = 26;
18993
+ _context12.n = 29;
18973
18994
  break;
18974
18995
  }
18975
- _context12.n = 26;
18996
+ _context12.n = 29;
18976
18997
  return put(updateMessageAC(messageToSend.tid, messageUpdateData, true));
18977
- case 26:
18998
+ case 29:
18978
18999
  messageToUpdate = JSON.parse(JSON.stringify(_extends({}, messageResponse, {
18979
19000
  attachments: attachmentsToUpdate
18980
19001
  })));
18981
19002
  addConfirmedMessageToCache(channel.id, messageToUpdate);
18982
19003
  updateTabAttachmentCache(channel.id, attachmentsToUpdate, messageResponse.user);
18983
19004
  if (!channel.unread) {
18984
- _context12.n = 27;
19005
+ _context12.n = 30;
18985
19006
  break;
18986
19007
  }
18987
- _context12.n = 27;
19008
+ _context12.n = 30;
18988
19009
  return put(markChannelAsReadAC(channel.id));
18989
- case 27:
19010
+ case 30:
18990
19011
  resolvedLastMessage = getResolvedChannelLastMessage(channel.id, messageToUpdate, messageToSend);
18991
19012
  if (!lastMessageNeedsUpdate(getReduxChannelLastMessage(channel.id), resolvedLastMessage)) {
18992
- _context12.n = 29;
19013
+ _context12.n = 32;
18993
19014
  break;
18994
19015
  }
18995
19016
  updateChannelLastMessageOnAllChannels(channel.id, resolvedLastMessage);
@@ -18997,90 +19018,90 @@ function sendMessage(action) {
18997
19018
  lastMessage: resolvedLastMessage,
18998
19019
  lastReactedMessage: null
18999
19020
  };
19000
- _context12.n = 28;
19021
+ _context12.n = 31;
19001
19022
  return put(updateChannelDataAC(channel.id, channelUpdateParam, true));
19002
- case 28:
19023
+ case 31:
19003
19024
  updateChannelOnAllChannels(channel.id, channelUpdateParam);
19004
- case 29:
19005
- _context12.n = 31;
19025
+ case 32:
19026
+ _context12.n = 34;
19006
19027
  break;
19007
- case 30:
19028
+ case 33:
19008
19029
  throw new Error('Connection required to send message');
19009
- case 31:
19010
- _context12.n = 37;
19030
+ case 34:
19031
+ _context12.n = 40;
19011
19032
  break;
19012
- case 32:
19013
- _context12.p = 32;
19033
+ case 35:
19034
+ _context12.p = 35;
19014
19035
  _t2 = _context12.v;
19015
19036
  if (!(messageToSend.tid && isPendingMessageDeleted(channel.id, messageToSend.tid))) {
19016
- _context12.n = 33;
19037
+ _context12.n = 36;
19017
19038
  break;
19018
19039
  }
19019
19040
  return _context12.a(2, 0);
19020
- case 33:
19041
+ case 36:
19021
19042
  isErrorResendable = isResendableError(_t2 === null || _t2 === void 0 ? void 0 : _t2.type);
19022
19043
  if (!((_channel2 = channel) !== null && _channel2 !== void 0 && _channel2.id && (_messageToSend2 = messageToSend) !== null && _messageToSend2 !== void 0 && _messageToSend2.tid)) {
19023
- _context12.n = 37;
19044
+ _context12.n = 40;
19024
19045
  break;
19025
19046
  }
19026
19047
  log.error('Error on uploading attachment', messageToSend.tid, _t2);
19027
19048
  if (!((_messageToSend$attach = messageToSend.attachments) !== null && _messageToSend$attach !== void 0 && _messageToSend$attach.length)) {
19028
- _context12.n = 36;
19049
+ _context12.n = 39;
19029
19050
  break;
19030
19051
  }
19031
19052
  _iterator2 = _createForOfIteratorHelperLoose(messageToSend.attachments);
19032
- case 34:
19053
+ case 37:
19033
19054
  if ((_step2 = _iterator2()).done) {
19034
- _context12.n = 36;
19055
+ _context12.n = 39;
19035
19056
  break;
19036
19057
  }
19037
19058
  att = _step2.value;
19038
19059
  if (!att.tid) {
19039
- _context12.n = 35;
19060
+ _context12.n = 38;
19040
19061
  break;
19041
19062
  }
19042
- _context12.n = 35;
19063
+ _context12.n = 38;
19043
19064
  return put(updateAttachmentUploadingStateAC(UPLOAD_STATE.FAIL, att.tid));
19044
- case 35:
19045
- _context12.n = 34;
19046
- break;
19047
- case 36:
19065
+ case 38:
19048
19066
  _context12.n = 37;
19067
+ break;
19068
+ case 39:
19069
+ _context12.n = 40;
19049
19070
  return call(syncFailedMessageState, channel, messageToSend.tid, pendingMessages[_i2] || messageToSend, isErrorResendable);
19050
- case 37:
19071
+ case 40:
19051
19072
  return _context12.a(2);
19052
19073
  }
19053
- }, _callee4, null, [[16, 18], [2, 32]]);
19074
+ }, _callee4, null, [[19, 21], [2, 35]]);
19054
19075
  });
19055
19076
  _i2 = 0;
19056
- case 13:
19077
+ case 11:
19057
19078
  if (!(_i2 < messagesToSend.length)) {
19058
- _context13.n = 16;
19079
+ _context13.n = 14;
19059
19080
  break;
19060
19081
  }
19061
- return _context13.d(_regeneratorValues(_loop3(_i2)), 14);
19062
- case 14:
19082
+ return _context13.d(_regeneratorValues(_loop3(_i2)), 12);
19083
+ case 12:
19063
19084
  _ret = _context13.v;
19064
19085
  if (!(_ret === 0)) {
19065
- _context13.n = 15;
19086
+ _context13.n = 13;
19066
19087
  break;
19067
19088
  }
19068
- return _context13.a(3, 15);
19069
- case 15:
19089
+ return _context13.a(3, 13);
19090
+ case 13:
19070
19091
  _i2++;
19071
- _context13.n = 13;
19092
+ _context13.n = 11;
19072
19093
  break;
19073
- case 16:
19074
- _context13.n = 18;
19094
+ case 14:
19095
+ _context13.n = 16;
19075
19096
  break;
19076
- case 17:
19077
- _context13.p = 17;
19097
+ case 15:
19098
+ _context13.p = 15;
19078
19099
  _t3 = _context13.v;
19079
19100
  log.error('error on send message ... ', _t3);
19080
- case 18:
19101
+ case 16:
19081
19102
  return _context13.a(2);
19082
19103
  }
19083
- }, _marked1, null, [[1, 17]]);
19104
+ }, _marked1, null, [[1, 15]]);
19084
19105
  }
19085
19106
  function sendTextMessage(action) {
19086
19107
  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;
@@ -22286,7 +22307,8 @@ function deleteReaction(action) {
22286
22307
  }
22287
22308
  channelUpdateParam = {
22288
22309
  userMessageReactions: [],
22289
- lastReactedMessage: null
22310
+ lastReactedMessage: null,
22311
+ newReactions: []
22290
22312
  };
22291
22313
  _context40.n = 3;
22292
22314
  return put(updateChannelDataAC(channel.id, channelUpdateParam));
@@ -23882,7 +23904,7 @@ function MessageSaga() {
23882
23904
  return takeEvery(CANCEL_CHANNEL_MESSAGE_PROCESSES, cancelChannelMessageProcesses);
23883
23905
  case 22:
23884
23906
  _context65.n = 23;
23885
- return takeEvery(GET_REACTIONS, getReactions);
23907
+ return takeLatest(GET_REACTIONS, getReactions);
23886
23908
  case 23:
23887
23909
  _context65.n = 24;
23888
23910
  return takeEvery(LOAD_MORE_REACTIONS, loadMoreReactions);
@@ -29537,9 +29559,16 @@ function updateChannel(action) {
29537
29559
  avatarUrl: avatarUrl,
29538
29560
  metadata: isJSON(metadata) ? JSON.parse(metadata) : metadata
29539
29561
  });
29562
+ _context28.n = 6;
29563
+ return put(updateSearchedChannelDataAC(channelId, {
29564
+ subject: subject,
29565
+ avatarUrl: avatarUrl,
29566
+ metadata: isJSON(metadata) ? JSON.parse(metadata) : metadata
29567
+ }, getChannelGroupName(channel)));
29568
+ case 6:
29540
29569
  onUpdateChannel = getOnUpdateChannel();
29541
29570
  if (!onUpdateChannel) {
29542
- _context28.n = 7;
29571
+ _context28.n = 8;
29543
29572
  break;
29544
29573
  }
29545
29574
  fields = [];
@@ -29552,22 +29581,22 @@ function updateChannel(action) {
29552
29581
  if (JSON.stringify((_channel5 = channel) === null || _channel5 === void 0 ? void 0 : _channel5.metadata) !== metadata) {
29553
29582
  fields.push('metadata');
29554
29583
  }
29555
- _context28.n = 6;
29584
+ _context28.n = 7;
29556
29585
  return call(getChannelFromMap, channelId);
29557
- case 6:
29586
+ case 7:
29558
29587
  updatedChannel = _context28.v;
29559
29588
  onUpdateChannel(updatedChannel, fields);
29560
- case 7:
29561
- _context28.n = 9;
29562
- break;
29563
29589
  case 8:
29564
- _context28.p = 8;
29590
+ _context28.n = 10;
29591
+ break;
29592
+ case 9:
29593
+ _context28.p = 9;
29565
29594
  _t26 = _context28.v;
29566
29595
  log.error('ERROR in update channel', _t26.message);
29567
- case 9:
29596
+ case 10:
29568
29597
  return _context28.a(2);
29569
29598
  }
29570
- }, _marked27$1, null, [[0, 8]]);
29599
+ }, _marked27$1, null, [[0, 9]]);
29571
29600
  }
29572
29601
  function checkUsersStatus() {
29573
29602
  var _SceytChatClient7, usersForUpdate, updatedUsers, usersToUpdateMap, update, updateData, _t27;
@@ -31495,11 +31524,38 @@ function MembersSaga$1() {
31495
31524
  var isPinnedMessageDeleted = function isPinnedMessageDeleted(message) {
31496
31525
  return (message === null || message === void 0 ? void 0 : message.state) === MESSAGE_STATUS.DELETE;
31497
31526
  };
31498
- var getPinnedMessagePreview = function getPinnedMessagePreview(message) {
31499
- var _message$body, _message$attachments;
31527
+ var getPinnedMessageBody = function getPinnedMessageBody(message, contactsMap, getFromContacts) {
31528
+ var _message$bodyAttribut;
31529
+ if (contactsMap === void 0) {
31530
+ contactsMap = {};
31531
+ }
31532
+ if (getFromContacts === void 0) {
31533
+ getFromContacts = false;
31534
+ }
31535
+ var body = (message === null || message === void 0 ? void 0 : message.body) || '';
31536
+ if (!body || !(message !== null && message !== void 0 && (_message$bodyAttribut = message.bodyAttributes) !== null && _message$bodyAttribut !== void 0 && _message$bodyAttribut.length)) return body;
31537
+ var formattedBody = MessageTextFormat({
31538
+ text: body,
31539
+ message: message,
31540
+ contactsMap: contactsMap,
31541
+ getFromContacts: getFromContacts,
31542
+ asSampleText: true,
31543
+ accentColor: '',
31544
+ textSecondary: ''
31545
+ });
31546
+ return Array.isArray(formattedBody) ? formattedBody.join('') : String(formattedBody);
31547
+ };
31548
+ var getPinnedMessagePreview = function getPinnedMessagePreview(message, contactsMap, getFromContacts) {
31549
+ var _message$attachments;
31550
+ if (contactsMap === void 0) {
31551
+ contactsMap = {};
31552
+ }
31553
+ if (getFromContacts === void 0) {
31554
+ getFromContacts = false;
31555
+ }
31500
31556
  if (!message) return '';
31501
31557
  if (isPinnedMessageDeleted(message)) return 'Deleted message';
31502
- var body = (_message$body = message.body) === null || _message$body === void 0 ? void 0 : _message$body.trim();
31558
+ var body = getPinnedMessageBody(message, contactsMap, getFromContacts).trim();
31503
31559
  if (body) return body;
31504
31560
  if (message.pollDetails) return message.pollDetails.name || 'Poll';
31505
31561
  var attachment = (_message$attachments = message.attachments) === null || _message$attachments === void 0 ? void 0 : _message$attachments[0];
@@ -33898,16 +33954,13 @@ var ChannelMessageText = function ChannelMessageText(_ref2) {
33898
33954
  unsupportedMessage = _ref2.unsupportedMessage;
33899
33955
  var isViewOnce = (lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.type) === MESSAGE_TYPE.VIEW_ONCE && (lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.viewOnce);
33900
33956
  var systemMessageActor = lastMessage.user ? lastMessage.user.id === user.id ? 'You' : makeUsername(lastMessage.user && contactsMap && contactsMap[lastMessage.user.id], lastMessage.user, getFromContacts, true) : '';
33901
- var audioRecording = useMemo(function () {
33902
- return getAudioRecordingFromMap(channel.id);
33903
- }, [channel.id, draftMessageText]);
33904
33957
  return /*#__PURE__*/React__default.createElement(MessageTextContainer, null, isTypingOrRecording && (/*#__PURE__*/React__default.createElement(TypingIndicator, null, !isDirectChannel && /*#__PURE__*/React__default.createElement(Points, {
33905
33958
  color: textPrimary
33906
33959
  }, ":"), typingOrRecording.isTyping ? 'typing' : 'recording', "...")), !isTypingOrRecording && (draftMessageText ? (/*#__PURE__*/React__default.createElement(DraftMessageText, {
33907
33960
  color: textSecondary
33908
33961
  }, !lastMessage.body && (_lastMessage$attachme = lastMessage.attachments) !== null && _lastMessage$attachme !== void 0 && _lastMessage$attachme.length ? LastMessageAttachments({
33909
33962
  lastMessage: lastMessage
33910
- }) : null, audioRecording && /*#__PURE__*/React__default.createElement(SvgVoiceIcon, null), (!((_lastMessage$attachme2 = lastMessage.attachments) !== null && _lastMessage$attachme2 !== void 0 && _lastMessage$attachme2.length) || lastMessage.body) && MessageTextFormat({
33963
+ }) : null, (!((_lastMessage$attachme2 = lastMessage.attachments) !== null && _lastMessage$attachme2 !== void 0 && _lastMessage$attachme2.length) || lastMessage.body) && MessageTextFormat({
33911
33964
  text: (_lastMessage$attachme3 = lastMessage.attachments) !== null && _lastMessage$attachme3 !== void 0 && _lastMessage$attachme3.length ? lastMessage.body : draftMessageText,
33912
33965
  message: lastMessage,
33913
33966
  contactsMap: contactsMap,
@@ -34044,10 +34097,11 @@ var Channel = function Channel(_ref3) {
34044
34097
  setDraftMessageText(undefined);
34045
34098
  setDraftMessage(undefined);
34046
34099
  } else {
34100
+ var _channelDraftMessage$5;
34047
34101
  setDraftMessageText(draftText);
34048
34102
  setDraftMessage({
34049
34103
  mentionedUsers: channelDraftMessage.mentionedUsers,
34050
- body: channelDraftMessage.text,
34104
+ body: (_channelDraftMessage$5 = channelDraftMessage.text) !== null && _channelDraftMessage$5 !== void 0 && _channelDraftMessage$5.trim() ? channelDraftMessage.text : '',
34051
34105
  bodyAttributes: channelDraftMessage.bodyAttributes,
34052
34106
  attachments: channelDraftMessage.attachments,
34053
34107
  viewOnce: channelDraftMessage.viewOnce,
@@ -34056,7 +34110,14 @@ var Channel = function Channel(_ref3) {
34056
34110
  }
34057
34111
  } else if (draftAudioRecording) {
34058
34112
  setDraftMessageText('Voice');
34059
- setDraftMessage(undefined);
34113
+ setDraftMessage({
34114
+ body: '',
34115
+ attachments: [{
34116
+ type: attachmentTypes.voice,
34117
+ data: draftAudioRecording.file,
34118
+ attachmentUrl: draftAudioRecording.objectUrl
34119
+ }]
34120
+ });
34060
34121
  }
34061
34122
  } else if (draftMessageText) {
34062
34123
  setDraftMessageText(undefined);
@@ -36515,6 +36576,7 @@ var ChannelList = function ChannelList(_ref2) {
36515
36576
  List = _ref2.List,
36516
36577
  ListItem = _ref2.ListItem,
36517
36578
  getSelectedChannel = _ref2.getSelectedChannel,
36579
+ onSearchValueChange = _ref2.onSearchValueChange,
36518
36580
  Profile = _ref2.Profile,
36519
36581
  CreateChannel = _ref2.CreateChannel,
36520
36582
  ChannelsTitle = _ref2.ChannelsTitle,
@@ -36643,10 +36705,13 @@ var ChannelList = function ChannelList(_ref2) {
36643
36705
  getMyChannels();
36644
36706
  };
36645
36707
  var handleSearchValueChange = function handleSearchValueChange(e) {
36646
- setSearchValue(e.target.value);
36708
+ var value = e.target.value;
36709
+ setSearchValue(value);
36710
+ onSearchValueChange === null || onSearchValueChange === void 0 ? void 0 : onSearchValueChange(value);
36647
36711
  };
36648
36712
  var getMyChannels = function getMyChannels() {
36649
36713
  setSearchValue('');
36714
+ onSearchValueChange === null || onSearchValueChange === void 0 ? void 0 : onSearchValueChange('');
36650
36715
  };
36651
36716
  var handleOpenProfile = function handleOpenProfile() {
36652
36717
  setProfileIsOpen(!profileIsOpen);
@@ -39760,6 +39825,7 @@ var VideoPreview = /*#__PURE__*/memo(function VideoPreview(_ref) {
39760
39825
  markPreferredSourceLoaded = _useProgressiveMediaS.markPreferredSourceLoaded;
39761
39826
  var isExtractingRef = useRef(false);
39762
39827
  var hasExtractionFailedRef = useRef(false);
39828
+ var previousVideoSourceRef = useRef(undefined);
39763
39829
  useEffect(function () {
39764
39830
  if (!videoThumb || downloadedPreviewImage) return;
39765
39831
  var cancelled = false;
@@ -39776,10 +39842,16 @@ var VideoPreview = /*#__PURE__*/memo(function VideoPreview(_ref) {
39776
39842
  }, [videoThumb, downloadedPreviewImage, dispatch, messageType]);
39777
39843
  useEffect(function () {
39778
39844
  var videoSource = src;
39779
- if (!videoSource || !shouldExtractVideoFirstFrame(file.metadata) || isExtractingRef.current || hasExtractionFailedRef.current) return;
39845
+ var canExtractFirstFrame = shouldExtractVideoFirstFrame(file.metadata);
39846
+ if (previousVideoSourceRef.current !== videoSource) {
39847
+ previousVideoSourceRef.current = videoSource;
39848
+ hasExtractionFailedRef.current = false;
39849
+ }
39850
+ if (!videoSource || !canExtractFirstFrame || isExtractingRef.current || hasExtractionFailedRef.current) {
39851
+ return;
39852
+ }
39780
39853
  if (attachmentVideoFirstFrame || isPreview && setVideoIsReadyToSend) return;
39781
39854
  var frameCacheKey = typeof file.url === 'string' ? file.url : undefined;
39782
- hasExtractionFailedRef.current = false;
39783
39855
  var checkCache = function checkCache() {
39784
39856
  try {
39785
39857
  var _exit = false;
@@ -40169,7 +40241,7 @@ var Attachment = function Attachment(_ref) {
40169
40241
  }
40170
40242
  }
40171
40243
  var fallbackImageSource = withPrefix && attachmentThumb ? "data:image/jpeg;base64," + attachmentThumb : attachmentThumb;
40172
- var preferredImageSource = attachment.attachmentUrl || attachmentUrlFromMap || attachmentUrl;
40244
+ var preferredImageSource = isPreview ? attachment.attachmentUrl || attachmentUrlFromMap || attachmentUrl : attachmentUrlFromMap || attachment.attachmentUrl || attachmentUrl;
40173
40245
  var _useProgressiveMediaS = useProgressiveMediaSource(preferredImageSource, fallbackImageSource),
40174
40246
  displayedImageSource = _useProgressiveMediaS.displayedSource,
40175
40247
  previousImageSource = _useProgressiveMediaS.previousSource,
@@ -40501,6 +40573,9 @@ var Attachment = function Attachment(_ref) {
40501
40573
  var _getVideoAttachmentCa = getVideoAttachmentCacheKeys(attachment.url, attachment.metadata),
40502
40574
  videoThumb = _getVideoAttachmentCa.videoThumb,
40503
40575
  originalVideoCacheKey = _getVideoAttachmentCa.originalVideo;
40576
+ if (sharedOriginalVideoDownload.state === 'completed' && originalVideoDownloadStartedRef.current) {
40577
+ originalVideoDownloadStartedRef.current = false;
40578
+ }
40504
40579
  if (typeof originalVideoUrlFromMap === 'string') {
40505
40580
  setAttachmentUrl(originalVideoUrlFromMap);
40506
40581
  setIsCached(true);
@@ -40579,7 +40654,7 @@ var Attachment = function Attachment(_ref) {
40579
40654
  return function () {
40580
40655
  cancelled = true;
40581
40656
  };
40582
- }, [attachment.id, attachment.type, attachment.url, attachment.metadata, attachment.attachmentUrl, isDetailsView, originalVideoUrlFromMap, connectionStatus, dispatch, messageType, attachment.size, videoDownloadRetry, isSharedOriginalVideoCancelled]);
40657
+ }, [attachment.id, attachment.type, attachment.url, attachment.metadata, attachment.attachmentUrl, isDetailsView, originalVideoUrlFromMap, connectionStatus, dispatch, messageType, attachment.size, videoDownloadRetry, isSharedOriginalVideoCancelled, sharedOriginalVideoDownload.state]);
40583
40658
  var handleResumeOriginalVideoDownload = function handleResumeOriginalVideoDownload(event) {
40584
40659
  event.stopPropagation();
40585
40660
  if (!attachment.url) return;
@@ -41186,7 +41261,7 @@ var Attachment = function Attachment(_ref) {
41186
41261
  }, _formatLargeText(isPreview ? attachment.data.name : attachment.name, fileAttachmentWidth ? fileAttachmentWidth / 12.5 : isPreview ? 18 : 30)), /*#__PURE__*/React__default.createElement(AttachmentSize, {
41187
41262
  color: selectedFileAttachmentsSizeColor || textSecondary,
41188
41263
  errorColor: errorColor
41189
- }, (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, {
41264
+ }, (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, {
41190
41265
  "$backgroundColor": background,
41191
41266
  color: iconPrimary,
41192
41267
  onClick: function onClick() {
@@ -41297,7 +41372,7 @@ var AttachmentImg = styled.img(_templateObject13$3 || (_templateObject13$3 = _ta
41297
41372
  }, function (props) {
41298
41373
  return props.$fadeIn && css(_templateObject14$3 || (_templateObject14$3 = _taggedTemplateLiteralLoose(["\n opacity: 0;\n animation: ", " 100ms ease-in-out forwards;\n "])), mediaCrossFade);
41299
41374
  });
41300
- var VideoCont = styled.div(_templateObject15$2 || (_templateObject15$2 = _taggedTemplateLiteralLoose(["\n position: relative;\n cursor: pointer;\n width: 100%;\n height: ", ";\n"])), function (props) {
41375
+ var VideoCont = styled.div(_templateObject15$2 || (_templateObject15$2 = _taggedTemplateLiteralLoose(["\n position: relative;\n cursor: pointer;\n height: ", ";\n"])), function (props) {
41301
41376
  return props.isDetailsView && '100%';
41302
41377
  });
41303
41378
 
@@ -42545,7 +42620,7 @@ var SliderPopup = function SliderPopup(_ref) {
42545
42620
  };
42546
42621
  var handleClicks = useCallback(function (e) {
42547
42622
  var target = e.target;
42548
- if (!target.closest('.custom_carousel_item') && !target.closest('.custom_carousel_arrow')) {
42623
+ if (!target.closest('.slider-preview-media, .custom_video_player, .custom_carousel_arrow')) {
42549
42624
  if (currentFileType === 'image') {
42550
42625
  log.info('[MEDIA_IMAGE_SLIDER] outside click closing slider ' + JSON.stringify({
42551
42626
  channelId: channel.id,
@@ -42982,6 +43057,7 @@ var SliderPopup = function SliderPopup(_ref) {
42982
43057
  })))), isItemLoading(file.id) && file.type === 'image' && (/*#__PURE__*/React__default.createElement(ItemLoadingCont, null, /*#__PURE__*/React__default.createElement(UploadingIcon, {
42983
43058
  color: textOnPrimary
42984
43059
  }))), 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", {
43060
+ className: 'slider-preview-media',
42985
43061
  loading: 'eager',
42986
43062
  decoding: 'async',
42987
43063
  draggable: false,
@@ -43096,7 +43172,7 @@ var IconWrapper = styled.span(_templateObject10$7 || (_templateObject10$7 = _tag
43096
43172
  }, function (props) {
43097
43173
  return props.hideInMobile && "\n @media (max-width: 550px) {\n display: none;\n }\n ";
43098
43174
  });
43099
- var CarouselItem$1 = styled.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"])));
43175
+ var CarouselItem$1 = styled.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"])));
43100
43176
  var UploadCont$1 = styled.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"])));
43101
43177
  var ItemLoadingCont = styled.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"])));
43102
43178
  var ArrowButton = styled.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) {
@@ -43130,7 +43206,8 @@ var Message = function Message(_ref) {
43130
43206
  backgroundColor = _ref.backgroundColor,
43131
43207
  borderRadius = _ref.borderRadius,
43132
43208
  contactsMap = _ref.contactsMap,
43133
- setLastVisibleMessageId = _ref.setLastVisibleMessageId;
43209
+ setLastVisibleMessageId = _ref.setLastVisibleMessageId,
43210
+ renderPinnedMessagePreview = _ref.renderPinnedMessagePreview;
43134
43211
  var _useColor = useColors(),
43135
43212
  textOnPrimary = _useColor[THEME_COLORS.TEXT_ON_PRIMARY],
43136
43213
  overlayBackground = _useColor[THEME_COLORS.OVERLAY_BACKGROUND];
@@ -43148,9 +43225,13 @@ var Message = function Message(_ref) {
43148
43225
  var actorName = message.incoming ? makeUsername(message.user && contactsMap[message.user.id], message.user, getFromContacts) : 'You';
43149
43226
  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;
43150
43227
  var pinnedMessagePreview = useMemo(function () {
43151
- return getPinnedMessagePreview(message.parentMessage);
43152
- }, [message.parentMessage]);
43228
+ return getPinnedMessagePreview(message.parentMessage, contactsMap, getFromContacts);
43229
+ }, [contactsMap, getFromContacts, message.parentMessage]);
43153
43230
  var pinnedMessageDeleted = isPinnedMessageDeleted(message.parentMessage);
43231
+ var customPinnedMessagePreview = pinnedMessageDeleted || !message.parentMessage ? null : renderPinnedMessagePreview === null || renderPinnedMessagePreview === void 0 ? void 0 : renderPinnedMessagePreview(message.parentMessage, {
43232
+ placement: 'system'
43233
+ });
43234
+ var pinnedPreview = customPinnedMessagePreview != null ? customPinnedMessagePreview : pinnedMessagePreview;
43154
43235
  var navigateToPinnedMessage = function navigateToPinnedMessage() {
43155
43236
  if (parentMessageId) navigateToMessage(parentMessageId);
43156
43237
  };
@@ -43187,7 +43268,7 @@ var Message = function Message(_ref) {
43187
43268
  onClick: navigateToPinnedMessage,
43188
43269
  disabled: !parentMessageId,
43189
43270
  "aria-label": parentMessageId ? 'Go to pinned message' : undefined
43190
- }, 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) {
43271
+ }, 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) {
43191
43272
  return mem === user.id ? 'You' : " " + systemMessageUserName(mem, contactsMap[mem], message.mentionedUsers);
43192
43273
  })) + " " + (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) {
43193
43274
  return mem === user.id ? 'You' : " " + systemMessageUserName(mem, contactsMap[mem], message.mentionedUsers);
@@ -43238,18 +43319,18 @@ var attachmentMetadata = function attachmentMetadata(attachment) {
43238
43319
  return {};
43239
43320
  }
43240
43321
  };
43241
- var preview = function preview(message) {
43322
+ var preview = function preview(message, contactsMap, getFromContacts) {
43242
43323
  var _message$attachments;
43243
43324
  if (isPinnedMessageDeleted(message)) return 'Deleted Message';
43244
43325
  if (message !== null && message !== void 0 && message.pollDetails) return "Poll: " + (message.pollDetails.name || message.body || 'Poll');
43245
43326
  var attachment = message === null || message === void 0 ? void 0 : (_message$attachments = message.attachments) === null || _message$attachments === void 0 ? void 0 : _message$attachments[0];
43246
- if (!attachment) return (message === null || message === void 0 ? void 0 : message.body) || (message !== null && message !== void 0 && message.forwardingDetails ? 'Shared content' : 'Message');
43327
+ if (!attachment) return getPinnedMessageBody(message, contactsMap, getFromContacts) || (message !== null && message !== void 0 && message.forwardingDetails ? 'Shared content' : 'Message');
43247
43328
  var metadata = attachmentMetadata(attachment);
43248
43329
  if (attachment.type === attachmentTypes.voice) {
43249
43330
  var duration = metadata.duration || metadata.dur || attachment.duration;
43250
43331
  return "Voice" + (duration ? ": " + formatDuration(duration) : '');
43251
43332
  }
43252
- if (message !== null && message !== void 0 && message.body) return message.body;
43333
+ if (message !== null && message !== void 0 && message.body) return getPinnedMessageBody(message, contactsMap, getFromContacts);
43253
43334
  if (attachment.type === attachmentTypes.image) return 'Photo';
43254
43335
  if (attachment.type === attachmentTypes.video) {
43255
43336
  return 'Video';
@@ -43281,10 +43362,13 @@ var PinnedMessagesBanner = function PinnedMessagesBanner(_ref) {
43281
43362
  var _active$message, _active$message2, _active$message3, _active$message3$atta, _active$message4;
43282
43363
  var channelId = _ref.channelId,
43283
43364
  pinIcon = _ref.pinIcon,
43284
- onOpenList = _ref.onOpenList;
43365
+ onOpenList = _ref.onOpenList,
43366
+ renderPinnedMessagePreview = _ref.renderPinnedMessagePreview;
43285
43367
  var dispatch = useDispatch();
43286
43368
  var pins = useSelector(pinnedMessagesSelector(channelId));
43287
43369
  var nextToken = useSelector(pinnedMessagesCursorSelector(channelId));
43370
+ var contactsMap = useSelector(contactsMapSelector);
43371
+ var getFromContacts = getShowOnlyContactUsers();
43288
43372
  var _useColor = useColors(),
43289
43373
  surface1 = _useColor[THEME_COLORS.SURFACE_1],
43290
43374
  textPrimary = _useColor[THEME_COLORS.TEXT_PRIMARY],
@@ -43357,6 +43441,9 @@ var PinnedMessagesBanner = function PinnedMessagesBanner(_ref) {
43357
43441
  });
43358
43442
  var linkPreviewImage = getLinkPreviewImage(attachment);
43359
43443
  var sourceMessageDeleted = isPinnedMessageDeleted(active.message);
43444
+ var customPinnedMessagePreview = sourceMessageDeleted ? null : renderPinnedMessagePreview === null || renderPinnedMessagePreview === void 0 ? void 0 : renderPinnedMessagePreview(active.message, {
43445
+ placement: 'banner'
43446
+ });
43360
43447
  var hasLeadingPreview = !sourceMessageDeleted && (hasAttachmentTile(attachmentForPreview) || (attachment === null || attachment === void 0 ? void 0 : attachment.type) === attachmentTypes.link);
43361
43448
  var markerFade = count <= 3 ? 'none' : index <= 1 ? 'top' : index >= count - 2 ? 'bottom' : 'both';
43362
43449
  var loadNextPage = function loadNextPage() {
@@ -43440,7 +43527,7 @@ var PinnedMessagesBanner = function PinnedMessagesBanner(_ref) {
43440
43527
  }, /*#__PURE__*/React__default.createElement("strong", null, "Pinned messages"), /*#__PURE__*/React__default.createElement(PinnedCopyPreview, {
43441
43528
  key: active.id,
43442
43529
  textPrimary: textPrimary
43443
- }, preview(active.message))), /*#__PURE__*/React__default.createElement(Controls$1, {
43530
+ }, customPinnedMessagePreview != null ? customPinnedMessagePreview : preview(active.message, contactsMap, getFromContacts))), /*#__PURE__*/React__default.createElement(Controls$1, {
43444
43531
  onClick: function onClick(event) {
43445
43532
  return event.stopPropagation();
43446
43533
  },
@@ -45706,12 +45793,14 @@ var PinnedMessagesList = function PinnedMessagesList(_ref) {
45706
45793
  };
45707
45794
  var positionNavigationControl = function positionNavigationControl(message, event) {
45708
45795
  var messageId = message.id || message.tid;
45709
- var messageContent = event.currentTarget.querySelector('.messageContent');
45796
+ var messageContent = event.querySelector('.messageContent');
45710
45797
  if (!messageId || !messageContent) return;
45711
- var rowBounds = event.currentTarget.getBoundingClientRect();
45798
+ var rowBounds = event.getBoundingClientRect();
45712
45799
  var contentBounds = messageContent.getBoundingClientRect();
45713
- var messageItem = event.currentTarget.querySelector('.message_item');
45714
- var bottom = messageItem ? Number.parseFloat(window.getComputedStyle(messageItem).marginBottom) || 0 : 0;
45800
+ var messageItem = event.querySelector('.message_item');
45801
+ var reactionContainer = event.querySelector('[data-reactions-container]');
45802
+ var itemMarginBottom = messageItem ? Number.parseFloat(window.getComputedStyle(messageItem).marginBottom) || 0 : 0;
45803
+ var bottom = itemMarginBottom + ((reactionContainer === null || reactionContainer === void 0 ? void 0 : reactionContainer.getBoundingClientRect().height) || 0);
45715
45804
  var left = message.incoming ? contentBounds.right - rowBounds.left + 8 : contentBounds.left - rowBounds.left - 36 - 8;
45716
45805
  setNavigationOffsets(function (current) {
45717
45806
  var _extends2;
@@ -45723,6 +45812,17 @@ var PinnedMessagesList = function PinnedMessagesList(_ref) {
45723
45812
  }, _extends2));
45724
45813
  });
45725
45814
  };
45815
+ useEffect(function () {
45816
+ if (pins) {
45817
+ for (var i = 0; i < pins.length; i++) {
45818
+ var pin = pins[i];
45819
+ var pinnedElement = document.querySelector("[data-pinned-message-id=\"" + pin.id + "\"]");
45820
+ if (pinnedElement) {
45821
+ positionNavigationControl(pin.message, pinnedElement);
45822
+ }
45823
+ }
45824
+ }
45825
+ }, [pins]);
45726
45826
  useLayoutEffect(function () {
45727
45827
  var element = itemsRef.current;
45728
45828
  if (!element) return;
@@ -45759,7 +45859,7 @@ var PinnedMessagesList = function PinnedMessagesList(_ref) {
45759
45859
  key: pin.id,
45760
45860
  "data-pinned-message-id": pin.id,
45761
45861
  onMouseEnter: function onMouseEnter(event) {
45762
- return positionNavigationControl(pin.message, event);
45862
+ return positionNavigationControl(pin.message, event.currentTarget);
45763
45863
  }
45764
45864
  }, renderMessage({
45765
45865
  message: pin.message,
@@ -47228,7 +47328,9 @@ function EmojisPopup(_ref2) {
47228
47328
  backgroundHovered = _useColor[THEME_COLORS.BACKGROUND_HOVERED],
47229
47329
  border = _useColor[THEME_COLORS.BORDER],
47230
47330
  iconPrimary = _useColor[THEME_COLORS.ICON_PRIMARY],
47231
- scrollbarThumbColor = _useColor[THEME_COLORS.SURFACE_2];
47331
+ scrollbarThumbColor = _useColor[THEME_COLORS.SURFACE_2],
47332
+ background = _useColor[THEME_COLORS.BACKGROUND];
47333
+ var theme = useSelector(themeSelector);
47232
47334
  var _useState = useState(false),
47233
47335
  rendered = _useState[0],
47234
47336
  setRendered = _useState[1];
@@ -47319,7 +47421,7 @@ function EmojisPopup(_ref2) {
47319
47421
  }, getEmojisCategoryTitle(activeCollection))), /*#__PURE__*/React__default.createElement(EmojiSection, {
47320
47422
  ref: emojiContainerRef,
47321
47423
  onScroll: handleEmojiListScroll,
47322
- scrollbarThumbColor: scrollbarThumbColor
47424
+ scrollbarThumbColor: theme === 'dark' ? background : scrollbarThumbColor
47323
47425
  }, /*#__PURE__*/React__default.createElement(AllEmojis, null, EMOJIS.map(function (emojiBigCollection, bigColIndex) {
47324
47426
  var mainCollectionKey = emojiBigCollection.key;
47325
47427
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, {
@@ -49306,6 +49408,8 @@ function ReactionsPopup(_ref) {
49306
49408
  reactionTotals = _ref.reactionTotals,
49307
49409
  reactionsDetailsPopupBorderRadius = _ref.reactionsDetailsPopupBorderRadius,
49308
49410
  reactionsDetailsPopupHeaderItemsStyle = _ref.reactionsDetailsPopupHeaderItemsStyle,
49411
+ _ref$popupZIndex = _ref.popupZIndex,
49412
+ popupZIndex = _ref$popupZIndex === void 0 ? 12 : _ref$popupZIndex,
49309
49413
  rtlDirection = _ref.rtlDirection,
49310
49414
  openUserProfile = _ref.openUserProfile;
49311
49415
  var _useColor = useColors(),
@@ -49327,6 +49431,13 @@ function ReactionsPopup(_ref) {
49327
49431
  var _useState = useState('all'),
49328
49432
  activeTabKey = _useState[0],
49329
49433
  setActiveTabKey = _useState[1];
49434
+ var reactionTotalsSignature = reactionTotals.map(function (_ref2) {
49435
+ var key = _ref2.key,
49436
+ count = _ref2.count,
49437
+ score = _ref2.score;
49438
+ return key + ":" + count + ":" + score;
49439
+ }).join('|');
49440
+ var reactionTotalsSignatureRef = useRef(reactionTotalsSignature);
49330
49441
  var _useState2 = useState(0),
49331
49442
  popupHeight = _useState2[0],
49332
49443
  setPopupHeight = _useState2[1];
@@ -49355,7 +49466,7 @@ function ReactionsPopup(_ref) {
49355
49466
  }
49356
49467
  };
49357
49468
  var handleClicks = function handleClicks(e) {
49358
- if (e.target.closest('.reactions_popup')) {
49469
+ if (e.target.closest('.reactions_popup') || e.target.closest('[data-reactions-container]')) {
49359
49470
  return;
49360
49471
  }
49361
49472
  if (closeIsApproved) {
@@ -49387,6 +49498,19 @@ function ReactionsPopup(_ref) {
49387
49498
  handleReactionsPopupClose();
49388
49499
  }
49389
49500
  }, [reactionTotals]);
49501
+ useEffect(function () {
49502
+ if (reactionTotalsSignatureRef.current === reactionTotalsSignature || !reactionTotals.length) {
49503
+ return;
49504
+ }
49505
+ reactionTotalsSignatureRef.current = reactionTotalsSignature;
49506
+ var nextActiveTabKey = activeTabKey !== 'all' && reactionTotals.some(function (reaction) {
49507
+ return reaction.key === activeTabKey;
49508
+ }) ? activeTabKey : 'all';
49509
+ if (nextActiveTabKey !== activeTabKey) {
49510
+ setActiveTabKey(nextActiveTabKey);
49511
+ }
49512
+ handleGetReactions(nextActiveTabKey === 'all' ? undefined : nextActiveTabKey);
49513
+ }, [activeTabKey, reactionTotals, reactionTotalsSignature]);
49390
49514
  var reactionsHeight = useMemo(function () {
49391
49515
  return reactions.length * 50 + 45;
49392
49516
  }, [reactions]);
@@ -49420,9 +49544,9 @@ function ReactionsPopup(_ref) {
49420
49544
  bottom: bottom,
49421
49545
  left: left,
49422
49546
  right: right,
49423
- zIndex: 12
49547
+ zIndex: popupZIndex
49424
49548
  };
49425
- }, [popupVerticalPosition, anchorTop, anchorBottom, horizontalPositions, rtlDirection]);
49549
+ }, [popupVerticalPosition, anchorTop, anchorBottom, horizontalPositions, popupZIndex, rtlDirection]);
49426
49550
  return /*#__PURE__*/createPortal(/*#__PURE__*/React__default.createElement(Container$i, {
49427
49551
  ref: popupRef,
49428
49552
  popupVerticalPosition: popupVerticalPosition,
@@ -49593,9 +49717,11 @@ var MessageReactions = function MessageReactions(_ref) {
49593
49717
  reactionsContainerPadding = _ref.reactionsContainerPadding,
49594
49718
  reactionsDetailsPopupBorderRadius = _ref.reactionsDetailsPopupBorderRadius,
49595
49719
  reactionsDetailsPopupHeaderItemsStyle = _ref.reactionsDetailsPopupHeaderItemsStyle,
49720
+ popupZIndex = _ref.popupZIndex,
49596
49721
  onToggleReactionsPopup = _ref.onToggleReactionsPopup,
49597
49722
  onReactionAddDelete = _ref.onReactionAddDelete,
49598
49723
  onOpenUserProfile = _ref.onOpenUserProfile;
49724
+ var messageId = message.id || message.tid;
49599
49725
  var enableTransitionRef = React__default.useCallback(function (el) {
49600
49726
  if (!el) return;
49601
49727
  window.requestAnimationFrame(function () {
@@ -49609,15 +49735,17 @@ var MessageReactions = function MessageReactions(_ref) {
49609
49735
  anchorTop: reactionsAnchorTop,
49610
49736
  anchorBottom: reactionsAnchorBottom,
49611
49737
  reactionTotals: message.reactionTotals || [],
49612
- messageId: message.id,
49738
+ messageId: messageId,
49613
49739
  handleReactionsPopupClose: onToggleReactionsPopup,
49614
49740
  rtlDirection: rtlDirection,
49615
49741
  handleAddDeleteEmoji: onReactionAddDelete,
49616
49742
  reactionsDetailsPopupBorderRadius: reactionsDetailsPopupBorderRadius,
49617
- reactionsDetailsPopupHeaderItemsStyle: reactionsDetailsPopupHeaderItemsStyle
49743
+ reactionsDetailsPopupHeaderItemsStyle: reactionsDetailsPopupHeaderItemsStyle,
49744
+ popupZIndex: popupZIndex
49618
49745
  })), /*#__PURE__*/React__default.createElement(ReactionsContainer, {
49619
49746
  ref: enableTransitionRef,
49620
- id: message.id + "_reactions_container",
49747
+ id: messageId + "_reactions_container",
49748
+ "data-reactions-container": true,
49621
49749
  border: reactionsContainerBorder,
49622
49750
  boxShadow: reactionsContainerBoxShadow,
49623
49751
  borderRadius: reactionsContainerBorderRadius,
@@ -50768,9 +50896,10 @@ var MESSAGE_ACTIONS_HOVER_DELAY = 450;
50768
50896
  var MESSAGE_ACTIONS_FLIP_THRESHOLD = 110;
50769
50897
  var MAX_SELECTED_MESSAGES = 30;
50770
50898
  var EMOJI_POPUP_THRESHOLD = 300;
50899
+ var PIN_TYPE_PERSONAL$1 = 1;
50771
50900
  var lastMediaItemClickTime = 0;
50772
50901
  var Message$1 = function Message(_ref) {
50773
- var _tabIsActiveRef$curre, _message$pinDetails, _message$reactionTota;
50902
+ var _tabIsActiveRef$curre, _message$pinDetails, _channel$members, _message$reactionTota;
50774
50903
  var message = _ref.message,
50775
50904
  channel = _ref.channel,
50776
50905
  MessageActionsMenu = _ref.MessageActionsMenu,
@@ -51001,6 +51130,8 @@ var Message$1 = function Message(_ref) {
51001
51130
  }, [pins, message.id, message.tid]);
51002
51131
  var isPinned = !!((_message$pinDetails = message.pinDetails) !== null && _message$pinDetails !== void 0 && _message$pinDetails.pinned) || !!pinnedMessage;
51003
51132
  var canPinForAll = checkActionPermission('pinMessage');
51133
+ var user = getClient().user;
51134
+ 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);
51004
51135
  var messageItemRef = useRef(null);
51005
51136
  var isVisible = useOnScreen(messageItemRef);
51006
51137
  var _useState = useState(false),
@@ -51018,14 +51149,14 @@ var Message$1 = function Message(_ref) {
51018
51149
  var prevMessageUserID = prevMessage ? getComparableUserId(prevMessage.user) : null;
51019
51150
  var current = moment(message.createdAt).startOf('day');
51020
51151
  var firstMessageInInterval = useMemo(function () {
51021
- return ifLatestAndHasNotPreview || !(prevMessage && current.diff(moment(prevMessage.createdAt).startOf('day'), 'days') === 0) || (prevMessage === null || prevMessage === void 0 ? void 0 : prevMessage.type) === MESSAGE_TYPE.SYSTEM || unreadMessageId === prevMessage.id;
51022
- }, [prevMessage, unreadMessageId, ifLatestAndHasNotPreview]);
51152
+ return ifLatestAndHasNotPreview || !isPinnedMessagesList && !(prevMessage && current.diff(moment(prevMessage.createdAt).startOf('day'), 'days') === 0) || (prevMessage === null || prevMessage === void 0 ? void 0 : prevMessage.type) === MESSAGE_TYPE.SYSTEM || unreadMessageId === (prevMessage === null || prevMessage === void 0 ? void 0 : prevMessage.id);
51153
+ }, [prevMessage, unreadMessageId, ifLatestAndHasNotPreview, isPinnedMessagesList]);
51023
51154
  var nextMessageUserID = nextMessage ? getComparableUserId(nextMessage.user) : null;
51024
51155
  var nextDay = nextMessage ? moment(nextMessage.createdAt).startOf('day') : null;
51025
51156
  var nextMessageFirstInInterval = !nextMessage || nextDay !== null && nextDay.diff(current, 'days') !== 0 || nextMessage.type === MESSAGE_TYPE.SYSTEM || nextMessageStartsUnreadSection;
51026
51157
  var messageTimeVisible = showMessageTime && (showMessageTimeForEachMessage || !nextMessage);
51027
51158
  var messageStatusVisible = !message.incoming && showMessageStatus && message.state !== MESSAGE_STATUS.DELETE && (showMessageStatusForEachMessage || !nextMessage);
51028
- var renderAvatar = (!!prevMessageUserID || ifLatestAndHasNotPreview) && (prevMessageUserID !== messageUserID || firstMessageInInterval) && !(channel.type === DEFAULT_CHANNEL_TYPE.DIRECT && !showSenderNameOnDirectChannel) && !(!message.incoming && !showOwnAvatar);
51159
+ var renderAvatar = (!!prevMessageUserID || ifLatestAndHasNotPreview) && (prevMessageUserID !== messageUserID || firstMessageInInterval) && !(isPinnedMessagesList && channel.type === DEFAULT_CHANNEL_TYPE.DIRECT) && !(channel.type === DEFAULT_CHANNEL_TYPE.DIRECT && !showSenderNameOnDirectChannel) && !(!message.incoming && !showOwnAvatar);
51029
51160
  var selectionIsActive = selectedMessagesMap && selectedMessagesMap.size > 0;
51030
51161
  var isSelectedMessage = selectedMessagesMap && selectedMessagesMap.get(message.id || message.tid);
51031
51162
  var tooManySelected = selectedMessagesMap && selectedMessagesMap.size >= MAX_SELECTED_MESSAGES;
@@ -51078,11 +51209,16 @@ var Message$1 = function Message(_ref) {
51078
51209
  setMessageActionsShow(false);
51079
51210
  }, [channel.id, isPinnedMessagesList, message.id, message.tid, setInfoPopupOpen, setMessageActionsShow]);
51080
51211
  var handleTogglePinMessagePopup = useCallback(function () {
51212
+ if (isSelfChannel) {
51213
+ dispatch(pinMessageAC(channel.id, message, PIN_TYPE_PERSONAL$1));
51214
+ setMessageActionsShow(false);
51215
+ return;
51216
+ }
51081
51217
  setPinPopupOpen(function (prev) {
51082
51218
  return !prev;
51083
51219
  });
51084
51220
  setMessageActionsShow(false);
51085
- }, [setPinPopupOpen, setMessageActionsShow]);
51221
+ }, [channel.id, dispatch, isSelfChannel, message, setMessageActionsShow, setPinPopupOpen]);
51086
51222
  var handlePinMessage = useCallback(function (scope) {
51087
51223
  dispatch(pinMessageAC(channel.id, message, scope));
51088
51224
  setPinPopupOpen(false);
@@ -51149,10 +51285,10 @@ var Message$1 = function Message(_ref) {
51149
51285
  setMessageActionsShow(false);
51150
51286
  }, [message, contactsMap]);
51151
51287
  var handleToggleReactionsPopup = useCallback(function () {
51152
- var _messageItemRef$curre;
51153
- var reactionsContainer = document.getElementById(message.id + "_reactions_container");
51288
+ var _messageItemRef$curre, _messageItemRef$curre2;
51289
+ var reactionsContainer = (_messageItemRef$curre = messageItemRef.current) === null || _messageItemRef$curre === void 0 ? void 0 : _messageItemRef$curre.querySelector('[data-reactions-container]');
51154
51290
  var reactionsContPos = reactionsContainer === null || reactionsContainer === void 0 ? void 0 : reactionsContainer.getBoundingClientRect();
51155
- var bottomPos = (_messageItemRef$curre = messageItemRef.current) === null || _messageItemRef$curre === void 0 ? void 0 : _messageItemRef$curre.getBoundingClientRect().bottom;
51291
+ var bottomPos = (_messageItemRef$curre2 = messageItemRef.current) === null || _messageItemRef$curre2 === void 0 ? void 0 : _messageItemRef$curre2.getBoundingClientRect().bottom;
51156
51292
  var offsetBottom = bottomPos ? window.innerHeight - bottomPos : 0;
51157
51293
  setReactionsPopupPosition(offsetBottom);
51158
51294
  setReactionsPopupHorizontalPosition({
@@ -51165,15 +51301,15 @@ var Message$1 = function Message(_ref) {
51165
51301
  setReactionsPopupOpen(function (prev) {
51166
51302
  return !prev;
51167
51303
  });
51168
- }, [dispatch, message.id]);
51304
+ }, [dispatch, message.id, message.tid]);
51169
51305
  var handleMouseEnter = useCallback(function () {
51170
51306
  if (message.state !== MESSAGE_STATUS.DELETE && !selectionIsActive && !infoPopupOpen) {
51171
51307
  messageActionsTimeout.current = setTimeout(function () {
51172
- var _messageItemRef$curre2, _messageItemRef$curre3;
51308
+ var _messageItemRef$curre3, _messageItemRef$curre4;
51173
51309
  if (Date.now() - lastMediaItemClickTime < MESSAGE_ACTIONS_HOVER_DELAY * 2) {
51174
51310
  return;
51175
51311
  }
51176
- var msgTop = (_messageItemRef$curre2 = (_messageItemRef$curre3 = messageItemRef.current) === null || _messageItemRef$curre3 === void 0 ? void 0 : _messageItemRef$curre3.getBoundingClientRect().top) != null ? _messageItemRef$curre2 : 0;
51312
+ var msgTop = (_messageItemRef$curre3 = (_messageItemRef$curre4 = messageItemRef.current) === null || _messageItemRef$curre4 === void 0 ? void 0 : _messageItemRef$curre4.getBoundingClientRect().top) != null ? _messageItemRef$curre3 : 0;
51177
51313
  setMessageActionsBelow(msgTop < MESSAGE_ACTIONS_FLIP_THRESHOLD);
51178
51314
  setMessageActionsShow(true);
51179
51315
  dispatch(setMessageMenuOpenedAC(message.id || message.tid));
@@ -51276,6 +51412,7 @@ var Message$1 = function Message(_ref) {
51276
51412
  }
51277
51413
  }, [dispatch, selectionIsActive]);
51278
51414
  useEffect(function () {
51415
+ if (isPinnedMessagesList) return;
51279
51416
  if (isVisible) {
51280
51417
  if (setLastVisibleMessageId) {
51281
51418
  setLastVisibleMessageId(message);
@@ -51288,12 +51425,13 @@ var Message$1 = function Message(_ref) {
51288
51425
  } else {
51289
51426
  dispatch(removeVisibleMessageAC(message));
51290
51427
  }
51291
- }, [isVisible, setLastVisibleMessageId, message.id, handleSendReadMarker, channel.lastMessage, scrollToNewMessage.scrollToBottom, dispatch, message, isTabActive]);
51428
+ }, [isVisible, setLastVisibleMessageId, message.id, handleSendReadMarker, channel.lastMessage, scrollToNewMessage.scrollToBottom, dispatch, message, isTabActive, isPinnedMessagesList]);
51292
51429
  useEffect(function () {
51430
+ if (isPinnedMessagesList) return undefined;
51293
51431
  return function () {
51294
51432
  dispatch(removeVisibleMessageAC(message));
51295
51433
  };
51296
- }, [dispatch, message]);
51434
+ }, [dispatch, isPinnedMessagesList, message]);
51297
51435
  useEffect(function () {
51298
51436
  if (!isPinnedMessagesList && !isVisible && infoPopupOpen) {
51299
51437
  setInfoPopupOpen(false);
@@ -51341,7 +51479,7 @@ var Message$1 = function Message(_ref) {
51341
51479
  if (!reactionsPopupOpen) {
51342
51480
  return undefined;
51343
51481
  }
51344
- var scrollContainer = document.getElementById('scrollableDiv');
51482
+ var scrollContainer = document.getElementById(isPinnedMessagesList ? 'pinnedScrollableDiv' : 'scrollableDiv');
51345
51483
  if (!scrollContainer) {
51346
51484
  return undefined;
51347
51485
  }
@@ -51354,7 +51492,7 @@ var Message$1 = function Message(_ref) {
51354
51492
  return function () {
51355
51493
  scrollContainer.removeEventListener('scroll', handleChatScroll);
51356
51494
  };
51357
- }, [reactionsPopupOpen]);
51495
+ }, [isPinnedMessagesList, reactionsPopupOpen]);
51358
51496
  useEffect(function () {
51359
51497
  document.addEventListener('mousedown', handleClick);
51360
51498
  return function () {
@@ -51388,8 +51526,8 @@ var Message$1 = function Message(_ref) {
51388
51526
  if (!nextMessage || nextMessage.type === MESSAGE_TYPE.SYSTEM) {
51389
51527
  spacingBottom = '';
51390
51528
  } else if (nextMessageStartsUnreadSection) {
51391
- spacingBottom = differentUserMessageSpacing || '16px';
51392
- } else if (nextMessageUserID && (nextMessageUserID !== messageUserID || nextMessageFirstInInterval)) {
51529
+ spacingBottom = isPinnedMessagesList ? '0' : differentUserMessageSpacing || '16px';
51530
+ } else if (nextMessageUserID && (nextMessageUserID !== messageUserID || nextMessageFirstInInterval && !isPinnedMessagesList)) {
51393
51531
  spacingBottom = differentUserMessageSpacing || '16px';
51394
51532
  }
51395
51533
  spacingTop = sameUserMessageSpacing || '6px';
@@ -51402,7 +51540,7 @@ var Message$1 = function Message(_ref) {
51402
51540
  bottom: reactionsMargin || spacingBottom,
51403
51541
  top: spacingTop
51404
51542
  };
51405
- }, [nextMessageUserID, messageUserID, nextMessageFirstInInterval, (_message$reactionTota = message.reactionTotals) === null || _message$reactionTota === void 0 ? void 0 : _message$reactionTota.length]);
51543
+ }, [nextMessageUserID, isPinnedMessagesList, messageUserID, nextMessageFirstInInterval, (_message$reactionTota = message.reactionTotals) === null || _message$reactionTota === void 0 ? void 0 : _message$reactionTota.length]);
51406
51544
  return /*#__PURE__*/React__default.createElement(MessageItem, {
51407
51545
  className: 'message_item',
51408
51546
  rtl: ownMessageOnRightSide && !message.incoming,
@@ -51437,7 +51575,7 @@ var Message$1 = function Message(_ref) {
51437
51575
  selectionIsActive: selectionIsActive,
51438
51576
  messageWidthPercent: messageWidthPercent,
51439
51577
  rtl: ownMessageOnRightSide && !message.incoming,
51440
- withAvatar: !(channel.type === DEFAULT_CHANNEL_TYPE.DIRECT && !showSenderNameOnDirectChannel) && !(!message.incoming && !showOwnAvatar),
51578
+ withAvatar: !(isPinnedMessagesList && channel.type === DEFAULT_CHANNEL_TYPE.DIRECT) && !(channel.type === DEFAULT_CHANNEL_TYPE.DIRECT && !showSenderNameOnDirectChannel) && !(!message.incoming && !showOwnAvatar),
51441
51579
  className: 'messageContent'
51442
51580
  }, message.state === MESSAGE_STATUS.FAILED && (/*#__PURE__*/React__default.createElement(FailedMessageIcon, {
51443
51581
  rtl: ownMessageOnRightSide && !message.incoming,
@@ -51447,6 +51585,7 @@ var Message$1 = function Message(_ref) {
51447
51585
  ifLatestAndHasNotPreview: ifLatestAndHasNotPreview,
51448
51586
  channel: channel,
51449
51587
  message: message,
51588
+ isPinnedMessagesList: isPinnedMessagesList,
51450
51589
  prevMessage: prevMessage,
51451
51590
  nextMessage: nextMessage,
51452
51591
  unreadMessageId: unreadMessageId,
@@ -51671,6 +51810,7 @@ var Message$1 = function Message(_ref) {
51671
51810
  reactionsContainerPadding: reactionsContainerPadding,
51672
51811
  reactionsDetailsPopupBorderRadius: reactionsDetailsPopupBorderRadius,
51673
51812
  reactionsDetailsPopupHeaderItemsStyle: reactionsDetailsPopupHeaderItemsStyle,
51813
+ popupZIndex: isPinnedMessagesList ? 30 : undefined,
51674
51814
  onToggleReactionsPopup: handleToggleReactionsPopup,
51675
51815
  onReactionAddDelete: handleReactionAddDelete,
51676
51816
  onOpenUserProfile: handleOpenUserProfile
@@ -52014,6 +52154,19 @@ var DEFAULT_MEDIA_MIME_TYPES = new Set(['image/jpeg', 'image/png', 'image/gif',
52014
52154
  var isDefaultSupportedMediaMimeType = function isDefaultSupportedMediaMimeType(mimeType) {
52015
52155
  return DEFAULT_MEDIA_MIME_TYPES.has(mimeType.toLowerCase());
52016
52156
  };
52157
+ var getClipboardFiles = function getClipboardFiles(clipboardData) {
52158
+ var files = Array.from(clipboardData.files || []);
52159
+ if (files.length) {
52160
+ return files;
52161
+ }
52162
+ return Array.from(clipboardData.items || []).filter(function (item) {
52163
+ return item.kind === 'file';
52164
+ }).map(function (item) {
52165
+ return item.getAsFile();
52166
+ }).filter(function (file) {
52167
+ return file !== null;
52168
+ });
52169
+ };
52017
52170
  var getMediaAttachmentValidationError = function getMediaAttachmentValidationError(file, _ref) {
52018
52171
  var _file$name$split$pop;
52019
52172
  var allowedExtensions = _ref.allowedExtensions,
@@ -52028,7 +52181,7 @@ var getMediaAttachmentValidationError = function getMediaAttachmentValidationErr
52028
52181
  });
52029
52182
  var extension = (_file$name$split$pop = file.name.split('.').pop()) === null || _file$name$split$pop === void 0 ? void 0 : _file$name$split$pop.toLowerCase();
52030
52183
  if (!extension || !supportedExtensions.includes(extension)) {
52031
- return invalidTypeMessage != null ? invalidTypeMessage : "Invalid file type. Allowed extensions are: " + supportedExtensions.join(', ') + ".";
52184
+ return invalidTypeMessage != null ? invalidTypeMessage : "Invalid file type.";
52032
52185
  }
52033
52186
  return null;
52034
52187
  };
@@ -52084,6 +52237,7 @@ var MessageList = function MessageList(_ref) {
52084
52237
  retractVoteIcon = _ref.retractVoteIcon,
52085
52238
  endVoteIcon = _ref.endVoteIcon,
52086
52239
  pinnedMessageIcon = _ref.pinnedMessageIcon,
52240
+ renderPinnedMessagePreview = _ref.renderPinnedMessagePreview,
52087
52241
  _ref$allowEditDeleteI = _ref.allowEditDeleteIncomingMessage,
52088
52242
  allowEditDeleteIncomingMessage = _ref$allowEditDeleteI === void 0 ? true : _ref$allowEditDeleteI,
52089
52243
  starIcon = _ref.starIcon,
@@ -52559,7 +52713,8 @@ var MessageList = function MessageList(_ref) {
52559
52713
  border: dateDividerBorder,
52560
52714
  backgroundColor: dateDividerBackgroundColor,
52561
52715
  borderRadius: dateDividerBorderRadius,
52562
- setLastVisibleMessageId: setLastVisibleMessageId
52716
+ setLastVisibleMessageId: setLastVisibleMessageId,
52717
+ renderPinnedMessagePreview: renderPinnedMessagePreview
52563
52718
  });
52564
52719
  }
52565
52720
  return /*#__PURE__*/React__default.createElement(MessageWrapper, {
@@ -52607,13 +52762,13 @@ var MessageList = function MessageList(_ref) {
52607
52762
  MessageActionsMenu: MessageActionsMenu,
52608
52763
  CustomMessageItem: CustomMessageItem,
52609
52764
  messageReaction: messageReaction,
52610
- editMessage: editMessage,
52765
+ editMessage: isPinnedMessagesList ? false : editMessage,
52611
52766
  copyMessage: copyMessage,
52612
- replyMessage: replyMessage,
52613
- replyMessageInThread: replyMessageInThread,
52767
+ replyMessage: isPinnedMessagesList ? false : replyMessage,
52768
+ replyMessageInThread: isPinnedMessagesList ? false : replyMessageInThread,
52614
52769
  deleteMessage: deleteMessage,
52615
52770
  selectMessage: selectMessage,
52616
- showInfoMessage: showInfoMessage,
52771
+ showInfoMessage: isPinnedMessagesList ? false : showInfoMessage,
52617
52772
  allowEditDeleteIncomingMessage: allowEditDeleteIncomingMessage,
52618
52773
  reportMessage: reportMessage,
52619
52774
  reactionIcon: reactionIcon,
@@ -52746,7 +52901,8 @@ var MessageList = function MessageList(_ref) {
52746
52901
  }, /*#__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, {
52747
52902
  channelId: channel.id,
52748
52903
  pinIcon: pinnedMessageIcon,
52749
- onOpenList: openPinnedMessagesList
52904
+ onOpenList: openPinnedMessagesList,
52905
+ renderPinnedMessagePreview: renderPinnedMessagePreview
52750
52906
  })), /*#__PURE__*/React__default.createElement(ScrollViewport, null, isJumpingToItem && (/*#__PURE__*/React__default.createElement(JumpOverlay, null, /*#__PURE__*/React__default.createElement(JumpSpinner, {
52751
52907
  "$color": iconInactive
52752
52908
  }))), /*#__PURE__*/React__default.createElement(Container$j, {
@@ -52873,7 +53029,7 @@ var MessageList = function MessageList(_ref) {
52873
53029
  isUnreadMessage: false,
52874
53030
  nextMessageStartsUnreadSection: false,
52875
53031
  isHighlighted: false,
52876
- ifLatestAndHasNotPreview: false,
53032
+ ifLatestAndHasNotPreview: index === 0,
52877
53033
  registerInMessagesIndex: false,
52878
53034
  isPinnedMessagesList: true
52879
53035
  });
@@ -53001,6 +53157,7 @@ var MessagesContainer = function MessagesContainer(_ref) {
53001
53157
  retractVoteIcon = _ref.retractVoteIcon,
53002
53158
  endVoteIcon = _ref.endVoteIcon,
53003
53159
  pinnedMessageIcon = _ref.pinnedMessageIcon,
53160
+ renderPinnedMessagePreview = _ref.renderPinnedMessagePreview,
53004
53161
  reactionIconOrder = _ref.reactionIconOrder,
53005
53162
  openFrequentlyUsedReactions = _ref.openFrequentlyUsedReactions,
53006
53163
  fixEmojiCategoriesTitleOnTop = _ref.fixEmojiCategoriesTitleOnTop,
@@ -53168,6 +53325,7 @@ var MessagesContainer = function MessagesContainer(_ref) {
53168
53325
  retractVoteIcon: retractVoteIcon,
53169
53326
  endVoteIcon: endVoteIcon,
53170
53327
  pinnedMessageIcon: pinnedMessageIcon,
53328
+ renderPinnedMessagePreview: renderPinnedMessagePreview,
53171
53329
  reactionIconOrder: reactionIconOrder,
53172
53330
  openFrequentlyUsedReactions: openFrequentlyUsedReactions,
53173
53331
  fixEmojiCategoriesTitleOnTop: fixEmojiCategoriesTitleOnTop,
@@ -54790,7 +54948,9 @@ function EmojisPopup$1(_ref2) {
54790
54948
  textSecondary = _useColor[THEME_COLORS.TEXT_SECONDARY],
54791
54949
  textFootnote = _useColor[THEME_COLORS.TEXT_FOOTNOTE],
54792
54950
  border = _useColor[THEME_COLORS.BORDER],
54793
- scrollbarThumbColor = _useColor[THEME_COLORS.SURFACE_2];
54951
+ scrollbarThumbColor = _useColor[THEME_COLORS.SURFACE_2],
54952
+ background = _useColor[THEME_COLORS.BACKGROUND];
54953
+ var theme = useSelector(themeSelector);
54794
54954
  var richTextEditor;
54795
54955
  try {
54796
54956
  var _useLexicalComposerCo = useLexicalComposerContext(),
@@ -54869,6 +55029,7 @@ function EmojisPopup$1(_ref2) {
54869
55029
  }
54870
55030
  }, 300);
54871
55031
  }, []);
55032
+ console.log(theme, theme === 'dark' ? background : scrollbarThumbColor);
54872
55033
  return /*#__PURE__*/React__default.createElement(Container$k, {
54873
55034
  backgroundColor: backgroundSections,
54874
55035
  borderColor: border,
@@ -54901,7 +55062,7 @@ function EmojisPopup$1(_ref2) {
54901
55062
  }, getEmojisCategoryTitle(activeCollection))), /*#__PURE__*/React__default.createElement(EmojiSection$1, {
54902
55063
  ref: emojiContainerRef,
54903
55064
  onScroll: handleEmojiListScroll,
54904
- scrollbarThumbColor: scrollbarThumbColor
55065
+ scrollbarThumbColor: theme === 'dark' ? background : scrollbarThumbColor
54905
55066
  }, /*#__PURE__*/React__default.createElement(AllEmojis$1, null, EMOJIS.map(function (emojiBigCollection, bigColIndex) {
54906
55067
  var mainCollectionKey = emojiBigCollection.key;
54907
55068
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, {
@@ -54993,25 +55154,13 @@ var Emoji$1 = styled.li(_templateObject8$m || (_templateObject8$m = _taggedTempl
54993
55154
  return props.hoverBackgroundColor;
54994
55155
  });
54995
55156
 
54996
- var waitForImageAttachmentPreparation = function waitForImageAttachmentPreparation(attachments, preparations) {
54997
- try {
54998
- return Promise.resolve(Promise.all(attachments.filter(function (attachment) {
54999
- return attachment.type === attachmentTypes.image;
55000
- }).map(function (attachment) {
55001
- return attachment.tid ? preparations.get(attachment.tid) : undefined;
55002
- }))).then(function () {});
55003
- } catch (e) {
55004
- return Promise.reject(e);
55005
- }
55006
- };
55007
55157
  var mergePreparedAttachmentPatches = function mergePreparedAttachmentPatches(attachments, patches) {
55008
55158
  return attachments.map(function (attachment) {
55009
55159
  return _extends({}, attachment, attachment.tid ? patches.get(attachment.tid) : undefined);
55010
55160
  });
55011
55161
  };
55012
55162
  var getOutgoingAttachmentType = function getOutgoingAttachmentType(attachment) {
55013
- var _attachment$data, _attachment$data$type;
55014
- 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;
55163
+ return attachment.type;
55015
55164
  };
55016
55165
 
55017
55166
  var CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined';
@@ -55302,6 +55451,9 @@ var AudioRecord = function AudioRecord(_ref) {
55302
55451
  var recordButtonRef = useRef(null);
55303
55452
  var audioElements = useRef({});
55304
55453
  var intervalRef = useRef({});
55454
+ var isStoppingRef = useRef(false);
55455
+ var isStartingRef = useRef(false);
55456
+ var isRecordingRef = useRef(false);
55305
55457
  var currentRecordedFile = useMemo(function () {
55306
55458
  var current = getAudioRecordingFromMap(currentChannelId) || recordedFile;
55307
55459
  return current;
@@ -55379,17 +55531,13 @@ var AudioRecord = function AudioRecord(_ref) {
55379
55531
  setPlayAudio(false);
55380
55532
  clearInterval(intervalRef.current[id]);
55381
55533
  });
55382
- audio.addEventListener('error', function () {
55383
- var _audio$error;
55384
- log.error('Audio playback error:', (_audio$error = audio.error) === null || _audio$error === void 0 ? void 0 : _audio$error.message);
55385
- });
55386
55534
  audio.src = fileData.objectUrl;
55387
55535
  };
55388
55536
  var startRecording = function startRecording(cId) {
55389
55537
  try {
55390
55538
  var id = cId || currentChannelId;
55391
55539
  try {
55392
- if (recording) {
55540
+ if (recording || isRecordingRef.current) {
55393
55541
  stopRecording(true, id, false, recorder);
55394
55542
  } else if (currentRecordedFile) {
55395
55543
  if (!currentRecordedFile.dur) {
@@ -55405,8 +55553,16 @@ var AudioRecord = function AudioRecord(_ref) {
55405
55553
  dispatch(setChannelDraftMessageIsRemovedAC(id));
55406
55554
  sendRecordedFile(currentRecordedFile, id);
55407
55555
  } else {
55408
- if (!recorder) return Promise.resolve();
55556
+ if (!recorder) {
55557
+ return Promise.resolve();
55558
+ }
55559
+ if (isStartingRef.current) {
55560
+ return Promise.resolve();
55561
+ }
55562
+ isStartingRef.current = true;
55409
55563
  recorder.start().then(function () {
55564
+ isStartingRef.current = false;
55565
+ isRecordingRef.current = true;
55410
55566
  handleStartRecording();
55411
55567
  setAudioRecordingToMap(id, {
55412
55568
  file: null,
@@ -55495,17 +55651,19 @@ var AudioRecord = function AudioRecord(_ref) {
55495
55651
  };
55496
55652
  soundAllowed(stream);
55497
55653
  })["catch"](function (e) {
55654
+ isStartingRef.current = false;
55655
+ isRecordingRef.current = false;
55498
55656
  if ((e === null || e === void 0 ? void 0 : e.name) === 'NotAllowedError' || (e === null || e === void 0 ? void 0 : e.name) === 'PermissionDeniedError') {
55499
55657
  setMicrophonePermissionDenied(true);
55500
55658
  }
55501
- log.error(e);
55502
55659
  });
55503
55660
  }
55504
55661
  } catch (e) {
55662
+ isStartingRef.current = false;
55663
+ isRecordingRef.current = false;
55505
55664
  if ((e === null || e === void 0 ? void 0 : e.name) === 'NotAllowedError' || (e === null || e === void 0 ? void 0 : e.name) === 'PermissionDeniedError') {
55506
55665
  setMicrophonePermissionDenied(true);
55507
55666
  }
55508
- log.error(e);
55509
55667
  }
55510
55668
  return Promise.resolve();
55511
55669
  } catch (e) {
@@ -55513,7 +55671,12 @@ var AudioRecord = function AudioRecord(_ref) {
55513
55671
  }
55514
55672
  };
55515
55673
  var cancelRecording = useCallback(function () {
55674
+ if (isStoppingRef.current) {
55675
+ return;
55676
+ }
55516
55677
  handleStopRecording();
55678
+ isStartingRef.current = false;
55679
+ isRecordingRef.current = false;
55517
55680
  if (currentRecordedFile) {
55518
55681
  dispatch(setChannelDraftMessageIsRemovedAC(currentChannelId));
55519
55682
  if (currentRecordedFile.objectUrl && currentRecordedFile.objectUrl.startsWith('blob:')) {
@@ -55534,10 +55697,21 @@ var AudioRecord = function AudioRecord(_ref) {
55534
55697
  setShowRecording(false);
55535
55698
  }, [currentRecordedFile, currentChannelId, setShowRecording, setRecordedFile]);
55536
55699
  var stopRecording = useCallback(function (send, cId, draft, recorder) {
55700
+ var id = cId || channelId;
55701
+ if (isStoppingRef.current) {
55702
+ return;
55703
+ }
55704
+ if (!recorder) {
55705
+ return;
55706
+ }
55707
+ isStoppingRef.current = true;
55708
+ isStartingRef.current = false;
55709
+ isRecordingRef.current = false;
55537
55710
  handleStopRecording();
55538
55711
  shouldDraw = false;
55539
- var id = cId || channelId;
55540
- recorder === null || recorder === void 0 ? void 0 : recorder.stop().getMp3().then(function (_ref2) {
55712
+ Promise.resolve().then(function () {
55713
+ return recorder.stop().getMp3();
55714
+ }).then(function (_ref2) {
55541
55715
  var buffer = _ref2[0],
55542
55716
  blob = _ref2[1];
55543
55717
  var file = new File(buffer, 'record.mp3', {
@@ -55547,6 +55721,8 @@ var AudioRecord = function AudioRecord(_ref) {
55547
55721
  var audioContext = new (window.AudioContext || window.webkitAudioContext)();
55548
55722
  var reader = new FileReader();
55549
55723
  reader.onload = function (event) {
55724
+ var _event$target;
55725
+ var audioData = (_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.result;
55550
55726
  var closeDecodeContext = function closeDecodeContext() {
55551
55727
  if (audioContext.state !== 'closed') {
55552
55728
  audioContext.close()["catch"](function () {
@@ -55554,76 +55730,100 @@ var AudioRecord = function AudioRecord(_ref) {
55554
55730
  });
55555
55731
  }
55556
55732
  };
55557
- audioContext.decodeAudioData(event.target.result, function (audioBuffer) {
55733
+ var handleDecodeError = function handleDecodeError() {
55558
55734
  closeDecodeContext();
55559
- var numberOfSegments = 50;
55560
- var segmentSize = Math.floor(audioBuffer.length / numberOfSegments);
55561
- var waveform = [];
55562
- for (var i = 0; i < numberOfSegments; i++) {
55563
- var start = i * segmentSize;
55564
- var end = start + segmentSize;
55565
- var segment = audioBuffer.getChannelData(0).slice(start, end);
55566
- var maxAmplitude = 0;
55567
- for (var j = 0; j < segment.length; j++) {
55568
- var val = segment[j];
55569
- var absVal = val < 0 ? -val : val;
55570
- if (absVal > maxAmplitude) {
55571
- maxAmplitude = absVal;
55572
- }
55573
- }
55574
- waveform.push(Math.floor(maxAmplitude * 1000));
55575
- }
55576
55735
  setStartRecording(false);
55577
- var objectUrl = URL.createObjectURL(blob);
55578
- var durationInt = Math.round(audioBuffer.duration);
55579
- if (send) {
55580
- if (!durationInt) {
55581
- if (objectUrl.startsWith('blob:')) {
55582
- URL.revokeObjectURL(objectUrl);
55736
+ setShowRecording(false);
55737
+ removeAudioRecordingFromMap(id);
55738
+ dispatch(setChannelDraftMessageIsRemovedAC(id));
55739
+ isStoppingRef.current = false;
55740
+ };
55741
+ try {
55742
+ var decodeResult = audioContext.decodeAudioData(audioData, function (audioBuffer) {
55743
+ try {
55744
+ closeDecodeContext();
55745
+ var numberOfSegments = 50;
55746
+ var segmentSize = Math.floor(audioBuffer.length / numberOfSegments);
55747
+ var waveform = [];
55748
+ for (var i = 0; i < numberOfSegments; i++) {
55749
+ var start = i * segmentSize;
55750
+ var end = start + segmentSize;
55751
+ var segment = audioBuffer.getChannelData(0).slice(start, end);
55752
+ var maxAmplitude = 0;
55753
+ for (var j = 0; j < segment.length; j++) {
55754
+ var val = segment[j];
55755
+ var absVal = val < 0 ? -val : val;
55756
+ if (absVal > maxAmplitude) {
55757
+ maxAmplitude = absVal;
55758
+ }
55759
+ }
55760
+ waveform.push(Math.floor(maxAmplitude * 1000));
55583
55761
  }
55584
- setShowRecording(false);
55585
- removeAudioRecordingFromMap(id);
55586
- dispatch(setChannelDraftMessageIsRemovedAC(id));
55587
- return;
55588
- }
55589
- sendRecordedFile({
55590
- file: file,
55591
- objectUrl: objectUrl,
55592
- thumb: waveform,
55593
- dur: durationInt
55594
- }, id);
55595
- setShowRecording(false);
55596
- removeAudioRecordingFromMap(id);
55597
- dispatch(setChannelDraftMessageIsRemovedAC(id));
55598
- } else {
55599
- if (!draft) {
55600
- setRecordedFile({
55601
- file: file,
55602
- objectUrl: objectUrl,
55603
- thumb: waveform,
55604
- dur: durationInt
55605
- });
55606
- }
55607
- var audioRecording = {
55608
- file: file,
55609
- objectUrl: objectUrl,
55610
- thumb: waveform,
55611
- dur: durationInt
55612
- };
55613
- setAudioRecordingToMap(id, audioRecording);
55614
- if (draft) {
55615
- initAudioPlayback(draft, id, audioRecording);
55616
- }
55762
+ setStartRecording(false);
55763
+ var objectUrl = URL.createObjectURL(blob);
55764
+ var durationInt = Math.round(audioBuffer.duration);
55765
+ if (send) {
55766
+ if (!durationInt) {
55767
+ if (objectUrl.startsWith('blob:')) {
55768
+ URL.revokeObjectURL(objectUrl);
55769
+ }
55770
+ setShowRecording(false);
55771
+ removeAudioRecordingFromMap(id);
55772
+ dispatch(setChannelDraftMessageIsRemovedAC(id));
55773
+ isStoppingRef.current = false;
55774
+ return;
55775
+ }
55776
+ sendRecordedFile({
55777
+ file: file,
55778
+ objectUrl: objectUrl,
55779
+ thumb: waveform,
55780
+ dur: durationInt
55781
+ }, id);
55782
+ setShowRecording(false);
55783
+ removeAudioRecordingFromMap(id);
55784
+ dispatch(setChannelDraftMessageIsRemovedAC(id));
55785
+ } else {
55786
+ if (!draft) {
55787
+ setRecordedFile({
55788
+ file: file,
55789
+ objectUrl: objectUrl,
55790
+ thumb: waveform,
55791
+ dur: durationInt
55792
+ });
55793
+ }
55794
+ var audioRecording = {
55795
+ file: file,
55796
+ objectUrl: objectUrl,
55797
+ thumb: waveform,
55798
+ dur: durationInt
55799
+ };
55800
+ setAudioRecordingToMap(id, audioRecording);
55801
+ if (draft) {
55802
+ initAudioPlayback(draft, id, audioRecording);
55803
+ }
55804
+ }
55805
+ isStoppingRef.current = false;
55806
+ } catch (_unused) {}
55807
+ }, handleDecodeError);
55808
+ if (decodeResult && typeof decodeResult["catch"] === 'function') {
55809
+ decodeResult["catch"](function () {
55810
+ return undefined;
55811
+ });
55617
55812
  }
55618
- }, function (e) {
55619
- closeDecodeContext();
55620
- log.info('Error decoding audio data: ' + e.err);
55621
- });
55813
+ } catch (_unused2) {}
55814
+ };
55815
+ reader.onerror = function () {
55816
+ if (audioContext.state !== 'closed') {
55817
+ audioContext.close()["catch"](function () {
55818
+ return undefined;
55819
+ });
55820
+ }
55821
+ isStoppingRef.current = false;
55622
55822
  };
55623
55823
  reader.readAsArrayBuffer(blob);
55624
- })["catch"](function (e) {
55824
+ })["catch"](function () {
55825
+ isStoppingRef.current = false;
55625
55826
  handleStopRecording();
55626
- log.error(e);
55627
55827
  });
55628
55828
  }, [sendRecordedFile, setShowRecording, setAudioRecordingToMap, setRecordedFile, handleStopRecording, channelId]);
55629
55829
  var handlePlayPause = function handlePlayPause(cId) {
@@ -55640,8 +55840,7 @@ var AudioRecord = function AudioRecord(_ref) {
55640
55840
  setCurrentTimeSeconds(time);
55641
55841
  }
55642
55842
  }, 10);
55643
- audio.play()["catch"](function (e) {
55644
- log.error('Audio play failed:', e);
55843
+ audio.play()["catch"](function () {
55645
55844
  setPlayAudio(false);
55646
55845
  });
55647
55846
  } else {
@@ -55735,9 +55934,7 @@ var AudioRecord = function AudioRecord(_ref) {
55735
55934
  bitRate: 128
55736
55935
  });
55737
55936
  setRecorder(newRecorder);
55738
- } catch (e) {
55739
- log.error('Failed to init mic-recorder-to-mp3', e);
55740
- }
55937
+ } catch (_unused3) {}
55741
55938
  }
55742
55939
  } catch (e) {
55743
55940
  Promise.reject(e);
@@ -56394,6 +56591,52 @@ var SettingItem = styled.div(_templateObject9$k || (_templateObject9$k = _tagged
56394
56591
  return props.color;
56395
56592
  });
56396
56593
 
56594
+ var getDraftHandoff = function getDraftHandoff(_ref) {
56595
+ var channelId = _ref.channelId,
56596
+ nextChannelId = _ref.nextChannelId,
56597
+ text = _ref.text,
56598
+ mentionedUsers = _ref.mentionedUsers,
56599
+ messageForReply = _ref.messageForReply,
56600
+ editorState = _ref.editorState,
56601
+ bodyAttributes = _ref.bodyAttributes,
56602
+ attachments = _ref.attachments,
56603
+ viewOnce = _ref.viewOnce;
56604
+ if (!channelId || channelId === nextChannelId) {
56605
+ return null;
56606
+ }
56607
+ if (text.trim() || attachments.length) {
56608
+ return {
56609
+ channelId: channelId,
56610
+ draft: {
56611
+ text: text,
56612
+ mentionedUsers: mentionedUsers,
56613
+ messageForReply: messageForReply,
56614
+ editorState: editorState,
56615
+ bodyAttributes: bodyAttributes,
56616
+ attachments: attachments,
56617
+ viewOnce: viewOnce
56618
+ },
56619
+ persist: true
56620
+ };
56621
+ }
56622
+ if (messageForReply) {
56623
+ return {
56624
+ channelId: channelId,
56625
+ draft: {
56626
+ text: '',
56627
+ mentionedUsers: mentionedUsers,
56628
+ messageForReply: messageForReply,
56629
+ editorState: editorState,
56630
+ bodyAttributes: bodyAttributes,
56631
+ attachments: [],
56632
+ viewOnce: false
56633
+ },
56634
+ persist: false
56635
+ };
56636
+ }
56637
+ return null;
56638
+ };
56639
+
56397
56640
  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;
56398
56641
  function AutoFocusPlugin(_ref) {
56399
56642
  var messageForReply = _ref.messageForReply;
@@ -56458,8 +56701,9 @@ function ClearEditorPlugin(_ref2) {
56458
56701
  function onError(error) {
56459
56702
  log.error(error);
56460
56703
  }
56461
- var prevActiveChannelId;
56462
56704
  var attachmentsUpdate = [];
56705
+ var UNSUPPORTED_PASTED_FILE_MESSAGE = 'This file format is not supported.';
56706
+ var useComposerLayoutEffect = CAN_USE_DOM ? useLayoutEffect : useEffect;
56463
56707
  var SendMessageInput = function SendMessageInput(_ref3) {
56464
56708
  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;
56465
56709
  var handleAttachmentSelected = _ref3.handleAttachmentSelected,
@@ -56588,101 +56832,116 @@ var SendMessageInput = function SendMessageInput(_ref3) {
56588
56832
  var _useState = useState(false),
56589
56833
  showRecording = _useState[0],
56590
56834
  setShowRecording = _useState[1];
56835
+ var _useState2 = useState(0),
56836
+ setAudioRecordingRevision = _useState2[1];
56837
+ var handleShowRecording = useCallback(function (start) {
56838
+ setShowRecording(start);
56839
+ setAudioRecordingRevision(function (revision) {
56840
+ return revision + 1;
56841
+ });
56842
+ }, []);
56591
56843
  var _usePermissions = usePermissions(activeChannel.userRole),
56592
56844
  checkActionPermission = _usePermissions[0];
56593
- var _useState2 = useState(false),
56594
- listenerIsAdded = _useState2[0],
56595
- setListenerIsAdded = _useState2[1];
56596
- var _useState3 = useState(''),
56597
- messageText = _useState3[0],
56598
- setMessageText = _useState3[1];
56845
+ var _useState3 = useState(false),
56846
+ listenerIsAdded = _useState3[0],
56847
+ setListenerIsAdded = _useState3[1];
56599
56848
  var _useState4 = useState(''),
56600
- editMessageText = _useState4[0],
56601
- setEditMessageText = _useState4[1];
56602
- var _useState5 = useState(null),
56603
- restoredEditMessage = _useState5[0],
56604
- setRestoredEditMessage = _useState5[1];
56605
- var _useState6 = useState({}),
56606
- readyVideoAttachments = _useState6[0],
56607
- setReadyVideoAttachments = _useState6[1];
56608
- var _useState7 = useState(false),
56609
- showChooseAttachmentType = _useState7[0],
56610
- setShowChooseAttachmentType = _useState7[1];
56849
+ messageText = _useState4[0],
56850
+ setMessageText = _useState4[1];
56851
+ var _useState5 = useState(''),
56852
+ editMessageText = _useState5[0],
56853
+ setEditMessageText = _useState5[1];
56854
+ var _useState6 = useState(null),
56855
+ restoredEditMessage = _useState6[0],
56856
+ setRestoredEditMessage = _useState6[1];
56857
+ var _useState7 = useState({}),
56858
+ readyVideoAttachments = _useState7[0],
56859
+ setReadyVideoAttachments = _useState7[1];
56611
56860
  var _useState8 = useState(false),
56612
- isEmojisOpened = _useState8[0],
56613
- setIsEmojisOpened = _useState8[1];
56861
+ showChooseAttachmentType = _useState8[0],
56862
+ setShowChooseAttachmentType = _useState8[1];
56614
56863
  var _useState9 = useState(false),
56615
- emojisInRightSide = _useState9[0],
56616
- setEmojisInRightSide = _useState9[1];
56617
- var _useState0 = useState(0),
56618
- emojisPopupLeftPosition = _useState0[0],
56619
- setEmojisPopupLeftPosition = _useState0[1];
56864
+ isEmojisOpened = _useState9[0],
56865
+ setIsEmojisOpened = _useState9[1];
56866
+ var _useState0 = useState(false),
56867
+ emojisInRightSide = _useState0[0],
56868
+ setEmojisInRightSide = _useState0[1];
56620
56869
  var _useState1 = useState(0),
56621
- emojisPopupBottomPosition = _useState1[0],
56622
- setEmojisPopupBottomPosition = _useState1[1];
56623
- var _useState10 = useState(false),
56624
- addAttachmentsInRightSide = _useState10[0],
56625
- setAddAttachmentsInRightSide = _useState10[1];
56870
+ emojisPopupLeftPosition = _useState1[0],
56871
+ setEmojisPopupLeftPosition = _useState1[1];
56872
+ var _useState10 = useState(0),
56873
+ emojisPopupBottomPosition = _useState10[0],
56874
+ setEmojisPopupBottomPosition = _useState10[1];
56626
56875
  var _useState11 = useState(false),
56627
- showPoll = _useState11[0],
56628
- setShowPoll = _useState11[1];
56629
- var _useState12 = useState({
56876
+ addAttachmentsInRightSide = _useState11[0],
56877
+ setAddAttachmentsInRightSide = _useState11[1];
56878
+ var _useState12 = useState(false),
56879
+ showPoll = _useState12[0],
56880
+ setShowPoll = _useState12[1];
56881
+ var _useState13 = useState({
56630
56882
  clear: false
56631
56883
  }),
56632
- shouldClearEditor = _useState12[0],
56633
- setShouldClearEditor = _useState12[1];
56634
- var _useState13 = useState([]),
56635
- messageBodyAttributes = _useState13[0],
56636
- setMessageBodyAttributes = _useState13[1];
56884
+ shouldClearEditor = _useState13[0],
56885
+ setShouldClearEditor = _useState13[1];
56637
56886
  var _useState14 = useState([]),
56638
- mentionedUsers = _useState14[0],
56639
- setMentionedUsers = _useState14[1];
56640
- var _useState15 = useState(''),
56641
- browser = _useState15[0],
56642
- setBrowser = _useState15[1];
56643
- var _useState16 = useState(false),
56644
- mentionsIsOpen = _useState16[0],
56645
- setMentionsIsOpen = _useState16[1];
56646
- var _useState17 = useState(),
56647
- inputContainerHeight = _useState17[0],
56648
- setInputContainerHeight = _useState17[1];
56649
- var selectedText = useRef(null);
56887
+ messageBodyAttributes = _useState14[0],
56888
+ setMessageBodyAttributes = _useState14[1];
56889
+ var _useState15 = useState([]),
56890
+ mentionedUsers = _useState15[0],
56891
+ setMentionedUsers = _useState15[1];
56892
+ var _useState16 = useState(''),
56893
+ browser = _useState16[0],
56894
+ setBrowser = _useState16[1];
56895
+ var _useState17 = useState(false),
56896
+ mentionsIsOpen = _useState17[0],
56897
+ setMentionsIsOpen = _useState17[1];
56650
56898
  var _useState18 = useState(),
56651
- typingTimout = _useState18[0],
56652
- setTypingTimout = _useState18[1];
56899
+ inputContainerHeight = _useState18[0],
56900
+ setInputContainerHeight = _useState18[1];
56901
+ var selectedText = useRef(null);
56653
56902
  var _useState19 = useState(),
56654
- inTypingStateTimout = _useState19[0],
56655
- setInTypingStateTimout = _useState19[1];
56656
- var _useState20 = useState(false),
56657
- inTypingState = _useState20[0],
56658
- setInTypingState = _useState20[1];
56903
+ typingTimout = _useState19[0],
56904
+ setTypingTimout = _useState19[1];
56905
+ var _useState20 = useState(),
56906
+ inTypingStateTimout = _useState20[0],
56907
+ setInTypingStateTimout = _useState20[1];
56659
56908
  var _useState21 = useState(false),
56660
- sendMessageIsActive = _useState21[0],
56661
- setSendMessageIsActive = _useState21[1];
56662
- var _useState22 = useState([]),
56663
- attachments = _useState22[0],
56664
- setAttachments = _useState22[1];
56909
+ inTypingState = _useState21[0],
56910
+ setInTypingState = _useState21[1];
56911
+ var _useState22 = useState(false),
56912
+ sendMessageIsActive = _useState22[0],
56913
+ setSendMessageIsActive = _useState22[1];
56665
56914
  var _useState23 = useState(false),
56666
- forwardPopupOpen = _useState23[0],
56667
- setForwardPopupOpen = _useState23[1];
56668
- var _useState24 = useState(false),
56669
- deletePopupOpen = _useState24[0],
56670
- setDeletePopupOpen = _useState24[1];
56915
+ isSendMessageInFlight = _useState23[0],
56916
+ setIsSendMessageInFlight = _useState23[1];
56917
+ var _useState24 = useState([]),
56918
+ attachments = _useState24[0],
56919
+ setAttachments = _useState24[1];
56920
+ var attachmentsRef = useRef([]);
56671
56921
  var _useState25 = useState(false),
56672
- isIncomingMessage = _useState25[0],
56673
- setIsIncomingMessage = _useState25[1];
56674
- var _useState26 = useState('.jpg,.jpeg,.png,.gif,.mp4,.mov,.avi,.wmv,.flv,.webm,.jfif'),
56675
- mediaExtensions = _useState26[0],
56676
- setMediaExtensions = _useState26[1];
56677
- var _useState27 = useState(''),
56678
- uploadErrorMessage = _useState27[0],
56679
- setUploadErrorMessage = _useState27[1];
56680
- var _useState28 = useState(false),
56681
- viewOnce = _useState28[0],
56682
- setViewOnce = _useState28[1];
56683
- var _useState29 = useState(areDraftMessagesHydrated()),
56684
- draftsHydrated = _useState29[0],
56685
- setDraftsHydrated = _useState29[1];
56922
+ forwardPopupOpen = _useState25[0],
56923
+ setForwardPopupOpen = _useState25[1];
56924
+ var _useState26 = useState(false),
56925
+ deletePopupOpen = _useState26[0],
56926
+ setDeletePopupOpen = _useState26[1];
56927
+ var _useState27 = useState(false),
56928
+ isIncomingMessage = _useState27[0],
56929
+ setIsIncomingMessage = _useState27[1];
56930
+ var _useState28 = useState('.jpg,.jpeg,.png,.gif,.mp4,.mov,.avi,.wmv,.flv,.webm,.jfif'),
56931
+ mediaExtensions = _useState28[0],
56932
+ setMediaExtensions = _useState28[1];
56933
+ var _useState29 = useState(''),
56934
+ uploadErrorMessage = _useState29[0],
56935
+ setUploadErrorMessage = _useState29[1];
56936
+ var _useState30 = useState(false),
56937
+ viewOnce = _useState30[0],
56938
+ setViewOnce = _useState30[1];
56939
+ var _useState31 = useState(areDraftMessagesHydrated()),
56940
+ draftsHydrated = _useState31[0],
56941
+ setDraftsHydrated = _useState31[1];
56942
+ var _useState32 = useState(activeChannel.id || ''),
56943
+ composerChannelId = _useState32[0],
56944
+ setComposerChannelId = _useState32[1];
56686
56945
  var typingOrRecordingIndicator = useSelector(typingOrRecordingIndicatorArraySelector(activeChannel.id));
56687
56946
  var contactsMap = useSelector(contactsMapSelector);
56688
56947
  var connectionStatus = useSelector(connectionStatusSelector, shallowEqual);
@@ -56695,40 +56954,47 @@ var SendMessageInput = function SendMessageInput(_ref3) {
56695
56954
  var metadataDebounceRef = useRef(null);
56696
56955
  var attachmentPreparationPromisesRef = useRef(new Map());
56697
56956
  var preparedAttachmentPatchesRef = useRef(new Map());
56957
+ var isSendMessageInFlightRef = useRef(false);
56698
56958
  var sendMessageWrapperRef = useRef(null);
56699
56959
  var restoringDraftRef = useRef(false);
56700
56960
  var restoredDraftChannelIdRef = useRef(null);
56701
56961
  var isNavigatingChannelRef = useRef(false);
56702
- var _useState30 = useState(),
56703
- realEditorState = _useState30[0],
56704
- setRealEditorState = _useState30[1];
56705
- var _useState31 = useState(null),
56706
- floatingAnchorElem = _useState31[0],
56707
- setFloatingAnchorElem = _useState31[1];
56708
- var _useState32 = useState(false),
56709
- isSmallWidthViewport = _useState32[0],
56710
- setIsSmallWidthViewport = _useState32[1];
56711
- var _useState33 = useState(false),
56712
- isScrolling = _useState33[0],
56713
- setIsScrolling = _useState33[1];
56962
+ var releaseSendMessageLock = function releaseSendMessageLock() {
56963
+ Promise.resolve().then(function () {
56964
+ isSendMessageInFlightRef.current = false;
56965
+ setIsSendMessageInFlight(false);
56966
+ });
56967
+ };
56968
+ var _useState33 = useState(),
56969
+ realEditorState = _useState33[0],
56970
+ setRealEditorState = _useState33[1];
56714
56971
  var _useState34 = useState(null),
56715
- linkPreview = _useState34[0],
56716
- setLinkPreview = _useState34[1];
56717
- var _useState35 = useState(null),
56718
- detectedUrl = _useState35[0],
56719
- setDetectedUrl = _useState35[1];
56720
- var _useState36 = useState(new Set()),
56721
- dismissedUrls = _useState36[0],
56722
- setDismissedUrls = _useState36[1];
56723
- var _useState37 = useState(false),
56724
- isClosingPreview = _useState37[0],
56725
- setIsClosingPreview = _useState37[1];
56726
- var _useState38 = useState(false),
56727
- replyLinkPreviewImageFailed = _useState38[0],
56728
- setReplyLinkPreviewImageFailed = _useState38[1];
56729
- var _useState39 = useState(false),
56730
- linkPreviewImageFailed = _useState39[0],
56731
- setLinkPreviewImageFailed = _useState39[1];
56972
+ floatingAnchorElem = _useState34[0],
56973
+ setFloatingAnchorElem = _useState34[1];
56974
+ var _useState35 = useState(false),
56975
+ isSmallWidthViewport = _useState35[0],
56976
+ setIsSmallWidthViewport = _useState35[1];
56977
+ var _useState36 = useState(false),
56978
+ isScrolling = _useState36[0],
56979
+ setIsScrolling = _useState36[1];
56980
+ var _useState37 = useState(null),
56981
+ linkPreview = _useState37[0],
56982
+ setLinkPreview = _useState37[1];
56983
+ var _useState38 = useState(null),
56984
+ detectedUrl = _useState38[0],
56985
+ setDetectedUrl = _useState38[1];
56986
+ var _useState39 = useState(new Set()),
56987
+ dismissedUrls = _useState39[0],
56988
+ setDismissedUrls = _useState39[1];
56989
+ var _useState40 = useState(false),
56990
+ isClosingPreview = _useState40[0],
56991
+ setIsClosingPreview = _useState40[1];
56992
+ var _useState41 = useState(false),
56993
+ replyLinkPreviewImageFailed = _useState41[0],
56994
+ setReplyLinkPreviewImageFailed = _useState41[1];
56995
+ var _useState42 = useState(false),
56996
+ linkPreviewImageFailed = _useState42[0],
56997
+ setLinkPreviewImageFailed = _useState42[1];
56732
56998
  var addAttachmentByMenu = showChooseFileAttachment && showChooseMediaAttachment;
56733
56999
  var linkify = new LinkifyIt();
56734
57000
  var oGMetadata = useSelector(function (state) {
@@ -56739,8 +57005,52 @@ var SendMessageInput = function SendMessageInput(_ref3) {
56739
57005
  return setDraftsHydrated(areDraftMessagesHydrated());
56740
57006
  });
56741
57007
  }, []);
57008
+ useComposerLayoutEffect(function () {
57009
+ var nextChannelId = activeChannel.id || '';
57010
+ if (composerChannelId === nextChannelId) {
57011
+ return;
57012
+ }
57013
+ if (draftsHydrated) {
57014
+ var handoff = getDraftHandoff({
57015
+ channelId: composerChannelId,
57016
+ nextChannelId: nextChannelId,
57017
+ text: messageText,
57018
+ mentionedUsers: mentionedUsers,
57019
+ messageForReply: messageForReply,
57020
+ editorState: realEditorState,
57021
+ bodyAttributes: messageBodyAttributes,
57022
+ attachments: attachments,
57023
+ viewOnce: viewOnce
57024
+ });
57025
+ if (handoff) {
57026
+ setDraftMessageToMap(handoff.channelId, handoff.draft, {
57027
+ persist: handoff.persist
57028
+ });
57029
+ }
57030
+ }
57031
+ restoringDraftRef.current = false;
57032
+ restoredDraftChannelIdRef.current = null;
57033
+ isNavigatingChannelRef.current = !!messageForReply;
57034
+ setComposerChannelId(nextChannelId);
57035
+ setMessageText('');
57036
+ setEditMessageText('');
57037
+ setRestoredEditMessage(null);
57038
+ setMessageBodyAttributes([]);
57039
+ setMentionedUsers([]);
57040
+ setAttachments([]);
57041
+ attachmentsRef.current = [];
57042
+ setViewOnce(false);
57043
+ setSendMessageIsActive(false);
57044
+ setShouldClearEditor({
57045
+ clear: true
57046
+ });
57047
+ attachmentsUpdate = [];
57048
+ clearTimeout(typingTimout);
57049
+ dispatch(setMessageForReplyAC(null));
57050
+ dispatch(setMessageToEditAC(null));
57051
+ }, [activeChannel.id, composerChannelId]);
56742
57052
  useEffect(function () {
56743
- if (!draftsHydrated || !activeChannel.id) {
57053
+ if (!draftsHydrated || !activeChannel.id || composerChannelId !== activeChannel.id) {
56744
57054
  return;
56745
57055
  }
56746
57056
  var draftMessage = getDraftMessageFromMap(activeChannel.id);
@@ -56767,6 +57077,7 @@ var SendMessageInput = function SendMessageInput(_ref3) {
56767
57077
  setMessageText(draftMessage.text || '');
56768
57078
  setMentionedUsers(draftMessage.mentionedUsers || []);
56769
57079
  setAttachments(draftMessage.attachments || []);
57080
+ attachmentsRef.current = draftMessage.attachments || [];
56770
57081
  setViewOnce(!!draftMessage.viewOnce);
56771
57082
  if (draftMessage.messageForReply) dispatch(setMessageForReplyAC(draftMessage.messageForReply));
56772
57083
  setShouldClearEditor({
@@ -56774,7 +57085,27 @@ var SendMessageInput = function SendMessageInput(_ref3) {
56774
57085
  draftMessage: draftMessage
56775
57086
  });
56776
57087
  restoredDraftChannelIdRef.current = activeChannel.id;
56777
- }, [draftsHydrated, activeChannel.id]);
57088
+ }, [draftsHydrated, activeChannel.id, composerChannelId]);
57089
+ var setComposerMessageText = useCallback(function (text) {
57090
+ if (composerChannelId === activeChannel.id) {
57091
+ setMessageText(text);
57092
+ }
57093
+ }, [activeChannel.id, composerChannelId]);
57094
+ var setComposerEditMessageText = useCallback(function (text) {
57095
+ if (composerChannelId === activeChannel.id) {
57096
+ setEditMessageText(text);
57097
+ }
57098
+ }, [activeChannel.id, composerChannelId]);
57099
+ var setComposerMessageBodyAttributes = useCallback(function (attributes) {
57100
+ if (composerChannelId === activeChannel.id) {
57101
+ setMessageBodyAttributes(attributes);
57102
+ }
57103
+ }, [activeChannel.id, composerChannelId]);
57104
+ var setComposerMentionedUsers = useCallback(function (users) {
57105
+ if (composerChannelId === activeChannel.id) {
57106
+ setMentionedUsers(users);
57107
+ }
57108
+ }, [activeChannel.id, composerChannelId]);
56778
57109
  useEffect(function () {
56779
57110
  setReplyLinkPreviewImageFailed(false);
56780
57111
  }, [messageForReply === null || messageForReply === void 0 ? void 0 : messageForReply.id, messageForReply === null || messageForReply === void 0 ? void 0 : messageForReply.tid]);
@@ -56923,187 +57254,178 @@ var SendMessageInput = function SendMessageInput(_ref3) {
56923
57254
  var isEnter = (code === 'Enter' || code === 'NumpadEnter') && shiftKey === false;
56924
57255
  var isPoll = Boolean(pollDetails && pollDetails.options.length > 0 && pollDetails.name.trim());
56925
57256
  var messageTextForSend = isPoll ? pollDetails === null || pollDetails === void 0 ? void 0 : pollDetails.name.trim() : messageText.trim();
56926
- var shouldSend = (isEnter || type === 'click') && (messageToEdit || messageTextForSend || attachments.length && attachments.length > 0);
57257
+ var composerAttachments = attachmentsRef.current;
57258
+ var shouldSend = (isEnter || type === 'click') && (messageToEdit || messageTextForSend || composerAttachments.length && composerAttachments.length > 0);
56927
57259
  if (isEnter) {
56928
57260
  event.preventDefault();
56929
- if (!(messageTextForSend !== null && messageTextForSend !== void 0 && messageTextForSend.trim()) && !attachments.length && !messageToEdit) {
57261
+ if (!(messageTextForSend !== null && messageTextForSend !== void 0 && messageTextForSend.trim()) && !composerAttachments.length && !messageToEdit) {
56930
57262
  setShouldClearEditor({
56931
57263
  clear: true
56932
57264
  });
56933
57265
  }
56934
57266
  }
56935
- var _temp6 = function () {
56936
- if (shouldSend && !mentionsIsOpen) {
56937
- var _temp5 = function _temp5() {
56938
- setAttachments([]);
56939
- attachmentsUpdate = [];
56940
- removeDraftMessageFromMap(activeChannel.id);
56941
- dispatch(setChannelDraftMessageIsRemovedAC(activeChannel.id));
56942
- setViewOnce(false);
56943
- handleCloseReply();
56944
- setShouldClearEditor({
56945
- clear: true
56946
- });
56947
- setMentionedUsers([]);
56948
- setMessageBodyAttributes([]);
56949
- closePreviewWithAnimation(function () {
56950
- setDetectedUrl(null);
56951
- setDismissedUrls(new Set());
56952
- });
56953
- dispatch(setCloseSearchChannelsAC(true));
56954
- };
57267
+ if (shouldSend && !mentionsIsOpen) {
57268
+ if (isSendMessageInFlightRef.current) {
56955
57269
  event.preventDefault();
56956
57270
  event.stopPropagation();
56957
- var _temp4 = function () {
56958
- if (messageToEdit) {
56959
- handleEditMessage();
56960
- } else {
56961
- var _temp7 = function () {
56962
- if (messageTextForSend !== null && messageTextForSend !== void 0 && messageTextForSend.trim() || attachments.length && attachments.length > 0) {
56963
- var _temp2 = function _temp2() {
56964
- setMessageText('');
56965
- fileUploader.current.value = '';
56966
- if (inTypingState) {
56967
- handleSendTypingState(false);
56968
- }
56969
- clearTimeout(typingTimout);
56970
- setTypingTimout(undefined);
56971
- };
56972
- var _trimMessageBodyWithA = trimMessageBodyWithAttributes(messageText, messageBodyAttributes),
56973
- messageTexToSend = _trimMessageBodyWithA.body,
56974
- adjustedBodyAttributes = _trimMessageBodyWithA.bodyAttributes;
56975
- var messageToSend = {
56976
- body: messageTexToSend,
56977
- bodyAttributes: adjustedBodyAttributes,
56978
- mentionedUsers: [],
56979
- attachments: [],
56980
- type: 'text'
56981
- };
56982
- var mentionUsersToSend = [];
56983
- if (adjustedBodyAttributes && adjustedBodyAttributes.length) {
56984
- adjustedBodyAttributes.forEach(function (att) {
56985
- if (att.type === 'mention') {
56986
- var mentionsToFind = [].concat(mentionedUsers);
56987
- var draftMessage = getDraftMessageFromMap(activeChannel.id);
56988
- if (draftMessage) {
56989
- mentionsToFind = [].concat(draftMessage.mentionedUsers, mentionedUsers);
56990
- }
56991
- var mentionToAdd = mentionsToFind.find(function (mention) {
56992
- return mention.id === att.metadata;
56993
- });
56994
- mentionUsersToSend.push(mentionToAdd || {
56995
- id: att.metadata
56996
- });
56997
- }
56998
- });
56999
- }
57000
- messageToSend.mentionedUsers = mentionUsersToSend;
57001
- if (messageForReply) {
57002
- messageToSend.parentMessage = messageForReply;
57003
- }
57004
- var linkAttachment;
57005
- if (messageTexToSend) {
57006
- var _LinkifyIt$match;
57007
- var protocolMatch = /https?:\/\/\S+/.exec(messageTexToSend);
57008
- var linkifyMatchResult = !protocolMatch ? (_LinkifyIt$match = new LinkifyIt().match(messageTexToSend)) === null || _LinkifyIt$match === void 0 ? void 0 : _LinkifyIt$match[0] : null;
57009
- var url = protocolMatch ? protocolMatch[0] : linkifyMatchResult ? linkifyMatchResult.schema === '' ? linkifyMatchResult.url.replace(/^http:\/\//, 'https://') : linkifyMatchResult.url : null;
57010
- if (url) {
57011
- var urlMetadata = oGMetadata === null || oGMetadata === void 0 ? void 0 : oGMetadata[url];
57012
- var metadata = {};
57013
- if (urlMetadata) {
57014
- var _urlMetadata$og, _urlMetadata$og$favic, _urlMetadata$og2, _urlMetadata$og$descr, _urlMetadata$og3, _urlMetadata$og3$imag, _urlMetadata$og3$imag2, _urlMetadata$og4, _urlMetadata$og$title;
57015
- if (urlMetadata.imageWidth) metadata.szw = urlMetadata.imageWidth;
57016
- if (urlMetadata.imageHeight) metadata.szh = urlMetadata.imageHeight;
57017
- 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;
57018
- 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);
57019
- 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;
57020
- 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);
57021
- }
57022
- if (dismissedUrls.has(url)) {
57023
- metadata.hld = true;
57024
- }
57025
- linkAttachment = _extends({
57026
- type: attachmentTypes.link,
57027
- data: url,
57028
- upload: false
57029
- }, Object.keys(metadata).length > 0 ? {
57030
- metadata: metadata,
57031
- name: metadata.ttl
57032
- } : {
57033
- metadata: {
57034
- hld: true
57035
- }
57036
- });
57037
- }
57038
- }
57039
- if (hasSendableTextOrPoll(messageTexToSend, isPoll) && !attachments.length) {
57040
- if (linkAttachment) {
57041
- messageToSend.attachments = [linkAttachment];
57042
- }
57043
- if (isPoll) {
57044
- messageToSend.pollDetails = pollDetails;
57045
- messageToSend.type = 'poll';
57046
- messageToSend.body = messageTextForSend === null || messageTextForSend === void 0 ? void 0 : messageTextForSend.trim();
57047
- }
57048
- dispatch(sendTextMessageAC(messageToSend, activeChannel.id, connectionStatus));
57049
- }
57050
- var _temp = function () {
57051
- if (attachments.length) {
57052
- return Promise.resolve(waitForImageAttachmentPreparation(attachments, attachmentPreparationPromisesRef.current)).then(function () {
57053
- var sendAsSeparateMessage = getSendAttachmentsAsSeparateMessages();
57054
- messageToSend.attachments = mergePreparedAttachmentPatches(attachments, preparedAttachmentPatchesRef.current).map(function (preparedAttachment) {
57055
- return {
57056
- name: preparedAttachment.data.name,
57057
- data: preparedAttachment.data,
57058
- attachmentUrl: preparedAttachment.attachmentUrl,
57059
- tid: preparedAttachment.tid,
57060
- cachedUrl: preparedAttachment.cachedUrl,
57061
- upload: preparedAttachment.upload,
57062
- metadata: preparedAttachment.metadata,
57063
- type: getOutgoingAttachmentType(preparedAttachment),
57064
- size: preparedAttachment.size,
57065
- thumbnailState: preparedAttachment.thumbnailState
57066
- };
57067
- });
57068
- if (viewOnce && canShowViewOnceToggle) {
57069
- messageToSend.viewOnce = true;
57070
- }
57071
- var attachmentsToSent = [].concat(messageToSend.attachments);
57072
- if (linkAttachment && !messageToSend.viewOnce) {
57073
- attachmentsToSent.push(linkAttachment);
57074
- }
57075
- dispatch(sendMessageAC(_extends({}, messageToSend, {
57076
- attachments: attachmentsToSent
57077
- }), activeChannel.id, connectionStatus, sendAsSeparateMessage));
57078
- attachments.forEach(function (attachment) {
57079
- attachmentPreparationPromisesRef.current["delete"](attachment.tid);
57080
- preparedAttachmentPatchesRef.current["delete"](attachment.tid);
57081
- });
57082
- });
57083
- }
57084
- }();
57085
- return _temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp);
57271
+ return Promise.resolve();
57272
+ }
57273
+ isSendMessageInFlightRef.current = true;
57274
+ setIsSendMessageInFlight(true);
57275
+ event.preventDefault();
57276
+ event.stopPropagation();
57277
+ if (messageToEdit) {
57278
+ handleEditMessage();
57279
+ } else if (messageTextForSend !== null && messageTextForSend !== void 0 && messageTextForSend.trim() || composerAttachments.length && composerAttachments.length > 0) {
57280
+ var _trimMessageBodyWithA = trimMessageBodyWithAttributes(messageText, messageBodyAttributes),
57281
+ messageTexToSend = _trimMessageBodyWithA.body,
57282
+ adjustedBodyAttributes = _trimMessageBodyWithA.bodyAttributes;
57283
+ var messageToSend = {
57284
+ body: messageTexToSend,
57285
+ bodyAttributes: adjustedBodyAttributes,
57286
+ mentionedUsers: [],
57287
+ attachments: [],
57288
+ type: 'text'
57289
+ };
57290
+ var mentionUsersToSend = [];
57291
+ if (adjustedBodyAttributes && adjustedBodyAttributes.length) {
57292
+ adjustedBodyAttributes.forEach(function (att) {
57293
+ if (att.type === 'mention') {
57294
+ var mentionsToFind = [].concat(mentionedUsers);
57295
+ var draftMessage = getDraftMessageFromMap(activeChannel.id);
57296
+ if (draftMessage) {
57297
+ mentionsToFind = [].concat(draftMessage.mentionedUsers, mentionedUsers);
57086
57298
  }
57087
- }();
57088
- if (_temp7 && _temp7.then) return _temp7.then(function () {});
57299
+ var mentionToAdd = mentionsToFind.find(function (mention) {
57300
+ return mention.id === att.metadata;
57301
+ });
57302
+ mentionUsersToSend.push(mentionToAdd || {
57303
+ id: att.metadata
57304
+ });
57305
+ }
57306
+ });
57307
+ }
57308
+ messageToSend.mentionedUsers = mentionUsersToSend;
57309
+ if (messageForReply) {
57310
+ messageToSend.parentMessage = messageForReply;
57311
+ }
57312
+ var linkAttachment;
57313
+ if (messageTexToSend) {
57314
+ var _LinkifyIt$match;
57315
+ var protocolMatch = /https?:\/\/\S+/.exec(messageTexToSend);
57316
+ var linkifyMatchResult = !protocolMatch ? (_LinkifyIt$match = new LinkifyIt().match(messageTexToSend)) === null || _LinkifyIt$match === void 0 ? void 0 : _LinkifyIt$match[0] : null;
57317
+ var url = protocolMatch ? protocolMatch[0] : linkifyMatchResult ? linkifyMatchResult.schema === '' ? linkifyMatchResult.url.replace(/^http:\/\//, 'https://') : linkifyMatchResult.url : null;
57318
+ if (url) {
57319
+ var urlMetadata = oGMetadata === null || oGMetadata === void 0 ? void 0 : oGMetadata[url];
57320
+ var metadata = {};
57321
+ if (urlMetadata) {
57322
+ var _urlMetadata$og, _urlMetadata$og$favic, _urlMetadata$og2, _urlMetadata$og$descr, _urlMetadata$og3, _urlMetadata$og3$imag, _urlMetadata$og3$imag2, _urlMetadata$og4, _urlMetadata$og$title;
57323
+ if (urlMetadata.imageWidth) metadata.szw = urlMetadata.imageWidth;
57324
+ if (urlMetadata.imageHeight) metadata.szh = urlMetadata.imageHeight;
57325
+ 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;
57326
+ 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);
57327
+ 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;
57328
+ 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);
57329
+ }
57330
+ if (dismissedUrls.has(url)) {
57331
+ metadata.hld = true;
57332
+ }
57333
+ linkAttachment = _extends({
57334
+ type: attachmentTypes.link,
57335
+ data: url,
57336
+ upload: false
57337
+ }, Object.keys(metadata).length > 0 ? {
57338
+ metadata: metadata,
57339
+ name: metadata.ttl
57340
+ } : {
57341
+ metadata: {
57342
+ hld: true
57343
+ }
57344
+ });
57089
57345
  }
57090
- }();
57091
- return _temp4 && _temp4.then ? _temp4.then(_temp5) : _temp5(_temp4);
57092
- } else {
57093
- if (typingTimout) {
57094
- if (!inTypingStateTimout) {
57095
- handleSendTypingState(true, code);
57346
+ }
57347
+ if (hasSendableTextOrPoll(messageTexToSend, isPoll) && !composerAttachments.length) {
57348
+ if (linkAttachment) {
57349
+ messageToSend.attachments = [linkAttachment];
57096
57350
  }
57097
- clearTimeout(typingTimout);
57098
- } else {
57351
+ if (isPoll) {
57352
+ messageToSend.pollDetails = pollDetails;
57353
+ messageToSend.type = 'poll';
57354
+ messageToSend.body = messageTextForSend === null || messageTextForSend === void 0 ? void 0 : messageTextForSend.trim();
57355
+ }
57356
+ dispatch(sendTextMessageAC(messageToSend, activeChannel.id, connectionStatus));
57357
+ }
57358
+ if (composerAttachments.length) {
57359
+ var sendAsSeparateMessage = getSendAttachmentsAsSeparateMessages();
57360
+ messageToSend.attachments = mergePreparedAttachmentPatches(composerAttachments, preparedAttachmentPatchesRef.current).map(function (preparedAttachment) {
57361
+ return {
57362
+ name: preparedAttachment.data.name,
57363
+ data: preparedAttachment.data,
57364
+ attachmentUrl: preparedAttachment.attachmentUrl,
57365
+ tid: preparedAttachment.tid,
57366
+ cachedUrl: preparedAttachment.cachedUrl,
57367
+ upload: preparedAttachment.upload,
57368
+ metadata: preparedAttachment.metadata,
57369
+ type: getOutgoingAttachmentType(preparedAttachment),
57370
+ size: preparedAttachment.size,
57371
+ thumbnailState: preparedAttachment.thumbnailState
57372
+ };
57373
+ });
57374
+ if (viewOnce && canShowViewOnceToggle) {
57375
+ messageToSend.viewOnce = true;
57376
+ }
57377
+ var attachmentsToSent = [].concat(messageToSend.attachments);
57378
+ if (linkAttachment && !messageToSend.viewOnce) {
57379
+ attachmentsToSent.push(linkAttachment);
57380
+ }
57381
+ dispatch(sendMessageAC(_extends({}, messageToSend, {
57382
+ attachments: attachmentsToSent
57383
+ }), activeChannel.id, connectionStatus, sendAsSeparateMessage));
57384
+ composerAttachments.forEach(function (attachment) {
57385
+ attachmentPreparationPromisesRef.current["delete"](attachment.tid);
57386
+ preparedAttachmentPatchesRef.current["delete"](attachment.tid);
57387
+ });
57388
+ }
57389
+ setMessageText('');
57390
+ fileUploader.current.value = '';
57391
+ if (inTypingState) {
57392
+ handleSendTypingState(false);
57393
+ }
57394
+ clearTimeout(typingTimout);
57395
+ setTypingTimout(undefined);
57396
+ }
57397
+ setAttachments([]);
57398
+ attachmentsRef.current = [];
57399
+ attachmentsUpdate = [];
57400
+ removeDraftMessageFromMap(activeChannel.id);
57401
+ dispatch(setChannelDraftMessageIsRemovedAC(activeChannel.id));
57402
+ setViewOnce(false);
57403
+ handleCloseReply();
57404
+ setShouldClearEditor({
57405
+ clear: true
57406
+ });
57407
+ setMentionedUsers([]);
57408
+ setMessageBodyAttributes([]);
57409
+ closePreviewWithAnimation(function () {
57410
+ setDetectedUrl(null);
57411
+ setDismissedUrls(new Set());
57412
+ });
57413
+ dispatch(setCloseSearchChannelsAC(true));
57414
+ releaseSendMessageLock();
57415
+ } else {
57416
+ if (typingTimout) {
57417
+ if (!inTypingStateTimout) {
57099
57418
  handleSendTypingState(true, code);
57100
57419
  }
57101
- setTypingTimout(setTimeout(function () {
57102
- setTypingTimout(0);
57103
- }, 2000));
57420
+ clearTimeout(typingTimout);
57421
+ } else {
57422
+ handleSendTypingState(true, code);
57104
57423
  }
57105
- }();
57106
- return Promise.resolve(_temp6 && _temp6.then ? _temp6.then(function () {}) : void 0);
57424
+ setTypingTimout(setTimeout(function () {
57425
+ setTypingTimout(0);
57426
+ }, 2000));
57427
+ }
57428
+ return Promise.resolve();
57107
57429
  } catch (e) {
57108
57430
  return Promise.reject(e);
57109
57431
  }
@@ -57207,25 +57529,27 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57207
57529
  };
57208
57530
  var removeUpload = function removeUpload(attachmentId) {
57209
57531
  if (attachmentId) {
57210
- var updatedAttachments = attachmentsUpdate.filter(function (item) {
57532
+ var updatedAttachments = attachmentsRef.current.filter(function (item) {
57211
57533
  return item.tid !== attachmentId;
57212
57534
  });
57213
- clearVideoPreparation(attachmentId);
57535
+ clearAttachmentPreparation(attachmentId);
57214
57536
  attachmentPreparationPromisesRef.current["delete"](attachmentId);
57215
57537
  preparedAttachmentPatchesRef.current["delete"](attachmentId);
57216
57538
  releaseBlobUrls(["compose_" + attachmentId]);
57217
57539
  setAttachments(updatedAttachments);
57540
+ attachmentsRef.current = updatedAttachments;
57218
57541
  attachmentsUpdate = updatedAttachments;
57219
57542
  } else {
57220
- attachmentsUpdate.forEach(function (attachment) {
57221
- return clearVideoPreparation(attachment.tid);
57543
+ attachmentsRef.current.forEach(function (attachment) {
57544
+ return clearAttachmentPreparation(attachment.tid);
57222
57545
  });
57223
57546
  attachmentPreparationPromisesRef.current.clear();
57224
57547
  preparedAttachmentPatchesRef.current.clear();
57225
- releaseBlobUrls(attachmentsUpdate.map(function (item) {
57548
+ releaseBlobUrls(attachmentsRef.current.map(function (item) {
57226
57549
  return "compose_" + item.tid;
57227
57550
  }));
57228
57551
  setAttachments([]);
57552
+ attachmentsRef.current = [];
57229
57553
  attachmentsUpdate = [];
57230
57554
  }
57231
57555
  if (attachmentsUpdate.length === 0) {
@@ -57291,14 +57615,14 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57291
57615
  filesToProcess.forEach(function (file) {
57292
57616
  try {
57293
57617
  var validationError = isMediaAttachment ? validateMediaAttachment(file) : null;
57294
- var _temp8 = function () {
57618
+ var _temp = function () {
57295
57619
  if (!validationError) {
57296
57620
  return Promise.resolve(handleAddAttachmentWithViewOnceCheck(file, isMediaAttachment)).then(function () {});
57297
57621
  } else {
57298
57622
  showFileUploadError(validationError);
57299
57623
  }
57300
57624
  }();
57301
- return Promise.resolve(_temp8 && _temp8.then ? _temp8.then(function () {}) : void 0);
57625
+ return Promise.resolve(_temp && _temp.then ? _temp.then(function () {}) : void 0);
57302
57626
  } catch (e) {
57303
57627
  return Promise.reject(e);
57304
57628
  }
@@ -57320,9 +57644,9 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57320
57644
  }
57321
57645
  var os = detectOS();
57322
57646
  if (!(os === 'Windows' && browser === 'Firefox')) {
57323
- if (e.clipboardData.files && e.clipboardData.files.length > 0) {
57647
+ var fileList = getClipboardFiles(e.clipboardData);
57648
+ if (fileList.length > 0) {
57324
57649
  e.preventDefault();
57325
- var fileList = Object.values(e.clipboardData.files);
57326
57650
  var remainingSlots = MAX_ATTACHMENTS - attachments.length;
57327
57651
  if (remainingSlots <= 0) {
57328
57652
  showFileUploadError("You have reached the maximum limit of " + MAX_ATTACHMENTS + " files");
@@ -57335,15 +57659,23 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57335
57659
  }
57336
57660
  filesToProcess.forEach(function (file) {
57337
57661
  try {
57338
- var validationError = validateMediaAttachment(file);
57339
- var _temp9 = function () {
57340
- if (!validationError) {
57662
+ var mediaValidationError = validateMediaAttachment(file);
57663
+ var canAddAsMedia = showChooseMediaAttachment && !mediaValidationError;
57664
+ var _temp3 = function () {
57665
+ if (canAddAsMedia) {
57341
57666
  return Promise.resolve(handleAddAttachmentWithViewOnceCheck(file, true)).then(function () {});
57342
57667
  } else {
57343
- showFileUploadError(validationError);
57668
+ var _temp4 = function () {
57669
+ if (showChooseFileAttachment) {
57670
+ return Promise.resolve(handleAddAttachmentWithViewOnceCheck(file, false)).then(function () {});
57671
+ } else {
57672
+ showFileUploadError(mediaValidationError || allowedMediaExtensionsErrorMessage || UNSUPPORTED_PASTED_FILE_MESSAGE);
57673
+ }
57674
+ }();
57675
+ if (_temp4 && _temp4.then) return _temp4.then(function () {});
57344
57676
  }
57345
57677
  }();
57346
- return Promise.resolve(_temp9 && _temp9.then ? _temp9.then(function () {}) : void 0);
57678
+ return Promise.resolve(_temp3 && _temp3.then ? _temp3.then(function () {}) : void 0);
57347
57679
  } catch (e) {
57348
57680
  return Promise.reject(e);
57349
57681
  }
@@ -57418,9 +57750,11 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57418
57750
  dispatch(clearSelectedMessagesAC());
57419
57751
  };
57420
57752
  var handleSetMentionMember = function handleSetMentionMember(mentionMember) {
57421
- setMentionedUsers(function (prevState) {
57422
- return [].concat(prevState, [mentionMember]);
57423
- });
57753
+ if (composerChannelId === activeChannel.id) {
57754
+ setMentionedUsers(function (prevState) {
57755
+ return [].concat(prevState, [mentionMember]);
57756
+ });
57757
+ }
57424
57758
  };
57425
57759
  var createComposePreviewUrl = function createComposePreviewUrl(attachmentTid, blob) {
57426
57760
  var url = URL.createObjectURL(blob);
@@ -57445,10 +57779,10 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57445
57779
  setPendingAttachment(tid, {
57446
57780
  file: file
57447
57781
  });
57448
- if (fileType === 'video') {
57449
- beginVideoPreparation(tid, file);
57782
+ if (fileType === 'image' || fileType === 'video') {
57783
+ beginAttachmentPreparation(tid, file);
57450
57784
  }
57451
- var type = fileType === 'video' && (!customUploader || isMediaAttachment) ? 'video' : isMediaAttachment && fileType === 'image' ? 'image' : 'file';
57785
+ var type = isMediaAttachment && fileType === 'video' ? attachmentTypes.video : isMediaAttachment && fileType === 'image' ? attachmentTypes.image : attachmentTypes.file;
57452
57786
  var attachment = _extends({
57453
57787
  data: file,
57454
57788
  name: file.name,
@@ -57462,29 +57796,37 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57462
57796
  attachmentUrl: createComposePreviewUrl(tid, file),
57463
57797
  metadata: customUploader ? {} : '{}'
57464
57798
  } : {});
57465
- setAttachments(function (prevState) {
57466
- return [].concat(prevState, [attachment]);
57467
- });
57799
+ var nextAttachments = [].concat(attachmentsRef.current, [attachment]);
57800
+ attachmentsRef.current = nextAttachments;
57801
+ setAttachments(nextAttachments);
57468
57802
  var updateAttachment = function updateAttachment(patch) {
57469
57803
  preparedAttachmentPatchesRef.current.set(tid, _extends({}, preparedAttachmentPatchesRef.current.get(tid), patch));
57470
- setAttachments(function (prevState) {
57471
- return prevState.map(function (current) {
57472
- return current.tid === tid ? _extends({}, current, patch) : current;
57473
- });
57804
+ var nextAttachments = attachmentsRef.current.map(function (current) {
57805
+ return current.tid === tid ? _extends({}, current, patch) : current;
57474
57806
  });
57807
+ attachmentsRef.current = nextAttachments;
57808
+ setAttachments(nextAttachments);
57475
57809
  };
57476
57810
  var preparationPromise = new Promise(function (resolve) {
57477
57811
  return setTimeout(function () {
57478
57812
  try {
57479
57813
  return Promise.resolve(_finallyRethrows(function () {
57480
- var _temp16 = function () {
57814
+ var _temp12 = function () {
57481
57815
  if (fileType === 'image') {
57482
- var _temp10 = _catch(function () {
57816
+ var _temp8 = _catch(function () {
57483
57817
  return Promise.resolve(createImageThumbnail(file)).then(function (_ref5) {
57484
57818
  var thumbnail = _ref5.thumbnail,
57485
57819
  imageWidth = _ref5.imageWidth,
57486
57820
  imageHeight = _ref5.imageHeight;
57487
- var _temp1 = function () {
57821
+ function _temp7() {
57822
+ completeAttachmentPreparation(tid, {
57823
+ file: preparedFile,
57824
+ metadata: metadata
57825
+ });
57826
+ }
57827
+ var preparedFile = file;
57828
+ var metadata;
57829
+ var _temp6 = function () {
57488
57830
  if (customUploader) {
57489
57831
  return Promise.resolve(resizeImage(file)).then(function (resizedFile) {
57490
57832
  var patch = {
@@ -57495,11 +57837,25 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57495
57837
  tmb: thumbnail
57496
57838
  }
57497
57839
  };
57498
- updateAttachment(patch);
57840
+ if (isMediaAttachment && resizedFile !== null && resizedFile !== void 0 && resizedFile.blob) {
57841
+ preparedFile = new File([resizedFile.blob], resizedFile.file.name, {
57842
+ type: file.type
57843
+ });
57844
+ patch.size = preparedFile.size;
57845
+ updateAttachment(_extends({}, patch, {
57846
+ data: preparedFile
57847
+ }));
57848
+ setPendingAttachment(tid, {
57849
+ file: preparedFile
57850
+ });
57851
+ } else {
57852
+ updateAttachment(patch);
57853
+ }
57854
+ metadata = patch.metadata;
57499
57855
  handleAttachmentImageForCache(_extends({}, attachment, patch));
57500
57856
  });
57501
57857
  } else {
57502
- var _temp17 = function () {
57858
+ var _temp13 = function () {
57503
57859
  if (isMediaAttachment && file.type !== 'image/gif') {
57504
57860
  return Promise.resolve(resizeImage(file)).then(function (resizedFileData) {
57505
57861
  var resizedFile = resizedFileData.blob ? new File([resizedFileData.blob], resizedFileData.file.name, {
@@ -57519,30 +57875,34 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57519
57875
  file: resizedFile
57520
57876
  });
57521
57877
  handleAttachmentImageForCache(_extends({}, attachment, patch));
57878
+ preparedFile = resizedFile;
57879
+ metadata = patch.metadata;
57522
57880
  });
57523
57881
  } else {
57882
+ metadata = JSON.stringify({
57883
+ tmb: thumbnail,
57884
+ szw: imageWidth,
57885
+ szh: imageHeight
57886
+ });
57524
57887
  updateAttachment({
57525
- metadata: JSON.stringify({
57526
- tmb: thumbnail,
57527
- szw: imageWidth,
57528
- szh: imageHeight
57529
- })
57888
+ metadata: metadata
57530
57889
  });
57531
57890
  }
57532
57891
  }();
57533
- if (_temp17 && _temp17.then) return _temp17.then(function () {});
57892
+ if (_temp13 && _temp13.then) return _temp13.then(function () {});
57534
57893
  }
57535
57894
  }();
57536
- if (_temp1 && _temp1.then) return _temp1.then(function () {});
57895
+ return _temp6 && _temp6.then ? _temp6.then(_temp7) : _temp7(_temp6);
57537
57896
  });
57538
57897
  }, function (error) {
57539
57898
  log.warn('Unable to prepare image attachment preview:', error);
57899
+ failAttachmentPreparation(tid);
57540
57900
  });
57541
- if (_temp10 && _temp10.then) return _temp10.then(function () {});
57901
+ if (_temp8 && _temp8.then) return _temp8.then(function () {});
57542
57902
  } else {
57543
- var _temp18 = function () {
57903
+ var _temp14 = function () {
57544
57904
  if (fileType === 'video') {
57545
- var _temp14 = function _temp14() {
57905
+ var _temp10 = function _temp10() {
57546
57906
  return Promise.resolve(remuxPromise).then(function (uploadFile) {
57547
57907
  if (uploadFile !== file) {
57548
57908
  updateAttachment({
@@ -57555,13 +57915,13 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57555
57915
  }
57556
57916
  if (metadata) {
57557
57917
  var _frame;
57558
- completeVideoPreparation(tid, {
57918
+ completeAttachmentPreparation(tid, {
57559
57919
  file: uploadFile,
57560
57920
  metadata: metadata,
57561
57921
  videoPreviewBlob: (_frame = frame) === null || _frame === void 0 ? void 0 : _frame.blob
57562
57922
  });
57563
57923
  } else {
57564
- failVideoPreparation(tid);
57924
+ failAttachmentPreparation(tid);
57565
57925
  updateAttachment({
57566
57926
  thumbnailState: 'failed'
57567
57927
  });
@@ -57572,8 +57932,8 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57572
57932
  var thumbnailSource = file;
57573
57933
  var metadata;
57574
57934
  var frame;
57575
- var _temp13 = _catch(function () {
57576
- function _temp12() {
57935
+ var _temp1 = _catch(function () {
57936
+ function _temp0() {
57577
57937
  var _frame2 = frame,
57578
57938
  thumb = _frame2.thumb,
57579
57939
  width = _frame2.width,
@@ -57597,7 +57957,7 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57597
57957
  dispatch(setUpdateMessageAttachmentAC(thumb, frame.frameBlobUrl));
57598
57958
  setVideoIsReadyToSend(tid);
57599
57959
  }
57600
- var _temp11 = _catch(function () {
57960
+ var _temp9 = _catch(function () {
57601
57961
  return Promise.resolve(getFrame(thumbnailSource, 0)).then(function (_getFrame) {
57602
57962
  frame = _getFrame;
57603
57963
  });
@@ -57609,17 +57969,17 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57609
57969
  });
57610
57970
  });
57611
57971
  });
57612
- return _temp11 && _temp11.then ? _temp11.then(_temp12) : _temp12(_temp11);
57972
+ return _temp9 && _temp9.then ? _temp9.then(_temp0) : _temp0(_temp9);
57613
57973
  }, function (error) {
57614
57974
  log.warn('Unable to generate video thumbnail:', error);
57615
57975
  });
57616
- return _temp13 && _temp13.then ? _temp13.then(_temp14) : _temp14(_temp13);
57976
+ return _temp1 && _temp1.then ? _temp1.then(_temp10) : _temp10(_temp1);
57617
57977
  }
57618
57978
  }();
57619
- if (_temp18 && _temp18.then) return _temp18.then(function () {});
57979
+ if (_temp14 && _temp14.then) return _temp14.then(function () {});
57620
57980
  }
57621
57981
  }();
57622
- if (_temp16 && _temp16.then) return _temp16.then(function () {});
57982
+ if (_temp12 && _temp12.then) return _temp12.then(function () {});
57623
57983
  }, function (_wasThrown, _result) {
57624
57984
  resolve();
57625
57985
  if (_wasThrown) throw _result;
@@ -57630,7 +57990,7 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57630
57990
  }
57631
57991
  }, 0);
57632
57992
  });
57633
- if (fileType === 'image') {
57993
+ if (fileType === 'image' || fileType === 'video') {
57634
57994
  attachmentPreparationPromisesRef.current.set(tid, preparationPromise);
57635
57995
  }
57636
57996
  return Promise.resolve();
@@ -57677,14 +58037,14 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57677
58037
  filesToProcess.forEach(function (file) {
57678
58038
  try {
57679
58039
  var validationError = isMediaAttachment ? validateMediaAttachment(file) : null;
57680
- var _temp19 = function () {
58040
+ var _temp15 = function () {
57681
58041
  if (!validationError) {
57682
58042
  return Promise.resolve(handleAddAttachmentWithViewOnceCheck(file, isMediaAttachment)).then(function () {});
57683
58043
  } else {
57684
58044
  showFileUploadError(validationError);
57685
58045
  }
57686
58046
  }();
57687
- return Promise.resolve(_temp19 && _temp19.then ? _temp19.then(function () {}) : void 0);
58047
+ return Promise.resolve(_temp15 && _temp15.then ? _temp15.then(function () {}) : void 0);
57688
58048
  } catch (e) {
57689
58049
  return Promise.reject(e);
57690
58050
  }
@@ -57756,59 +58116,6 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57756
58116
  };
57757
58117
  }, [isSmallWidthViewport]);
57758
58118
  useEffect(function () {
57759
- if (prevActiveChannelId && activeChannel.id && prevActiveChannelId !== activeChannel.id) {
57760
- setMessageText('');
57761
- if (messageForReply) {
57762
- isNavigatingChannelRef.current = true;
57763
- handleCloseReply(true);
57764
- }
57765
- setAttachments([]);
57766
- attachmentsUpdate = [];
57767
- handleCloseEditMode(!!messageToEdit);
57768
- clearTimeout(typingTimout);
57769
- var draftMessage = getDraftMessageFromMap(activeChannel.id);
57770
- if (draftMessage) {
57771
- restoringDraftRef.current = true;
57772
- if (draftMessage.messageToEdit) {
57773
- var _ref6, _draftMessage$editMes2, _draftMessage$editBod2, _draftMessage$mention2;
57774
- var restoredText = (_ref6 = (_draftMessage$editMes2 = draftMessage.editMessageText) != null ? _draftMessage$editMes2 : draftMessage.messageToEdit.body) != null ? _ref6 : '';
57775
- var restoredEdit = _extends({}, draftMessage.messageToEdit, {
57776
- body: restoredText,
57777
- bodyAttributes: (_draftMessage$editBod2 = draftMessage.editBodyAttributes) != null ? _draftMessage$editBod2 : draftMessage.messageToEdit.bodyAttributes,
57778
- mentionedUsers: (_draftMessage$mention2 = draftMessage.mentionedUsers) != null ? _draftMessage$mention2 : draftMessage.messageToEdit.mentionedUsers
57779
- });
57780
- setEditMessageText(restoredText);
57781
- setMessageBodyAttributes(restoredEdit.bodyAttributes || []);
57782
- setMentionedUsers(restoredEdit.mentionedUsers || []);
57783
- setRestoredEditMessage(restoredEdit);
57784
- dispatch(setMessageToEditAC(draftMessage.messageToEdit));
57785
- restoredDraftChannelIdRef.current = activeChannel.id;
57786
- }
57787
- if (!draftMessage.messageToEdit) {
57788
- if (draftMessage.messageForReply) {
57789
- dispatch(setMessageForReplyAC(draftMessage.messageForReply));
57790
- }
57791
- setMessageText(draftMessage.text);
57792
- setMentionedUsers(draftMessage.mentionedUsers);
57793
- setAttachments(draftMessage.attachments || []);
57794
- setViewOnce(!!draftMessage.viewOnce);
57795
- restoredDraftChannelIdRef.current = activeChannel.id;
57796
- setShouldClearEditor({
57797
- clear: true,
57798
- draftMessage: draftMessage
57799
- });
57800
- }
57801
- } else {
57802
- setMentionedUsers([]);
57803
- setShouldClearEditor({
57804
- clear: true,
57805
- draftMessage: draftMessage
57806
- });
57807
- }
57808
- }
57809
- if (activeChannel.id) {
57810
- prevActiveChannelId = activeChannel.id;
57811
- }
57812
58119
  if (activeChannel.id && membersHasNext === undefined && !(activeChannel.type === DEFAULT_CHANNEL_TYPE.DIRECT && activeChannel.memberCount === 2)) {
57813
58120
  dispatch(getMembersAC(activeChannel.id));
57814
58121
  }
@@ -57817,6 +58124,9 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57817
58124
  if (!draftsHydrated) {
57818
58125
  return;
57819
58126
  }
58127
+ if (!activeChannel.id || composerChannelId !== activeChannel.id) {
58128
+ return;
58129
+ }
57820
58130
  if (restoringDraftRef.current) {
57821
58131
  restoringDraftRef.current = false;
57822
58132
  return;
@@ -57903,9 +58213,9 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57903
58213
  document.body.removeAttribute('onbeforeunload');
57904
58214
  }
57905
58215
  }
57906
- }, [messageText, attachments, editMessageText, readyVideoAttachments, messageBodyAttributes, messageToEdit, viewOnce, draftsHydrated]);
58216
+ }, [messageText, attachments, editMessageText, readyVideoAttachments, messageBodyAttributes, messageToEdit, viewOnce, draftsHydrated, activeChannel.id, composerChannelId]);
57907
58217
  useDidUpdate(function () {
57908
- if (!messageToEdit && mentionedUsers && mentionedUsers.length) {
58218
+ if (composerChannelId === activeChannel.id && !messageToEdit && mentionedUsers && mentionedUsers.length) {
57909
58219
  setDraftMessageToMap(activeChannel.id, {
57910
58220
  text: messageText,
57911
58221
  mentionedUsers: mentionedUsers,
@@ -57917,7 +58227,7 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57917
58227
  persist: !!(messageText.trim() || attachments.length)
57918
58228
  });
57919
58229
  }
57920
- }, [mentionedUsers]);
58230
+ }, [mentionedUsers, activeChannel.id, composerChannelId]);
57921
58231
  useDidUpdate(function () {
57922
58232
  var _getAudioRecordingFro;
57923
58233
  if (handleAttachmentSelected) {
@@ -57931,6 +58241,7 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57931
58241
  }
57932
58242
  }
57933
58243
  attachmentsUpdate = attachments;
58244
+ attachmentsRef.current = attachments;
57934
58245
  var hasAudioRecording = showRecording || ((_getAudioRecordingFro = getAudioRecordingFromMap(activeChannel === null || activeChannel === void 0 ? void 0 : activeChannel.id)) === null || _getAudioRecordingFro === void 0 ? void 0 : _getAudioRecordingFro.file);
57935
58246
  if (viewOnce && attachments.length !== 1 && !hasAudioRecording) {
57936
58247
  setViewOnce(false);
@@ -57964,6 +58275,9 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57964
58275
  });
57965
58276
  useDidUpdate(function () {
57966
58277
  var _draftMessagesMap$act;
58278
+ if (composerChannelId !== activeChannel.id) {
58279
+ return;
58280
+ }
57967
58281
  var persistedReply = (_draftMessagesMap$act = draftMessagesMap[activeChannel.id]) === null || _draftMessagesMap$act === void 0 ? void 0 : _draftMessagesMap$act.messageForReply;
57968
58282
  if (isNavigatingChannelRef.current) {
57969
58283
  isNavigatingChannelRef.current = false;
@@ -57991,7 +58305,7 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57991
58305
  if (messageContRef && messageContRef.current) {
57992
58306
  dispatch(setSendMessageInputHeightAC(messageContRef.current.getBoundingClientRect().height));
57993
58307
  }
57994
- }, [messageForReply]);
58308
+ }, [messageForReply, activeChannel.id, composerChannelId]);
57995
58309
  useDidUpdate(function () {
57996
58310
  if (messageToEdit) {
57997
58311
  if (messageForReply) {
@@ -58024,7 +58338,6 @@ var SendMessageInput = function SendMessageInput(_ref3) {
58024
58338
  if (inputHeightTimeout) {
58025
58339
  clearTimeout(inputHeightTimeout);
58026
58340
  }
58027
- prevActiveChannelId = undefined;
58028
58341
  document.removeEventListener('mousedown', handleClick);
58029
58342
  if (messageContRef && messageContRef.current) {
58030
58343
  messageContRef.current.removeEventListener('paste', handlePastAttachments);
@@ -58082,16 +58395,21 @@ var SendMessageInput = function SendMessageInput(_ref3) {
58082
58395
  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));
58083
58396
  }, [linkPreview]);
58084
58397
  useEffect(function () {
58085
- if (messageContRef && messageContRef.current) {
58086
- setTimeout(function () {
58087
- dispatch(setSendMessageInputHeightAC(messageContRef.current.getBoundingClientRect().height));
58088
- }, 301);
58089
- }
58398
+ if (!messageContRef.current) return undefined;
58399
+ var timeout = setTimeout(function () {
58400
+ var messageContainer = messageContRef.current;
58401
+ if (messageContainer) {
58402
+ dispatch(setSendMessageInputHeightAC(messageContainer.getBoundingClientRect().height));
58403
+ }
58404
+ }, 301);
58405
+ return function () {
58406
+ return clearTimeout(timeout);
58407
+ };
58090
58408
  }, [showLinkPreview]);
58091
58409
  return /*#__PURE__*/React__default.createElement(SendMessageWrapper, {
58092
58410
  ref: sendMessageWrapperRef,
58093
58411
  backgroundColor: backgroundColor || background,
58094
- "$hidden": pinnedMessagesListOpen && !messageToEdit && !messageForReply && !(selectedMessagesMap !== null && selectedMessagesMap !== void 0 && selectedMessagesMap.size)
58412
+ "$hidden": pinnedMessagesListOpen && !(selectedMessagesMap && selectedMessagesMap.size > 0)
58095
58413
  }, /*#__PURE__*/React__default.createElement(Container$m, {
58096
58414
  margin: margin,
58097
58415
  padding: padding,
@@ -58438,11 +58756,11 @@ var SendMessageInput = function SendMessageInput(_ref3) {
58438
58756
  draftMessage: (restoredEditMessage === null || restoredEditMessage === void 0 ? void 0 : restoredEditMessage.id) === (messageToEdit === null || messageToEdit === void 0 ? void 0 : messageToEdit.id) ? restoredEditMessage : null,
58439
58757
  contactsMap: contactsMap,
58440
58758
  getFromContacts: getFromContacts,
58441
- setMentionedMember: setMentionedUsers
58759
+ setMentionedMember: setComposerMentionedUsers
58442
58760
  }), /*#__PURE__*/React__default.createElement(FormatMessagePlugin, {
58443
58761
  editorState: realEditorState,
58444
- setMessageBodyAttributes: setMessageBodyAttributes,
58445
- setMessageText: messageToEdit ? setEditMessageText : setMessageText,
58762
+ setMessageBodyAttributes: setComposerMessageBodyAttributes,
58763
+ setMessageText: messageToEdit ? setComposerEditMessageText : setComposerMessageText,
58446
58764
  messageToEdit: messageToEdit,
58447
58765
  activeChannelMembers: activeChannelMembers,
58448
58766
  contactsMap: contactsMap,
@@ -58485,11 +58803,11 @@ var SendMessageInput = function SendMessageInput(_ref3) {
58485
58803
  anchorElem: floatingAnchorElem
58486
58804
  })))))))), 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, {
58487
58805
  isCustomButton: CustomSendMessageButton,
58488
- isActive: sendMessageIsActive,
58806
+ isActive: sendMessageIsActive && !isSendMessageInFlight,
58489
58807
  order: sendIconOrder,
58490
58808
  color: backgroundSections,
58491
58809
  height: inputContainerHeight || minHeight,
58492
- onClick: sendMessageIsActive ? handleSendEditMessage : null,
58810
+ onClick: sendMessageIsActive && !isSendMessageInFlight ? handleSendEditMessage : null,
58493
58811
  iconColor: accentColor,
58494
58812
  activeColor: accentColor
58495
58813
  }, CustomSendMessageButton || /*#__PURE__*/React__default.createElement(SvgSend, null))) : (/*#__PURE__*/React__default.createElement(SendMessageButton, {
@@ -58501,7 +58819,7 @@ var SendMessageInput = function SendMessageInput(_ref3) {
58501
58819
  activeColor: accentColor
58502
58820
  }, /*#__PURE__*/React__default.createElement(AudioRecord$1, {
58503
58821
  sendRecordedFile: sendRecordedFile,
58504
- setShowRecording: setShowRecording,
58822
+ setShowRecording: handleShowRecording,
58505
58823
  showRecording: showRecording,
58506
58824
  channelId: activeChannel.id,
58507
58825
  maxRecordingDuration: audioRecordingMaxDuration,
@@ -58513,10 +58831,14 @@ var SendMessageInput = function SendMessageInput(_ref3) {
58513
58831
  ViewOnceNotSelectedSVGIcon: ViewOnceNotSelectedSVGIcon
58514
58832
  }))))))))));
58515
58833
  };
58516
- var SendMessageWrapper = styled.div(_templateObject$Z || (_templateObject$Z = _taggedTemplateLiteralLoose(["\n visibility: ", ";\n pointer-events: ", ";\n background-color: ", ";\n position: relative;\n z-index: 10;\n"])), function (props) {
58834
+ var SendMessageWrapper = styled.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) {
58517
58835
  return props.$hidden ? 'hidden' : 'visible';
58518
58836
  }, function (props) {
58519
58837
  return props.$hidden ? 'none' : 'auto';
58838
+ }, function (props) {
58839
+ return props.$hidden ? '40px' : 'none';
58840
+ }, function (props) {
58841
+ return props.$hidden ? 'hidden' : 'visible';
58520
58842
  }, function (props) {
58521
58843
  return props.backgroundColor;
58522
58844
  });
@@ -60432,7 +60754,7 @@ var Files = function Files(_ref) {
60432
60754
  fontSize: fileSizeFontSize,
60433
60755
  lineHeight: fileSizeLineHeight,
60434
60756
  color: filePreviewSizeColor || textSecondary
60435
- }, file.size ? bytesToSize(file.size) + " \u2022 " + formatChannelDetailsDate(file.createdAt) : formatChannelDetailsDate(file.createdAt))), /*#__PURE__*/React__default.createElement(DownloadWrapper, {
60757
+ }, file.size ? bytesToSize(file.size, 1) + " \u2022 " + formatChannelDetailsDate(file.createdAt) : formatChannelDetailsDate(file.createdAt))), /*#__PURE__*/React__default.createElement(DownloadWrapper, {
60436
60758
  visible: !!downloadingFilesMap[file.id],
60437
60759
  iconColor: accentColor,
60438
60760
  onClick: function onClick() {
@@ -64236,7 +64558,10 @@ var UnreadCount$2 = styled.span(_templateObject2$1c || (_templateObject2$1c = _t
64236
64558
  return props.textColor || '#fff';
64237
64559
  });
64238
64560
 
64239
- var createOrGetDirectChannel = function createOrGetDirectChannel(user, callback) {
64561
+ var createOrGetDirectChannel = function createOrGetDirectChannel(user, callback, dontCreateIfNotExists) {
64562
+ if (dontCreateIfNotExists === void 0) {
64563
+ dontCreateIfNotExists = false;
64564
+ }
64240
64565
  try {
64241
64566
  if (user) {
64242
64567
  store.dispatch(createChannelAC({
@@ -64245,7 +64570,7 @@ var createOrGetDirectChannel = function createOrGetDirectChannel(user, callback)
64245
64570
  members: [_extends({}, user, {
64246
64571
  role: 'owner'
64247
64572
  })]
64248
- }, false, callback));
64573
+ }, dontCreateIfNotExists, callback));
64249
64574
  }
64250
64575
  return Promise.resolve();
64251
64576
  } catch (e) {