sceyt-chat-react-uikit 1.9.0-beta.14 → 1.9.0-beta.16

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.
@@ -0,0 +1,24 @@
1
+ export declare type ComposerDraft = {
2
+ text: string;
3
+ mentionedUsers: any[];
4
+ messageForReply: any;
5
+ editorState: any;
6
+ bodyAttributes: any;
7
+ attachments: any[];
8
+ viewOnce: boolean;
9
+ };
10
+ export declare type DraftHandoff = {
11
+ channelId: string;
12
+ draft: ComposerDraft;
13
+ persist: boolean;
14
+ };
15
+ declare type ComposerState = ComposerDraft & {
16
+ channelId: string;
17
+ nextChannelId: string;
18
+ };
19
+ /**
20
+ * Returns the only draft write allowed while the active chat changes. The
21
+ * composer values belong to `channelId`, never to `nextChannelId`.
22
+ */
23
+ export declare const getDraftHandoff: ({ channelId, nextChannelId, text, mentionedUsers, messageForReply, editorState, bodyAttributes, attachments, viewOnce }: ComposerState) => DraftHandoff | null;
24
+ export {};
package/index.js CHANGED
@@ -13744,9 +13744,10 @@ var hydrateDraftMessages = function hydrateDraftMessages() {
13744
13744
  type: data.type || attachment.mimeType || 'application/octet-stream',
13745
13745
  lastModified: attachment.lastModified || Date.now()
13746
13746
  }) : data;
13747
+ var canRestorePreviewUrl = attachment.type === attachmentTypes.image || attachment.type === attachmentTypes.video || attachment.type === attachmentTypes.voice;
13747
13748
  return _extends({}, attachment, {
13748
13749
  data: restoredData,
13749
- 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
13750
13751
  });
13751
13752
  });
13752
13753
  draftMessagesMap[channelId] = _extends({}, draft, {
@@ -29557,9 +29558,16 @@ function updateChannel(action) {
29557
29558
  avatarUrl: avatarUrl,
29558
29559
  metadata: isJSON(metadata) ? JSON.parse(metadata) : metadata
29559
29560
  });
29561
+ _context28.n = 6;
29562
+ return effects.put(updateSearchedChannelDataAC(channelId, {
29563
+ subject: subject,
29564
+ avatarUrl: avatarUrl,
29565
+ metadata: isJSON(metadata) ? JSON.parse(metadata) : metadata
29566
+ }, getChannelGroupName(channel)));
29567
+ case 6:
29560
29568
  onUpdateChannel = getOnUpdateChannel();
29561
29569
  if (!onUpdateChannel) {
29562
- _context28.n = 7;
29570
+ _context28.n = 8;
29563
29571
  break;
29564
29572
  }
29565
29573
  fields = [];
@@ -29572,22 +29580,22 @@ function updateChannel(action) {
29572
29580
  if (JSON.stringify((_channel5 = channel) === null || _channel5 === void 0 ? void 0 : _channel5.metadata) !== metadata) {
29573
29581
  fields.push('metadata');
29574
29582
  }
29575
- _context28.n = 6;
29583
+ _context28.n = 7;
29576
29584
  return effects.call(getChannelFromMap, channelId);
29577
- case 6:
29585
+ case 7:
29578
29586
  updatedChannel = _context28.v;
29579
29587
  onUpdateChannel(updatedChannel, fields);
29580
- case 7:
29581
- _context28.n = 9;
29582
- break;
29583
29588
  case 8:
29584
- _context28.p = 8;
29589
+ _context28.n = 10;
29590
+ break;
29591
+ case 9:
29592
+ _context28.p = 9;
29585
29593
  _t26 = _context28.v;
29586
29594
  log.error('ERROR in update channel', _t26.message);
29587
- case 9:
29595
+ case 10:
29588
29596
  return _context28.a(2);
29589
29597
  }
29590
- }, _marked27$1, null, [[0, 8]]);
29598
+ }, _marked27$1, null, [[0, 9]]);
29591
29599
  }
29592
29600
  function checkUsersStatus() {
29593
29601
  var _SceytChatClient7, usersForUpdate, updatedUsers, usersToUpdateMap, update, updateData, _t27;
@@ -34088,10 +34096,11 @@ var Channel = function Channel(_ref3) {
34088
34096
  setDraftMessageText(undefined);
34089
34097
  setDraftMessage(undefined);
34090
34098
  } else {
34099
+ var _channelDraftMessage$5;
34091
34100
  setDraftMessageText(draftText);
34092
34101
  setDraftMessage({
34093
34102
  mentionedUsers: channelDraftMessage.mentionedUsers,
34094
- body: channelDraftMessage.text,
34103
+ body: (_channelDraftMessage$5 = channelDraftMessage.text) !== null && _channelDraftMessage$5 !== void 0 && _channelDraftMessage$5.trim() ? channelDraftMessage.text : '',
34095
34104
  bodyAttributes: channelDraftMessage.bodyAttributes,
34096
34105
  attachments: channelDraftMessage.attachments,
34097
34106
  viewOnce: channelDraftMessage.viewOnce,
@@ -34100,7 +34109,14 @@ var Channel = function Channel(_ref3) {
34100
34109
  }
34101
34110
  } else if (draftAudioRecording) {
34102
34111
  setDraftMessageText('Voice');
34103
- setDraftMessage(undefined);
34112
+ setDraftMessage({
34113
+ body: '',
34114
+ attachments: [{
34115
+ type: attachmentTypes.voice,
34116
+ data: draftAudioRecording.file,
34117
+ attachmentUrl: draftAudioRecording.objectUrl
34118
+ }]
34119
+ });
34104
34120
  }
34105
34121
  } else if (draftMessageText) {
34106
34122
  setDraftMessageText(undefined);
@@ -41345,7 +41361,7 @@ var AttachmentImg = styled__default.img(_templateObject13$3 || (_templateObject1
41345
41361
  }, function (props) {
41346
41362
  return props.$fadeIn && styled.css(_templateObject14$3 || (_templateObject14$3 = _taggedTemplateLiteralLoose(["\n opacity: 0;\n animation: ", " 100ms ease-in-out forwards;\n "])), mediaCrossFade);
41347
41363
  });
41348
- var VideoCont = styled__default.div(_templateObject15$2 || (_templateObject15$2 = _taggedTemplateLiteralLoose(["\n position: relative;\n cursor: pointer;\n width: 100%;\n height: ", ";\n"])), function (props) {
41364
+ var VideoCont = styled__default.div(_templateObject15$2 || (_templateObject15$2 = _taggedTemplateLiteralLoose(["\n position: relative;\n cursor: pointer;\n height: ", ";\n"])), function (props) {
41349
41365
  return props.isDetailsView && '100%';
41350
41366
  });
41351
41367
 
@@ -42593,7 +42609,7 @@ var SliderPopup = function SliderPopup(_ref) {
42593
42609
  };
42594
42610
  var handleClicks = React.useCallback(function (e) {
42595
42611
  var target = e.target;
42596
- if (!target.closest('.custom_carousel_item') && !target.closest('.custom_carousel_arrow')) {
42612
+ if (!target.closest('.slider-preview-media, .custom_video_player, .custom_carousel_arrow')) {
42597
42613
  if (currentFileType === 'image') {
42598
42614
  log.info('[MEDIA_IMAGE_SLIDER] outside click closing slider ' + JSON.stringify({
42599
42615
  channelId: channel.id,
@@ -43030,6 +43046,7 @@ var SliderPopup = function SliderPopup(_ref) {
43030
43046
  })))), isItemLoading(file.id) && file.type === 'image' && (/*#__PURE__*/React__default.createElement(ItemLoadingCont, null, /*#__PURE__*/React__default.createElement(UploadingIcon, {
43031
43047
  color: textOnPrimary
43032
43048
  }))), 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", {
43049
+ className: 'slider-preview-media',
43033
43050
  loading: 'eager',
43034
43051
  decoding: 'async',
43035
43052
  draggable: false,
@@ -43144,7 +43161,7 @@ var IconWrapper = styled__default.span(_templateObject10$7 || (_templateObject10
43144
43161
  }, function (props) {
43145
43162
  return props.hideInMobile && "\n @media (max-width: 550px) {\n display: none;\n }\n ";
43146
43163
  });
43147
- var CarouselItem$1 = styled__default.div(_templateObject11$6 || (_templateObject11$6 = _taggedTemplateLiteralLoose(["\n position: relative;\n display: flex;\n width: calc(100% - 200px);\n height: calc(100% - 80px);\n max-width: calc(100% - 200px);\n max-height: calc(100vh - 140px);\n align-items: center;\n justify-content: center;\n z-index: 2;\n\n img,\n video {\n width: 100%;\n height: 100%;\n min-width: 0;\n min-height: 0;\n object-fit: contain;\n @media (max-width: 480px) {\n width: 100%;\n }\n }\n @media (max-width: 480px) {\n width: calc(100% - 100px);\n height: calc(100% - 48px);\n max-width: calc(100% - 100px);\n }\n\n img {\n display: block;\n }\n"])));
43164
+ var CarouselItem$1 = styled__default.div(_templateObject11$6 || (_templateObject11$6 = _taggedTemplateLiteralLoose(["\n position: relative;\n display: flex;\n width: calc(100% - 200px);\n height: calc(100% - 80px);\n max-width: calc(100% - 200px);\n max-height: calc(100vh - 140px);\n align-items: center;\n justify-content: center;\n z-index: 2;\n\n img,\n video {\n height: 100%;\n min-width: 0;\n min-height: 0;\n object-fit: contain;\n @media (max-width: 480px) {\n width: 100%;\n }\n }\n @media (max-width: 480px) {\n width: calc(100% - 100px);\n height: calc(100% - 48px);\n max-width: calc(100% - 100px);\n }\n\n img {\n display: block;\n }\n"])));
43148
43165
  var UploadCont$1 = styled__default.div(_templateObject12$5 || (_templateObject12$5 = _taggedTemplateLiteralLoose(["\n left: calc((100vw - 100%) / -2);\n top: calc((100vh - 100%) / -2);\n width: 100vw;\n height: 100vh;\n display: flex;\n align-items: center;\n justify-content: center;\n position: absolute;\n z-index: 1;\n"])));
43149
43166
  var ItemLoadingCont = styled__default.div(_templateObject13$5 || (_templateObject13$5 = _taggedTemplateLiteralLoose(["\n position: absolute;\n left: calc((100vw - 100%) / -2);\n top: calc((100vh - 100% + 60px) / -2);\n width: 100vw;\n height: 100vh;\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 1;\n"])));
43150
43167
  var ArrowButton = styled__default.button(_templateObject14$5 || (_templateObject14$5 = _taggedTemplateLiteralLoose(["\n min-width: 60px;\n max-width: 60px;\n height: 60px;\n margin-right: ", ";\n margin-left: ", ";\n border: none;\n color: ", ";\n background: transparent;\n box-sizing: border-box;\n border-radius: 50%;\n line-height: 1px;\n align-self: center;\n outline: none;\n cursor: pointer;\n visibility: ", ";\n position: absolute;\n top: 50%;\n transform: translateY(-50%);\n left: ", ";\n right: ", ";\n & > svg {\n width: 40px;\n height: 40px;\n }\n @media (max-width: 768px) {\n min-width: 36px;\n max-width: 36px;\n height: 36px;\n margin-right: ", ";\n margin-left: ", ";\n\n & > svg {\n width: 22px;\n height: 22px;\n }\n }\n @media (max-width: 450px) {\n min-width: 32px;\n max-width: 32px;\n height: 32px;\n\n & > svg {\n width: 20px;\n height: 20px;\n }\n }\n"])), function (props) {
@@ -51080,8 +51097,8 @@ var Message$1 = function Message(_ref) {
51080
51097
  var prevMessageUserID = prevMessage ? getComparableUserId(prevMessage.user) : null;
51081
51098
  var current = moment(message.createdAt).startOf('day');
51082
51099
  var firstMessageInInterval = React.useMemo(function () {
51083
- return ifLatestAndHasNotPreview || !(prevMessage && current.diff(moment(prevMessage.createdAt).startOf('day'), 'days') === 0) || (prevMessage === null || prevMessage === void 0 ? void 0 : prevMessage.type) === exports.MESSAGE_TYPE.SYSTEM || unreadMessageId === prevMessage.id;
51084
- }, [prevMessage, unreadMessageId, ifLatestAndHasNotPreview]);
51100
+ return ifLatestAndHasNotPreview || !isPinnedMessagesList && !(prevMessage && current.diff(moment(prevMessage.createdAt).startOf('day'), 'days') === 0) || (prevMessage === null || prevMessage === void 0 ? void 0 : prevMessage.type) === exports.MESSAGE_TYPE.SYSTEM || unreadMessageId === (prevMessage === null || prevMessage === void 0 ? void 0 : prevMessage.id);
51101
+ }, [prevMessage, unreadMessageId, ifLatestAndHasNotPreview, isPinnedMessagesList]);
51085
51102
  var nextMessageUserID = nextMessage ? getComparableUserId(nextMessage.user) : null;
51086
51103
  var nextDay = nextMessage ? moment(nextMessage.createdAt).startOf('day') : null;
51087
51104
  var nextMessageFirstInInterval = !nextMessage || nextDay !== null && nextDay.diff(current, 'days') !== 0 || nextMessage.type === exports.MESSAGE_TYPE.SYSTEM || nextMessageStartsUnreadSection;
@@ -51457,8 +51474,8 @@ var Message$1 = function Message(_ref) {
51457
51474
  if (!nextMessage || nextMessage.type === exports.MESSAGE_TYPE.SYSTEM) {
51458
51475
  spacingBottom = '';
51459
51476
  } else if (nextMessageStartsUnreadSection) {
51460
- spacingBottom = differentUserMessageSpacing || '16px';
51461
- } else if (nextMessageUserID && (nextMessageUserID !== messageUserID || nextMessageFirstInInterval)) {
51477
+ spacingBottom = isPinnedMessagesList ? '0' : differentUserMessageSpacing || '16px';
51478
+ } else if (nextMessageUserID && (nextMessageUserID !== messageUserID || nextMessageFirstInInterval && !isPinnedMessagesList)) {
51462
51479
  spacingBottom = differentUserMessageSpacing || '16px';
51463
51480
  }
51464
51481
  spacingTop = sameUserMessageSpacing || '6px';
@@ -51471,7 +51488,7 @@ var Message$1 = function Message(_ref) {
51471
51488
  bottom: reactionsMargin || spacingBottom,
51472
51489
  top: spacingTop
51473
51490
  };
51474
- }, [nextMessageUserID, messageUserID, nextMessageFirstInInterval, (_message$reactionTota = message.reactionTotals) === null || _message$reactionTota === void 0 ? void 0 : _message$reactionTota.length]);
51491
+ }, [nextMessageUserID, isPinnedMessagesList, messageUserID, nextMessageFirstInInterval, (_message$reactionTota = message.reactionTotals) === null || _message$reactionTota === void 0 ? void 0 : _message$reactionTota.length]);
51475
51492
  return /*#__PURE__*/React__default.createElement(MessageItem, {
51476
51493
  className: 'message_item',
51477
51494
  rtl: ownMessageOnRightSide && !message.incoming,
@@ -52957,7 +52974,7 @@ var MessageList = function MessageList(_ref) {
52957
52974
  isUnreadMessage: false,
52958
52975
  nextMessageStartsUnreadSection: false,
52959
52976
  isHighlighted: false,
52960
- ifLatestAndHasNotPreview: channel.type !== DEFAULT_CHANNEL_TYPE.DIRECT,
52977
+ ifLatestAndHasNotPreview: index === 0,
52961
52978
  registerInMessagesIndex: false,
52962
52979
  isPinnedMessagesList: true
52963
52980
  });
@@ -55077,10 +55094,14 @@ var Emoji$1 = styled__default.li(_templateObject8$m || (_templateObject8$m = _ta
55077
55094
  return props.hoverBackgroundColor;
55078
55095
  });
55079
55096
 
55097
+ var isVideoAttachment = function isVideoAttachment(attachment) {
55098
+ var _attachment$data, _attachment$data$type;
55099
+ return attachment.type === attachmentTypes.video || ((_attachment$data = attachment.data) === null || _attachment$data === void 0 ? void 0 : (_attachment$data$type = _attachment$data.type) === null || _attachment$data$type === void 0 ? void 0 : _attachment$data$type.startsWith('video/'));
55100
+ };
55080
55101
  var waitForMediaAttachmentPreparation = function waitForMediaAttachmentPreparation(attachments, preparations) {
55081
55102
  try {
55082
55103
  return Promise.resolve(Promise.all(attachments.filter(function (attachment) {
55083
- return attachment.type === attachmentTypes.image || getOutgoingAttachmentType(attachment) === attachmentTypes.video;
55104
+ return attachment.type === attachmentTypes.image || isVideoAttachment(attachment);
55084
55105
  }).map(function (attachment) {
55085
55106
  return attachment.tid ? preparations.get(attachment.tid) : undefined;
55086
55107
  }))).then(function () {});
@@ -55094,8 +55115,7 @@ var mergePreparedAttachmentPatches = function mergePreparedAttachmentPatches(att
55094
55115
  });
55095
55116
  };
55096
55117
  var getOutgoingAttachmentType = function getOutgoingAttachmentType(attachment) {
55097
- var _attachment$data, _attachment$data$type;
55098
- 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;
55118
+ return attachment.type;
55099
55119
  };
55100
55120
 
55101
55121
  var CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined';
@@ -56526,6 +56546,52 @@ var SettingItem = styled__default.div(_templateObject9$k || (_templateObject9$k
56526
56546
  return props.color;
56527
56547
  });
56528
56548
 
56549
+ var getDraftHandoff = function getDraftHandoff(_ref) {
56550
+ var channelId = _ref.channelId,
56551
+ nextChannelId = _ref.nextChannelId,
56552
+ text = _ref.text,
56553
+ mentionedUsers = _ref.mentionedUsers,
56554
+ messageForReply = _ref.messageForReply,
56555
+ editorState = _ref.editorState,
56556
+ bodyAttributes = _ref.bodyAttributes,
56557
+ attachments = _ref.attachments,
56558
+ viewOnce = _ref.viewOnce;
56559
+ if (!channelId || channelId === nextChannelId) {
56560
+ return null;
56561
+ }
56562
+ if (text.trim() || attachments.length) {
56563
+ return {
56564
+ channelId: channelId,
56565
+ draft: {
56566
+ text: text,
56567
+ mentionedUsers: mentionedUsers,
56568
+ messageForReply: messageForReply,
56569
+ editorState: editorState,
56570
+ bodyAttributes: bodyAttributes,
56571
+ attachments: attachments,
56572
+ viewOnce: viewOnce
56573
+ },
56574
+ persist: true
56575
+ };
56576
+ }
56577
+ if (messageForReply) {
56578
+ return {
56579
+ channelId: channelId,
56580
+ draft: {
56581
+ text: '',
56582
+ mentionedUsers: mentionedUsers,
56583
+ messageForReply: messageForReply,
56584
+ editorState: editorState,
56585
+ bodyAttributes: bodyAttributes,
56586
+ attachments: [],
56587
+ viewOnce: false
56588
+ },
56589
+ persist: false
56590
+ };
56591
+ }
56592
+ return null;
56593
+ };
56594
+
56529
56595
  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;
56530
56596
  function AutoFocusPlugin(_ref) {
56531
56597
  var messageForReply = _ref.messageForReply;
@@ -56590,9 +56656,9 @@ function ClearEditorPlugin(_ref2) {
56590
56656
  function onError(error) {
56591
56657
  log.error(error);
56592
56658
  }
56593
- var prevActiveChannelId;
56594
56659
  var attachmentsUpdate = [];
56595
56660
  var UNSUPPORTED_PASTED_FILE_MESSAGE = 'This file format is not supported.';
56661
+ var useComposerLayoutEffect = CAN_USE_DOM ? React.useLayoutEffect : React.useEffect;
56596
56662
  var SendMessageInput = function SendMessageInput(_ref3) {
56597
56663
  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;
56598
56664
  var handleAttachmentSelected = _ref3.handleAttachmentSelected,
@@ -56824,6 +56890,9 @@ var SendMessageInput = function SendMessageInput(_ref3) {
56824
56890
  var _useState30 = React.useState(areDraftMessagesHydrated()),
56825
56891
  draftsHydrated = _useState30[0],
56826
56892
  setDraftsHydrated = _useState30[1];
56893
+ var _useState31 = React.useState(activeChannel.id || ''),
56894
+ composerChannelId = _useState31[0],
56895
+ setComposerChannelId = _useState31[1];
56827
56896
  var typingOrRecordingIndicator = useSelector(typingOrRecordingIndicatorArraySelector(activeChannel.id));
56828
56897
  var contactsMap = useSelector(contactsMapSelector);
56829
56898
  var connectionStatus = useSelector(connectionStatusSelector, reactRedux.shallowEqual);
@@ -56840,36 +56909,36 @@ var SendMessageInput = function SendMessageInput(_ref3) {
56840
56909
  var restoringDraftRef = React.useRef(false);
56841
56910
  var restoredDraftChannelIdRef = React.useRef(null);
56842
56911
  var isNavigatingChannelRef = React.useRef(false);
56843
- var _useState31 = React.useState(),
56844
- realEditorState = _useState31[0],
56845
- setRealEditorState = _useState31[1];
56846
- var _useState32 = React.useState(null),
56847
- floatingAnchorElem = _useState32[0],
56848
- setFloatingAnchorElem = _useState32[1];
56849
- var _useState33 = React.useState(false),
56850
- isSmallWidthViewport = _useState33[0],
56851
- setIsSmallWidthViewport = _useState33[1];
56912
+ var _useState32 = React.useState(),
56913
+ realEditorState = _useState32[0],
56914
+ setRealEditorState = _useState32[1];
56915
+ var _useState33 = React.useState(null),
56916
+ floatingAnchorElem = _useState33[0],
56917
+ setFloatingAnchorElem = _useState33[1];
56852
56918
  var _useState34 = React.useState(false),
56853
- isScrolling = _useState34[0],
56854
- setIsScrolling = _useState34[1];
56855
- var _useState35 = React.useState(null),
56856
- linkPreview = _useState35[0],
56857
- setLinkPreview = _useState35[1];
56919
+ isSmallWidthViewport = _useState34[0],
56920
+ setIsSmallWidthViewport = _useState34[1];
56921
+ var _useState35 = React.useState(false),
56922
+ isScrolling = _useState35[0],
56923
+ setIsScrolling = _useState35[1];
56858
56924
  var _useState36 = React.useState(null),
56859
- detectedUrl = _useState36[0],
56860
- setDetectedUrl = _useState36[1];
56861
- var _useState37 = React.useState(new Set()),
56862
- dismissedUrls = _useState37[0],
56863
- setDismissedUrls = _useState37[1];
56864
- var _useState38 = React.useState(false),
56865
- isClosingPreview = _useState38[0],
56866
- setIsClosingPreview = _useState38[1];
56925
+ linkPreview = _useState36[0],
56926
+ setLinkPreview = _useState36[1];
56927
+ var _useState37 = React.useState(null),
56928
+ detectedUrl = _useState37[0],
56929
+ setDetectedUrl = _useState37[1];
56930
+ var _useState38 = React.useState(new Set()),
56931
+ dismissedUrls = _useState38[0],
56932
+ setDismissedUrls = _useState38[1];
56867
56933
  var _useState39 = React.useState(false),
56868
- replyLinkPreviewImageFailed = _useState39[0],
56869
- setReplyLinkPreviewImageFailed = _useState39[1];
56934
+ isClosingPreview = _useState39[0],
56935
+ setIsClosingPreview = _useState39[1];
56870
56936
  var _useState40 = React.useState(false),
56871
- linkPreviewImageFailed = _useState40[0],
56872
- setLinkPreviewImageFailed = _useState40[1];
56937
+ replyLinkPreviewImageFailed = _useState40[0],
56938
+ setReplyLinkPreviewImageFailed = _useState40[1];
56939
+ var _useState41 = React.useState(false),
56940
+ linkPreviewImageFailed = _useState41[0],
56941
+ setLinkPreviewImageFailed = _useState41[1];
56873
56942
  var addAttachmentByMenu = showChooseFileAttachment && showChooseMediaAttachment;
56874
56943
  var linkify = new LinkifyIt();
56875
56944
  var oGMetadata = useSelector(function (state) {
@@ -56880,8 +56949,51 @@ var SendMessageInput = function SendMessageInput(_ref3) {
56880
56949
  return setDraftsHydrated(areDraftMessagesHydrated());
56881
56950
  });
56882
56951
  }, []);
56952
+ useComposerLayoutEffect(function () {
56953
+ var nextChannelId = activeChannel.id || '';
56954
+ if (composerChannelId === nextChannelId) {
56955
+ return;
56956
+ }
56957
+ if (draftsHydrated) {
56958
+ var handoff = getDraftHandoff({
56959
+ channelId: composerChannelId,
56960
+ nextChannelId: nextChannelId,
56961
+ text: messageText,
56962
+ mentionedUsers: mentionedUsers,
56963
+ messageForReply: messageForReply,
56964
+ editorState: realEditorState,
56965
+ bodyAttributes: messageBodyAttributes,
56966
+ attachments: attachments,
56967
+ viewOnce: viewOnce
56968
+ });
56969
+ if (handoff) {
56970
+ setDraftMessageToMap(handoff.channelId, handoff.draft, {
56971
+ persist: handoff.persist
56972
+ });
56973
+ }
56974
+ }
56975
+ restoringDraftRef.current = false;
56976
+ restoredDraftChannelIdRef.current = null;
56977
+ isNavigatingChannelRef.current = !!messageForReply;
56978
+ setComposerChannelId(nextChannelId);
56979
+ setMessageText('');
56980
+ setEditMessageText('');
56981
+ setRestoredEditMessage(null);
56982
+ setMessageBodyAttributes([]);
56983
+ setMentionedUsers([]);
56984
+ setAttachments([]);
56985
+ setViewOnce(false);
56986
+ setSendMessageIsActive(false);
56987
+ setShouldClearEditor({
56988
+ clear: true
56989
+ });
56990
+ attachmentsUpdate = [];
56991
+ clearTimeout(typingTimout);
56992
+ dispatch(setMessageForReplyAC(null));
56993
+ dispatch(setMessageToEditAC(null));
56994
+ }, [activeChannel.id, composerChannelId]);
56883
56995
  React.useEffect(function () {
56884
- if (!draftsHydrated || !activeChannel.id) {
56996
+ if (!draftsHydrated || !activeChannel.id || composerChannelId !== activeChannel.id) {
56885
56997
  return;
56886
56998
  }
56887
56999
  var draftMessage = getDraftMessageFromMap(activeChannel.id);
@@ -56915,7 +57027,27 @@ var SendMessageInput = function SendMessageInput(_ref3) {
56915
57027
  draftMessage: draftMessage
56916
57028
  });
56917
57029
  restoredDraftChannelIdRef.current = activeChannel.id;
56918
- }, [draftsHydrated, activeChannel.id]);
57030
+ }, [draftsHydrated, activeChannel.id, composerChannelId]);
57031
+ var setComposerMessageText = React.useCallback(function (text) {
57032
+ if (composerChannelId === activeChannel.id) {
57033
+ setMessageText(text);
57034
+ }
57035
+ }, [activeChannel.id, composerChannelId]);
57036
+ var setComposerEditMessageText = React.useCallback(function (text) {
57037
+ if (composerChannelId === activeChannel.id) {
57038
+ setEditMessageText(text);
57039
+ }
57040
+ }, [activeChannel.id, composerChannelId]);
57041
+ var setComposerMessageBodyAttributes = React.useCallback(function (attributes) {
57042
+ if (composerChannelId === activeChannel.id) {
57043
+ setMessageBodyAttributes(attributes);
57044
+ }
57045
+ }, [activeChannel.id, composerChannelId]);
57046
+ var setComposerMentionedUsers = React.useCallback(function (users) {
57047
+ if (composerChannelId === activeChannel.id) {
57048
+ setMentionedUsers(users);
57049
+ }
57050
+ }, [activeChannel.id, composerChannelId]);
56919
57051
  React.useEffect(function () {
56920
57052
  setReplyLinkPreviewImageFailed(false);
56921
57053
  }, [messageForReply === null || messageForReply === void 0 ? void 0 : messageForReply.id, messageForReply === null || messageForReply === void 0 ? void 0 : messageForReply.tid]);
@@ -57567,9 +57699,11 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57567
57699
  dispatch(clearSelectedMessagesAC());
57568
57700
  };
57569
57701
  var handleSetMentionMember = function handleSetMentionMember(mentionMember) {
57570
- setMentionedUsers(function (prevState) {
57571
- return [].concat(prevState, [mentionMember]);
57572
- });
57702
+ if (composerChannelId === activeChannel.id) {
57703
+ setMentionedUsers(function (prevState) {
57704
+ return [].concat(prevState, [mentionMember]);
57705
+ });
57706
+ }
57573
57707
  };
57574
57708
  var createComposePreviewUrl = function createComposePreviewUrl(attachmentTid, blob) {
57575
57709
  var url = URL.createObjectURL(blob);
@@ -57597,7 +57731,7 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57597
57731
  if (fileType === 'video') {
57598
57732
  beginVideoPreparation(tid, file);
57599
57733
  }
57600
- var type = fileType === 'video' && (!customUploader || isMediaAttachment) ? 'video' : isMediaAttachment && fileType === 'image' ? 'image' : 'file';
57734
+ var type = isMediaAttachment && fileType === 'video' ? attachmentTypes.video : isMediaAttachment && fileType === 'image' ? attachmentTypes.image : attachmentTypes.file;
57601
57735
  var attachment = _extends({
57602
57736
  data: file,
57603
57737
  name: file.name,
@@ -57905,59 +58039,6 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57905
58039
  };
57906
58040
  }, [isSmallWidthViewport]);
57907
58041
  React.useEffect(function () {
57908
- if (prevActiveChannelId && activeChannel.id && prevActiveChannelId !== activeChannel.id) {
57909
- setMessageText('');
57910
- if (messageForReply) {
57911
- isNavigatingChannelRef.current = true;
57912
- handleCloseReply(true);
57913
- }
57914
- setAttachments([]);
57915
- attachmentsUpdate = [];
57916
- handleCloseEditMode(!!messageToEdit);
57917
- clearTimeout(typingTimout);
57918
- var draftMessage = getDraftMessageFromMap(activeChannel.id);
57919
- if (draftMessage) {
57920
- restoringDraftRef.current = true;
57921
- if (draftMessage.messageToEdit) {
57922
- var _ref6, _draftMessage$editMes2, _draftMessage$editBod2, _draftMessage$mention2;
57923
- var restoredText = (_ref6 = (_draftMessage$editMes2 = draftMessage.editMessageText) != null ? _draftMessage$editMes2 : draftMessage.messageToEdit.body) != null ? _ref6 : '';
57924
- var restoredEdit = _extends({}, draftMessage.messageToEdit, {
57925
- body: restoredText,
57926
- bodyAttributes: (_draftMessage$editBod2 = draftMessage.editBodyAttributes) != null ? _draftMessage$editBod2 : draftMessage.messageToEdit.bodyAttributes,
57927
- mentionedUsers: (_draftMessage$mention2 = draftMessage.mentionedUsers) != null ? _draftMessage$mention2 : draftMessage.messageToEdit.mentionedUsers
57928
- });
57929
- setEditMessageText(restoredText);
57930
- setMessageBodyAttributes(restoredEdit.bodyAttributes || []);
57931
- setMentionedUsers(restoredEdit.mentionedUsers || []);
57932
- setRestoredEditMessage(restoredEdit);
57933
- dispatch(setMessageToEditAC(draftMessage.messageToEdit));
57934
- restoredDraftChannelIdRef.current = activeChannel.id;
57935
- }
57936
- if (!draftMessage.messageToEdit) {
57937
- if (draftMessage.messageForReply) {
57938
- dispatch(setMessageForReplyAC(draftMessage.messageForReply));
57939
- }
57940
- setMessageText(draftMessage.text);
57941
- setMentionedUsers(draftMessage.mentionedUsers);
57942
- setAttachments(draftMessage.attachments || []);
57943
- setViewOnce(!!draftMessage.viewOnce);
57944
- restoredDraftChannelIdRef.current = activeChannel.id;
57945
- setShouldClearEditor({
57946
- clear: true,
57947
- draftMessage: draftMessage
57948
- });
57949
- }
57950
- } else {
57951
- setMentionedUsers([]);
57952
- setShouldClearEditor({
57953
- clear: true,
57954
- draftMessage: draftMessage
57955
- });
57956
- }
57957
- }
57958
- if (activeChannel.id) {
57959
- prevActiveChannelId = activeChannel.id;
57960
- }
57961
58042
  if (activeChannel.id && membersHasNext === undefined && !(activeChannel.type === DEFAULT_CHANNEL_TYPE.DIRECT && activeChannel.memberCount === 2)) {
57962
58043
  dispatch(getMembersAC(activeChannel.id));
57963
58044
  }
@@ -57966,6 +58047,9 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57966
58047
  if (!draftsHydrated) {
57967
58048
  return;
57968
58049
  }
58050
+ if (!activeChannel.id || composerChannelId !== activeChannel.id) {
58051
+ return;
58052
+ }
57969
58053
  if (restoringDraftRef.current) {
57970
58054
  restoringDraftRef.current = false;
57971
58055
  return;
@@ -58052,9 +58136,9 @@ var SendMessageInput = function SendMessageInput(_ref3) {
58052
58136
  document.body.removeAttribute('onbeforeunload');
58053
58137
  }
58054
58138
  }
58055
- }, [messageText, attachments, editMessageText, readyVideoAttachments, messageBodyAttributes, messageToEdit, viewOnce, draftsHydrated]);
58139
+ }, [messageText, attachments, editMessageText, readyVideoAttachments, messageBodyAttributes, messageToEdit, viewOnce, draftsHydrated, activeChannel.id, composerChannelId]);
58056
58140
  useDidUpdate(function () {
58057
- if (!messageToEdit && mentionedUsers && mentionedUsers.length) {
58141
+ if (composerChannelId === activeChannel.id && !messageToEdit && mentionedUsers && mentionedUsers.length) {
58058
58142
  setDraftMessageToMap(activeChannel.id, {
58059
58143
  text: messageText,
58060
58144
  mentionedUsers: mentionedUsers,
@@ -58066,7 +58150,7 @@ var SendMessageInput = function SendMessageInput(_ref3) {
58066
58150
  persist: !!(messageText.trim() || attachments.length)
58067
58151
  });
58068
58152
  }
58069
- }, [mentionedUsers]);
58153
+ }, [mentionedUsers, activeChannel.id, composerChannelId]);
58070
58154
  useDidUpdate(function () {
58071
58155
  var _getAudioRecordingFro;
58072
58156
  if (handleAttachmentSelected) {
@@ -58113,6 +58197,9 @@ var SendMessageInput = function SendMessageInput(_ref3) {
58113
58197
  });
58114
58198
  useDidUpdate(function () {
58115
58199
  var _draftMessagesMap$act;
58200
+ if (composerChannelId !== activeChannel.id) {
58201
+ return;
58202
+ }
58116
58203
  var persistedReply = (_draftMessagesMap$act = draftMessagesMap[activeChannel.id]) === null || _draftMessagesMap$act === void 0 ? void 0 : _draftMessagesMap$act.messageForReply;
58117
58204
  if (isNavigatingChannelRef.current) {
58118
58205
  isNavigatingChannelRef.current = false;
@@ -58140,7 +58227,7 @@ var SendMessageInput = function SendMessageInput(_ref3) {
58140
58227
  if (messageContRef && messageContRef.current) {
58141
58228
  dispatch(setSendMessageInputHeightAC(messageContRef.current.getBoundingClientRect().height));
58142
58229
  }
58143
- }, [messageForReply]);
58230
+ }, [messageForReply, activeChannel.id, composerChannelId]);
58144
58231
  useDidUpdate(function () {
58145
58232
  if (messageToEdit) {
58146
58233
  if (messageForReply) {
@@ -58173,7 +58260,6 @@ var SendMessageInput = function SendMessageInput(_ref3) {
58173
58260
  if (inputHeightTimeout) {
58174
58261
  clearTimeout(inputHeightTimeout);
58175
58262
  }
58176
- prevActiveChannelId = undefined;
58177
58263
  document.removeEventListener('mousedown', handleClick);
58178
58264
  if (messageContRef && messageContRef.current) {
58179
58265
  messageContRef.current.removeEventListener('paste', handlePastAttachments);
@@ -58587,11 +58673,11 @@ var SendMessageInput = function SendMessageInput(_ref3) {
58587
58673
  draftMessage: (restoredEditMessage === null || restoredEditMessage === void 0 ? void 0 : restoredEditMessage.id) === (messageToEdit === null || messageToEdit === void 0 ? void 0 : messageToEdit.id) ? restoredEditMessage : null,
58588
58674
  contactsMap: contactsMap,
58589
58675
  getFromContacts: getFromContacts,
58590
- setMentionedMember: setMentionedUsers
58676
+ setMentionedMember: setComposerMentionedUsers
58591
58677
  }), /*#__PURE__*/React__default.createElement(FormatMessagePlugin, {
58592
58678
  editorState: realEditorState,
58593
- setMessageBodyAttributes: setMessageBodyAttributes,
58594
- setMessageText: messageToEdit ? setEditMessageText : setMessageText,
58679
+ setMessageBodyAttributes: setComposerMessageBodyAttributes,
58680
+ setMessageText: messageToEdit ? setComposerEditMessageText : setComposerMessageText,
58595
58681
  messageToEdit: messageToEdit,
58596
58682
  activeChannelMembers: activeChannelMembers,
58597
58683
  contactsMap: contactsMap,
package/index.modern.js CHANGED
@@ -13724,9 +13724,10 @@ var hydrateDraftMessages = function hydrateDraftMessages() {
13724
13724
  type: data.type || attachment.mimeType || 'application/octet-stream',
13725
13725
  lastModified: attachment.lastModified || Date.now()
13726
13726
  }) : data;
13727
+ var canRestorePreviewUrl = attachment.type === attachmentTypes.image || attachment.type === attachmentTypes.video || attachment.type === attachmentTypes.voice;
13727
13728
  return _extends({}, attachment, {
13728
13729
  data: restoredData,
13729
- attachmentUrl: restoredData instanceof Blob && typeof URL !== 'undefined' ? URL.createObjectURL(restoredData) : attachment.attachmentUrl
13730
+ attachmentUrl: canRestorePreviewUrl && restoredData instanceof Blob && typeof URL !== 'undefined' ? URL.createObjectURL(restoredData) : undefined
13730
13731
  });
13731
13732
  });
13732
13733
  draftMessagesMap[channelId] = _extends({}, draft, {
@@ -29537,9 +29538,16 @@ function updateChannel(action) {
29537
29538
  avatarUrl: avatarUrl,
29538
29539
  metadata: isJSON(metadata) ? JSON.parse(metadata) : metadata
29539
29540
  });
29541
+ _context28.n = 6;
29542
+ return put(updateSearchedChannelDataAC(channelId, {
29543
+ subject: subject,
29544
+ avatarUrl: avatarUrl,
29545
+ metadata: isJSON(metadata) ? JSON.parse(metadata) : metadata
29546
+ }, getChannelGroupName(channel)));
29547
+ case 6:
29540
29548
  onUpdateChannel = getOnUpdateChannel();
29541
29549
  if (!onUpdateChannel) {
29542
- _context28.n = 7;
29550
+ _context28.n = 8;
29543
29551
  break;
29544
29552
  }
29545
29553
  fields = [];
@@ -29552,22 +29560,22 @@ function updateChannel(action) {
29552
29560
  if (JSON.stringify((_channel5 = channel) === null || _channel5 === void 0 ? void 0 : _channel5.metadata) !== metadata) {
29553
29561
  fields.push('metadata');
29554
29562
  }
29555
- _context28.n = 6;
29563
+ _context28.n = 7;
29556
29564
  return call(getChannelFromMap, channelId);
29557
- case 6:
29565
+ case 7:
29558
29566
  updatedChannel = _context28.v;
29559
29567
  onUpdateChannel(updatedChannel, fields);
29560
- case 7:
29561
- _context28.n = 9;
29562
- break;
29563
29568
  case 8:
29564
- _context28.p = 8;
29569
+ _context28.n = 10;
29570
+ break;
29571
+ case 9:
29572
+ _context28.p = 9;
29565
29573
  _t26 = _context28.v;
29566
29574
  log.error('ERROR in update channel', _t26.message);
29567
- case 9:
29575
+ case 10:
29568
29576
  return _context28.a(2);
29569
29577
  }
29570
- }, _marked27$1, null, [[0, 8]]);
29578
+ }, _marked27$1, null, [[0, 9]]);
29571
29579
  }
29572
29580
  function checkUsersStatus() {
29573
29581
  var _SceytChatClient7, usersForUpdate, updatedUsers, usersToUpdateMap, update, updateData, _t27;
@@ -34068,10 +34076,11 @@ var Channel = function Channel(_ref3) {
34068
34076
  setDraftMessageText(undefined);
34069
34077
  setDraftMessage(undefined);
34070
34078
  } else {
34079
+ var _channelDraftMessage$5;
34071
34080
  setDraftMessageText(draftText);
34072
34081
  setDraftMessage({
34073
34082
  mentionedUsers: channelDraftMessage.mentionedUsers,
34074
- body: channelDraftMessage.text,
34083
+ body: (_channelDraftMessage$5 = channelDraftMessage.text) !== null && _channelDraftMessage$5 !== void 0 && _channelDraftMessage$5.trim() ? channelDraftMessage.text : '',
34075
34084
  bodyAttributes: channelDraftMessage.bodyAttributes,
34076
34085
  attachments: channelDraftMessage.attachments,
34077
34086
  viewOnce: channelDraftMessage.viewOnce,
@@ -34080,7 +34089,14 @@ var Channel = function Channel(_ref3) {
34080
34089
  }
34081
34090
  } else if (draftAudioRecording) {
34082
34091
  setDraftMessageText('Voice');
34083
- setDraftMessage(undefined);
34092
+ setDraftMessage({
34093
+ body: '',
34094
+ attachments: [{
34095
+ type: attachmentTypes.voice,
34096
+ data: draftAudioRecording.file,
34097
+ attachmentUrl: draftAudioRecording.objectUrl
34098
+ }]
34099
+ });
34084
34100
  }
34085
34101
  } else if (draftMessageText) {
34086
34102
  setDraftMessageText(undefined);
@@ -41325,7 +41341,7 @@ var AttachmentImg = styled.img(_templateObject13$3 || (_templateObject13$3 = _ta
41325
41341
  }, function (props) {
41326
41342
  return props.$fadeIn && css(_templateObject14$3 || (_templateObject14$3 = _taggedTemplateLiteralLoose(["\n opacity: 0;\n animation: ", " 100ms ease-in-out forwards;\n "])), mediaCrossFade);
41327
41343
  });
41328
- var VideoCont = styled.div(_templateObject15$2 || (_templateObject15$2 = _taggedTemplateLiteralLoose(["\n position: relative;\n cursor: pointer;\n width: 100%;\n height: ", ";\n"])), function (props) {
41344
+ var VideoCont = styled.div(_templateObject15$2 || (_templateObject15$2 = _taggedTemplateLiteralLoose(["\n position: relative;\n cursor: pointer;\n height: ", ";\n"])), function (props) {
41329
41345
  return props.isDetailsView && '100%';
41330
41346
  });
41331
41347
 
@@ -42573,7 +42589,7 @@ var SliderPopup = function SliderPopup(_ref) {
42573
42589
  };
42574
42590
  var handleClicks = useCallback(function (e) {
42575
42591
  var target = e.target;
42576
- if (!target.closest('.custom_carousel_item') && !target.closest('.custom_carousel_arrow')) {
42592
+ if (!target.closest('.slider-preview-media, .custom_video_player, .custom_carousel_arrow')) {
42577
42593
  if (currentFileType === 'image') {
42578
42594
  log.info('[MEDIA_IMAGE_SLIDER] outside click closing slider ' + JSON.stringify({
42579
42595
  channelId: channel.id,
@@ -43010,6 +43026,7 @@ var SliderPopup = function SliderPopup(_ref) {
43010
43026
  })))), isItemLoading(file.id) && file.type === 'image' && (/*#__PURE__*/React__default.createElement(ItemLoadingCont, null, /*#__PURE__*/React__default.createElement(UploadingIcon, {
43011
43027
  color: textOnPrimary
43012
43028
  }))), 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", {
43029
+ className: 'slider-preview-media',
43013
43030
  loading: 'eager',
43014
43031
  decoding: 'async',
43015
43032
  draggable: false,
@@ -43124,7 +43141,7 @@ var IconWrapper = styled.span(_templateObject10$7 || (_templateObject10$7 = _tag
43124
43141
  }, function (props) {
43125
43142
  return props.hideInMobile && "\n @media (max-width: 550px) {\n display: none;\n }\n ";
43126
43143
  });
43127
- 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"])));
43144
+ 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"])));
43128
43145
  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"])));
43129
43146
  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"])));
43130
43147
  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) {
@@ -51060,8 +51077,8 @@ var Message$1 = function Message(_ref) {
51060
51077
  var prevMessageUserID = prevMessage ? getComparableUserId(prevMessage.user) : null;
51061
51078
  var current = moment(message.createdAt).startOf('day');
51062
51079
  var firstMessageInInterval = useMemo(function () {
51063
- 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;
51064
- }, [prevMessage, unreadMessageId, ifLatestAndHasNotPreview]);
51080
+ 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);
51081
+ }, [prevMessage, unreadMessageId, ifLatestAndHasNotPreview, isPinnedMessagesList]);
51065
51082
  var nextMessageUserID = nextMessage ? getComparableUserId(nextMessage.user) : null;
51066
51083
  var nextDay = nextMessage ? moment(nextMessage.createdAt).startOf('day') : null;
51067
51084
  var nextMessageFirstInInterval = !nextMessage || nextDay !== null && nextDay.diff(current, 'days') !== 0 || nextMessage.type === MESSAGE_TYPE.SYSTEM || nextMessageStartsUnreadSection;
@@ -51437,8 +51454,8 @@ var Message$1 = function Message(_ref) {
51437
51454
  if (!nextMessage || nextMessage.type === MESSAGE_TYPE.SYSTEM) {
51438
51455
  spacingBottom = '';
51439
51456
  } else if (nextMessageStartsUnreadSection) {
51440
- spacingBottom = differentUserMessageSpacing || '16px';
51441
- } else if (nextMessageUserID && (nextMessageUserID !== messageUserID || nextMessageFirstInInterval)) {
51457
+ spacingBottom = isPinnedMessagesList ? '0' : differentUserMessageSpacing || '16px';
51458
+ } else if (nextMessageUserID && (nextMessageUserID !== messageUserID || nextMessageFirstInInterval && !isPinnedMessagesList)) {
51442
51459
  spacingBottom = differentUserMessageSpacing || '16px';
51443
51460
  }
51444
51461
  spacingTop = sameUserMessageSpacing || '6px';
@@ -51451,7 +51468,7 @@ var Message$1 = function Message(_ref) {
51451
51468
  bottom: reactionsMargin || spacingBottom,
51452
51469
  top: spacingTop
51453
51470
  };
51454
- }, [nextMessageUserID, messageUserID, nextMessageFirstInInterval, (_message$reactionTota = message.reactionTotals) === null || _message$reactionTota === void 0 ? void 0 : _message$reactionTota.length]);
51471
+ }, [nextMessageUserID, isPinnedMessagesList, messageUserID, nextMessageFirstInInterval, (_message$reactionTota = message.reactionTotals) === null || _message$reactionTota === void 0 ? void 0 : _message$reactionTota.length]);
51455
51472
  return /*#__PURE__*/React__default.createElement(MessageItem, {
51456
51473
  className: 'message_item',
51457
51474
  rtl: ownMessageOnRightSide && !message.incoming,
@@ -52937,7 +52954,7 @@ var MessageList = function MessageList(_ref) {
52937
52954
  isUnreadMessage: false,
52938
52955
  nextMessageStartsUnreadSection: false,
52939
52956
  isHighlighted: false,
52940
- ifLatestAndHasNotPreview: channel.type !== DEFAULT_CHANNEL_TYPE.DIRECT,
52957
+ ifLatestAndHasNotPreview: index === 0,
52941
52958
  registerInMessagesIndex: false,
52942
52959
  isPinnedMessagesList: true
52943
52960
  });
@@ -55057,10 +55074,14 @@ var Emoji$1 = styled.li(_templateObject8$m || (_templateObject8$m = _taggedTempl
55057
55074
  return props.hoverBackgroundColor;
55058
55075
  });
55059
55076
 
55077
+ var isVideoAttachment = function isVideoAttachment(attachment) {
55078
+ var _attachment$data, _attachment$data$type;
55079
+ return attachment.type === attachmentTypes.video || ((_attachment$data = attachment.data) === null || _attachment$data === void 0 ? void 0 : (_attachment$data$type = _attachment$data.type) === null || _attachment$data$type === void 0 ? void 0 : _attachment$data$type.startsWith('video/'));
55080
+ };
55060
55081
  var waitForMediaAttachmentPreparation = function waitForMediaAttachmentPreparation(attachments, preparations) {
55061
55082
  try {
55062
55083
  return Promise.resolve(Promise.all(attachments.filter(function (attachment) {
55063
- return attachment.type === attachmentTypes.image || getOutgoingAttachmentType(attachment) === attachmentTypes.video;
55084
+ return attachment.type === attachmentTypes.image || isVideoAttachment(attachment);
55064
55085
  }).map(function (attachment) {
55065
55086
  return attachment.tid ? preparations.get(attachment.tid) : undefined;
55066
55087
  }))).then(function () {});
@@ -55074,8 +55095,7 @@ var mergePreparedAttachmentPatches = function mergePreparedAttachmentPatches(att
55074
55095
  });
55075
55096
  };
55076
55097
  var getOutgoingAttachmentType = function getOutgoingAttachmentType(attachment) {
55077
- var _attachment$data, _attachment$data$type;
55078
- 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;
55098
+ return attachment.type;
55079
55099
  };
55080
55100
 
55081
55101
  var CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined';
@@ -56506,6 +56526,52 @@ var SettingItem = styled.div(_templateObject9$k || (_templateObject9$k = _tagged
56506
56526
  return props.color;
56507
56527
  });
56508
56528
 
56529
+ var getDraftHandoff = function getDraftHandoff(_ref) {
56530
+ var channelId = _ref.channelId,
56531
+ nextChannelId = _ref.nextChannelId,
56532
+ text = _ref.text,
56533
+ mentionedUsers = _ref.mentionedUsers,
56534
+ messageForReply = _ref.messageForReply,
56535
+ editorState = _ref.editorState,
56536
+ bodyAttributes = _ref.bodyAttributes,
56537
+ attachments = _ref.attachments,
56538
+ viewOnce = _ref.viewOnce;
56539
+ if (!channelId || channelId === nextChannelId) {
56540
+ return null;
56541
+ }
56542
+ if (text.trim() || attachments.length) {
56543
+ return {
56544
+ channelId: channelId,
56545
+ draft: {
56546
+ text: text,
56547
+ mentionedUsers: mentionedUsers,
56548
+ messageForReply: messageForReply,
56549
+ editorState: editorState,
56550
+ bodyAttributes: bodyAttributes,
56551
+ attachments: attachments,
56552
+ viewOnce: viewOnce
56553
+ },
56554
+ persist: true
56555
+ };
56556
+ }
56557
+ if (messageForReply) {
56558
+ return {
56559
+ channelId: channelId,
56560
+ draft: {
56561
+ text: '',
56562
+ mentionedUsers: mentionedUsers,
56563
+ messageForReply: messageForReply,
56564
+ editorState: editorState,
56565
+ bodyAttributes: bodyAttributes,
56566
+ attachments: [],
56567
+ viewOnce: false
56568
+ },
56569
+ persist: false
56570
+ };
56571
+ }
56572
+ return null;
56573
+ };
56574
+
56509
56575
  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;
56510
56576
  function AutoFocusPlugin(_ref) {
56511
56577
  var messageForReply = _ref.messageForReply;
@@ -56570,9 +56636,9 @@ function ClearEditorPlugin(_ref2) {
56570
56636
  function onError(error) {
56571
56637
  log.error(error);
56572
56638
  }
56573
- var prevActiveChannelId;
56574
56639
  var attachmentsUpdate = [];
56575
56640
  var UNSUPPORTED_PASTED_FILE_MESSAGE = 'This file format is not supported.';
56641
+ var useComposerLayoutEffect = CAN_USE_DOM ? useLayoutEffect : useEffect;
56576
56642
  var SendMessageInput = function SendMessageInput(_ref3) {
56577
56643
  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;
56578
56644
  var handleAttachmentSelected = _ref3.handleAttachmentSelected,
@@ -56804,6 +56870,9 @@ var SendMessageInput = function SendMessageInput(_ref3) {
56804
56870
  var _useState30 = useState(areDraftMessagesHydrated()),
56805
56871
  draftsHydrated = _useState30[0],
56806
56872
  setDraftsHydrated = _useState30[1];
56873
+ var _useState31 = useState(activeChannel.id || ''),
56874
+ composerChannelId = _useState31[0],
56875
+ setComposerChannelId = _useState31[1];
56807
56876
  var typingOrRecordingIndicator = useSelector(typingOrRecordingIndicatorArraySelector(activeChannel.id));
56808
56877
  var contactsMap = useSelector(contactsMapSelector);
56809
56878
  var connectionStatus = useSelector(connectionStatusSelector, shallowEqual);
@@ -56820,36 +56889,36 @@ var SendMessageInput = function SendMessageInput(_ref3) {
56820
56889
  var restoringDraftRef = useRef(false);
56821
56890
  var restoredDraftChannelIdRef = useRef(null);
56822
56891
  var isNavigatingChannelRef = useRef(false);
56823
- var _useState31 = useState(),
56824
- realEditorState = _useState31[0],
56825
- setRealEditorState = _useState31[1];
56826
- var _useState32 = useState(null),
56827
- floatingAnchorElem = _useState32[0],
56828
- setFloatingAnchorElem = _useState32[1];
56829
- var _useState33 = useState(false),
56830
- isSmallWidthViewport = _useState33[0],
56831
- setIsSmallWidthViewport = _useState33[1];
56892
+ var _useState32 = useState(),
56893
+ realEditorState = _useState32[0],
56894
+ setRealEditorState = _useState32[1];
56895
+ var _useState33 = useState(null),
56896
+ floatingAnchorElem = _useState33[0],
56897
+ setFloatingAnchorElem = _useState33[1];
56832
56898
  var _useState34 = useState(false),
56833
- isScrolling = _useState34[0],
56834
- setIsScrolling = _useState34[1];
56835
- var _useState35 = useState(null),
56836
- linkPreview = _useState35[0],
56837
- setLinkPreview = _useState35[1];
56899
+ isSmallWidthViewport = _useState34[0],
56900
+ setIsSmallWidthViewport = _useState34[1];
56901
+ var _useState35 = useState(false),
56902
+ isScrolling = _useState35[0],
56903
+ setIsScrolling = _useState35[1];
56838
56904
  var _useState36 = useState(null),
56839
- detectedUrl = _useState36[0],
56840
- setDetectedUrl = _useState36[1];
56841
- var _useState37 = useState(new Set()),
56842
- dismissedUrls = _useState37[0],
56843
- setDismissedUrls = _useState37[1];
56844
- var _useState38 = useState(false),
56845
- isClosingPreview = _useState38[0],
56846
- setIsClosingPreview = _useState38[1];
56905
+ linkPreview = _useState36[0],
56906
+ setLinkPreview = _useState36[1];
56907
+ var _useState37 = useState(null),
56908
+ detectedUrl = _useState37[0],
56909
+ setDetectedUrl = _useState37[1];
56910
+ var _useState38 = useState(new Set()),
56911
+ dismissedUrls = _useState38[0],
56912
+ setDismissedUrls = _useState38[1];
56847
56913
  var _useState39 = useState(false),
56848
- replyLinkPreviewImageFailed = _useState39[0],
56849
- setReplyLinkPreviewImageFailed = _useState39[1];
56914
+ isClosingPreview = _useState39[0],
56915
+ setIsClosingPreview = _useState39[1];
56850
56916
  var _useState40 = useState(false),
56851
- linkPreviewImageFailed = _useState40[0],
56852
- setLinkPreviewImageFailed = _useState40[1];
56917
+ replyLinkPreviewImageFailed = _useState40[0],
56918
+ setReplyLinkPreviewImageFailed = _useState40[1];
56919
+ var _useState41 = useState(false),
56920
+ linkPreviewImageFailed = _useState41[0],
56921
+ setLinkPreviewImageFailed = _useState41[1];
56853
56922
  var addAttachmentByMenu = showChooseFileAttachment && showChooseMediaAttachment;
56854
56923
  var linkify = new LinkifyIt();
56855
56924
  var oGMetadata = useSelector(function (state) {
@@ -56860,8 +56929,51 @@ var SendMessageInput = function SendMessageInput(_ref3) {
56860
56929
  return setDraftsHydrated(areDraftMessagesHydrated());
56861
56930
  });
56862
56931
  }, []);
56932
+ useComposerLayoutEffect(function () {
56933
+ var nextChannelId = activeChannel.id || '';
56934
+ if (composerChannelId === nextChannelId) {
56935
+ return;
56936
+ }
56937
+ if (draftsHydrated) {
56938
+ var handoff = getDraftHandoff({
56939
+ channelId: composerChannelId,
56940
+ nextChannelId: nextChannelId,
56941
+ text: messageText,
56942
+ mentionedUsers: mentionedUsers,
56943
+ messageForReply: messageForReply,
56944
+ editorState: realEditorState,
56945
+ bodyAttributes: messageBodyAttributes,
56946
+ attachments: attachments,
56947
+ viewOnce: viewOnce
56948
+ });
56949
+ if (handoff) {
56950
+ setDraftMessageToMap(handoff.channelId, handoff.draft, {
56951
+ persist: handoff.persist
56952
+ });
56953
+ }
56954
+ }
56955
+ restoringDraftRef.current = false;
56956
+ restoredDraftChannelIdRef.current = null;
56957
+ isNavigatingChannelRef.current = !!messageForReply;
56958
+ setComposerChannelId(nextChannelId);
56959
+ setMessageText('');
56960
+ setEditMessageText('');
56961
+ setRestoredEditMessage(null);
56962
+ setMessageBodyAttributes([]);
56963
+ setMentionedUsers([]);
56964
+ setAttachments([]);
56965
+ setViewOnce(false);
56966
+ setSendMessageIsActive(false);
56967
+ setShouldClearEditor({
56968
+ clear: true
56969
+ });
56970
+ attachmentsUpdate = [];
56971
+ clearTimeout(typingTimout);
56972
+ dispatch(setMessageForReplyAC(null));
56973
+ dispatch(setMessageToEditAC(null));
56974
+ }, [activeChannel.id, composerChannelId]);
56863
56975
  useEffect(function () {
56864
- if (!draftsHydrated || !activeChannel.id) {
56976
+ if (!draftsHydrated || !activeChannel.id || composerChannelId !== activeChannel.id) {
56865
56977
  return;
56866
56978
  }
56867
56979
  var draftMessage = getDraftMessageFromMap(activeChannel.id);
@@ -56895,7 +57007,27 @@ var SendMessageInput = function SendMessageInput(_ref3) {
56895
57007
  draftMessage: draftMessage
56896
57008
  });
56897
57009
  restoredDraftChannelIdRef.current = activeChannel.id;
56898
- }, [draftsHydrated, activeChannel.id]);
57010
+ }, [draftsHydrated, activeChannel.id, composerChannelId]);
57011
+ var setComposerMessageText = useCallback(function (text) {
57012
+ if (composerChannelId === activeChannel.id) {
57013
+ setMessageText(text);
57014
+ }
57015
+ }, [activeChannel.id, composerChannelId]);
57016
+ var setComposerEditMessageText = useCallback(function (text) {
57017
+ if (composerChannelId === activeChannel.id) {
57018
+ setEditMessageText(text);
57019
+ }
57020
+ }, [activeChannel.id, composerChannelId]);
57021
+ var setComposerMessageBodyAttributes = useCallback(function (attributes) {
57022
+ if (composerChannelId === activeChannel.id) {
57023
+ setMessageBodyAttributes(attributes);
57024
+ }
57025
+ }, [activeChannel.id, composerChannelId]);
57026
+ var setComposerMentionedUsers = useCallback(function (users) {
57027
+ if (composerChannelId === activeChannel.id) {
57028
+ setMentionedUsers(users);
57029
+ }
57030
+ }, [activeChannel.id, composerChannelId]);
56899
57031
  useEffect(function () {
56900
57032
  setReplyLinkPreviewImageFailed(false);
56901
57033
  }, [messageForReply === null || messageForReply === void 0 ? void 0 : messageForReply.id, messageForReply === null || messageForReply === void 0 ? void 0 : messageForReply.tid]);
@@ -57547,9 +57679,11 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57547
57679
  dispatch(clearSelectedMessagesAC());
57548
57680
  };
57549
57681
  var handleSetMentionMember = function handleSetMentionMember(mentionMember) {
57550
- setMentionedUsers(function (prevState) {
57551
- return [].concat(prevState, [mentionMember]);
57552
- });
57682
+ if (composerChannelId === activeChannel.id) {
57683
+ setMentionedUsers(function (prevState) {
57684
+ return [].concat(prevState, [mentionMember]);
57685
+ });
57686
+ }
57553
57687
  };
57554
57688
  var createComposePreviewUrl = function createComposePreviewUrl(attachmentTid, blob) {
57555
57689
  var url = URL.createObjectURL(blob);
@@ -57577,7 +57711,7 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57577
57711
  if (fileType === 'video') {
57578
57712
  beginVideoPreparation(tid, file);
57579
57713
  }
57580
- var type = fileType === 'video' && (!customUploader || isMediaAttachment) ? 'video' : isMediaAttachment && fileType === 'image' ? 'image' : 'file';
57714
+ var type = isMediaAttachment && fileType === 'video' ? attachmentTypes.video : isMediaAttachment && fileType === 'image' ? attachmentTypes.image : attachmentTypes.file;
57581
57715
  var attachment = _extends({
57582
57716
  data: file,
57583
57717
  name: file.name,
@@ -57885,59 +58019,6 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57885
58019
  };
57886
58020
  }, [isSmallWidthViewport]);
57887
58021
  useEffect(function () {
57888
- if (prevActiveChannelId && activeChannel.id && prevActiveChannelId !== activeChannel.id) {
57889
- setMessageText('');
57890
- if (messageForReply) {
57891
- isNavigatingChannelRef.current = true;
57892
- handleCloseReply(true);
57893
- }
57894
- setAttachments([]);
57895
- attachmentsUpdate = [];
57896
- handleCloseEditMode(!!messageToEdit);
57897
- clearTimeout(typingTimout);
57898
- var draftMessage = getDraftMessageFromMap(activeChannel.id);
57899
- if (draftMessage) {
57900
- restoringDraftRef.current = true;
57901
- if (draftMessage.messageToEdit) {
57902
- var _ref6, _draftMessage$editMes2, _draftMessage$editBod2, _draftMessage$mention2;
57903
- var restoredText = (_ref6 = (_draftMessage$editMes2 = draftMessage.editMessageText) != null ? _draftMessage$editMes2 : draftMessage.messageToEdit.body) != null ? _ref6 : '';
57904
- var restoredEdit = _extends({}, draftMessage.messageToEdit, {
57905
- body: restoredText,
57906
- bodyAttributes: (_draftMessage$editBod2 = draftMessage.editBodyAttributes) != null ? _draftMessage$editBod2 : draftMessage.messageToEdit.bodyAttributes,
57907
- mentionedUsers: (_draftMessage$mention2 = draftMessage.mentionedUsers) != null ? _draftMessage$mention2 : draftMessage.messageToEdit.mentionedUsers
57908
- });
57909
- setEditMessageText(restoredText);
57910
- setMessageBodyAttributes(restoredEdit.bodyAttributes || []);
57911
- setMentionedUsers(restoredEdit.mentionedUsers || []);
57912
- setRestoredEditMessage(restoredEdit);
57913
- dispatch(setMessageToEditAC(draftMessage.messageToEdit));
57914
- restoredDraftChannelIdRef.current = activeChannel.id;
57915
- }
57916
- if (!draftMessage.messageToEdit) {
57917
- if (draftMessage.messageForReply) {
57918
- dispatch(setMessageForReplyAC(draftMessage.messageForReply));
57919
- }
57920
- setMessageText(draftMessage.text);
57921
- setMentionedUsers(draftMessage.mentionedUsers);
57922
- setAttachments(draftMessage.attachments || []);
57923
- setViewOnce(!!draftMessage.viewOnce);
57924
- restoredDraftChannelIdRef.current = activeChannel.id;
57925
- setShouldClearEditor({
57926
- clear: true,
57927
- draftMessage: draftMessage
57928
- });
57929
- }
57930
- } else {
57931
- setMentionedUsers([]);
57932
- setShouldClearEditor({
57933
- clear: true,
57934
- draftMessage: draftMessage
57935
- });
57936
- }
57937
- }
57938
- if (activeChannel.id) {
57939
- prevActiveChannelId = activeChannel.id;
57940
- }
57941
58022
  if (activeChannel.id && membersHasNext === undefined && !(activeChannel.type === DEFAULT_CHANNEL_TYPE.DIRECT && activeChannel.memberCount === 2)) {
57942
58023
  dispatch(getMembersAC(activeChannel.id));
57943
58024
  }
@@ -57946,6 +58027,9 @@ var SendMessageInput = function SendMessageInput(_ref3) {
57946
58027
  if (!draftsHydrated) {
57947
58028
  return;
57948
58029
  }
58030
+ if (!activeChannel.id || composerChannelId !== activeChannel.id) {
58031
+ return;
58032
+ }
57949
58033
  if (restoringDraftRef.current) {
57950
58034
  restoringDraftRef.current = false;
57951
58035
  return;
@@ -58032,9 +58116,9 @@ var SendMessageInput = function SendMessageInput(_ref3) {
58032
58116
  document.body.removeAttribute('onbeforeunload');
58033
58117
  }
58034
58118
  }
58035
- }, [messageText, attachments, editMessageText, readyVideoAttachments, messageBodyAttributes, messageToEdit, viewOnce, draftsHydrated]);
58119
+ }, [messageText, attachments, editMessageText, readyVideoAttachments, messageBodyAttributes, messageToEdit, viewOnce, draftsHydrated, activeChannel.id, composerChannelId]);
58036
58120
  useDidUpdate(function () {
58037
- if (!messageToEdit && mentionedUsers && mentionedUsers.length) {
58121
+ if (composerChannelId === activeChannel.id && !messageToEdit && mentionedUsers && mentionedUsers.length) {
58038
58122
  setDraftMessageToMap(activeChannel.id, {
58039
58123
  text: messageText,
58040
58124
  mentionedUsers: mentionedUsers,
@@ -58046,7 +58130,7 @@ var SendMessageInput = function SendMessageInput(_ref3) {
58046
58130
  persist: !!(messageText.trim() || attachments.length)
58047
58131
  });
58048
58132
  }
58049
- }, [mentionedUsers]);
58133
+ }, [mentionedUsers, activeChannel.id, composerChannelId]);
58050
58134
  useDidUpdate(function () {
58051
58135
  var _getAudioRecordingFro;
58052
58136
  if (handleAttachmentSelected) {
@@ -58093,6 +58177,9 @@ var SendMessageInput = function SendMessageInput(_ref3) {
58093
58177
  });
58094
58178
  useDidUpdate(function () {
58095
58179
  var _draftMessagesMap$act;
58180
+ if (composerChannelId !== activeChannel.id) {
58181
+ return;
58182
+ }
58096
58183
  var persistedReply = (_draftMessagesMap$act = draftMessagesMap[activeChannel.id]) === null || _draftMessagesMap$act === void 0 ? void 0 : _draftMessagesMap$act.messageForReply;
58097
58184
  if (isNavigatingChannelRef.current) {
58098
58185
  isNavigatingChannelRef.current = false;
@@ -58120,7 +58207,7 @@ var SendMessageInput = function SendMessageInput(_ref3) {
58120
58207
  if (messageContRef && messageContRef.current) {
58121
58208
  dispatch(setSendMessageInputHeightAC(messageContRef.current.getBoundingClientRect().height));
58122
58209
  }
58123
- }, [messageForReply]);
58210
+ }, [messageForReply, activeChannel.id, composerChannelId]);
58124
58211
  useDidUpdate(function () {
58125
58212
  if (messageToEdit) {
58126
58213
  if (messageForReply) {
@@ -58153,7 +58240,6 @@ var SendMessageInput = function SendMessageInput(_ref3) {
58153
58240
  if (inputHeightTimeout) {
58154
58241
  clearTimeout(inputHeightTimeout);
58155
58242
  }
58156
- prevActiveChannelId = undefined;
58157
58243
  document.removeEventListener('mousedown', handleClick);
58158
58244
  if (messageContRef && messageContRef.current) {
58159
58245
  messageContRef.current.removeEventListener('paste', handlePastAttachments);
@@ -58567,11 +58653,11 @@ var SendMessageInput = function SendMessageInput(_ref3) {
58567
58653
  draftMessage: (restoredEditMessage === null || restoredEditMessage === void 0 ? void 0 : restoredEditMessage.id) === (messageToEdit === null || messageToEdit === void 0 ? void 0 : messageToEdit.id) ? restoredEditMessage : null,
58568
58654
  contactsMap: contactsMap,
58569
58655
  getFromContacts: getFromContacts,
58570
- setMentionedMember: setMentionedUsers
58656
+ setMentionedMember: setComposerMentionedUsers
58571
58657
  }), /*#__PURE__*/React__default.createElement(FormatMessagePlugin, {
58572
58658
  editorState: realEditorState,
58573
- setMessageBodyAttributes: setMessageBodyAttributes,
58574
- setMessageText: messageToEdit ? setEditMessageText : setMessageText,
58659
+ setMessageBodyAttributes: setComposerMessageBodyAttributes,
58660
+ setMessageText: messageToEdit ? setComposerEditMessageText : setComposerMessageText,
58575
58661
  messageToEdit: messageToEdit,
58576
58662
  activeChannelMembers: activeChannelMembers,
58577
58663
  contactsMap: contactsMap,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sceyt-chat-react-uikit",
3
- "version": "1.9.0-beta.14",
3
+ "version": "1.9.0-beta.16",
4
4
  "description": "Interactive React UI Components for Sceyt Chat.",
5
5
  "author": "Sceyt",
6
6
  "license": "MIT",