sceyt-chat-react-uikit 1.9.0-beta.15 → 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.
- package/components/SendMessageInput/draftOwnership.d.ts +24 -0
- package/index.js +195 -110
- package/index.modern.js +195 -110
- package/package.json +1 -1
|
@@ -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) :
|
|
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 =
|
|
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 =
|
|
29583
|
+
_context28.n = 7;
|
|
29576
29584
|
return effects.call(getChannelFromMap, channelId);
|
|
29577
|
-
case
|
|
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.
|
|
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
|
|
29595
|
+
case 10:
|
|
29588
29596
|
return _context28.a(2);
|
|
29589
29597
|
}
|
|
29590
|
-
}, _marked27$1, null, [[0,
|
|
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(
|
|
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
|
|
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
|
|
|
@@ -55078,10 +55094,14 @@ var Emoji$1 = styled__default.li(_templateObject8$m || (_templateObject8$m = _ta
|
|
|
55078
55094
|
return props.hoverBackgroundColor;
|
|
55079
55095
|
});
|
|
55080
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
|
+
};
|
|
55081
55101
|
var waitForMediaAttachmentPreparation = function waitForMediaAttachmentPreparation(attachments, preparations) {
|
|
55082
55102
|
try {
|
|
55083
55103
|
return Promise.resolve(Promise.all(attachments.filter(function (attachment) {
|
|
55084
|
-
return attachment.type === attachmentTypes.image ||
|
|
55104
|
+
return attachment.type === attachmentTypes.image || isVideoAttachment(attachment);
|
|
55085
55105
|
}).map(function (attachment) {
|
|
55086
55106
|
return attachment.tid ? preparations.get(attachment.tid) : undefined;
|
|
55087
55107
|
}))).then(function () {});
|
|
@@ -55095,8 +55115,7 @@ var mergePreparedAttachmentPatches = function mergePreparedAttachmentPatches(att
|
|
|
55095
55115
|
});
|
|
55096
55116
|
};
|
|
55097
55117
|
var getOutgoingAttachmentType = function getOutgoingAttachmentType(attachment) {
|
|
55098
|
-
|
|
55099
|
-
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;
|
|
55100
55119
|
};
|
|
55101
55120
|
|
|
55102
55121
|
var CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined';
|
|
@@ -56527,6 +56546,52 @@ var SettingItem = styled__default.div(_templateObject9$k || (_templateObject9$k
|
|
|
56527
56546
|
return props.color;
|
|
56528
56547
|
});
|
|
56529
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
|
+
|
|
56530
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;
|
|
56531
56596
|
function AutoFocusPlugin(_ref) {
|
|
56532
56597
|
var messageForReply = _ref.messageForReply;
|
|
@@ -56591,9 +56656,9 @@ function ClearEditorPlugin(_ref2) {
|
|
|
56591
56656
|
function onError(error) {
|
|
56592
56657
|
log.error(error);
|
|
56593
56658
|
}
|
|
56594
|
-
var prevActiveChannelId;
|
|
56595
56659
|
var attachmentsUpdate = [];
|
|
56596
56660
|
var UNSUPPORTED_PASTED_FILE_MESSAGE = 'This file format is not supported.';
|
|
56661
|
+
var useComposerLayoutEffect = CAN_USE_DOM ? React.useLayoutEffect : React.useEffect;
|
|
56597
56662
|
var SendMessageInput = function SendMessageInput(_ref3) {
|
|
56598
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;
|
|
56599
56664
|
var handleAttachmentSelected = _ref3.handleAttachmentSelected,
|
|
@@ -56825,6 +56890,9 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
56825
56890
|
var _useState30 = React.useState(areDraftMessagesHydrated()),
|
|
56826
56891
|
draftsHydrated = _useState30[0],
|
|
56827
56892
|
setDraftsHydrated = _useState30[1];
|
|
56893
|
+
var _useState31 = React.useState(activeChannel.id || ''),
|
|
56894
|
+
composerChannelId = _useState31[0],
|
|
56895
|
+
setComposerChannelId = _useState31[1];
|
|
56828
56896
|
var typingOrRecordingIndicator = useSelector(typingOrRecordingIndicatorArraySelector(activeChannel.id));
|
|
56829
56897
|
var contactsMap = useSelector(contactsMapSelector);
|
|
56830
56898
|
var connectionStatus = useSelector(connectionStatusSelector, reactRedux.shallowEqual);
|
|
@@ -56841,36 +56909,36 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
56841
56909
|
var restoringDraftRef = React.useRef(false);
|
|
56842
56910
|
var restoredDraftChannelIdRef = React.useRef(null);
|
|
56843
56911
|
var isNavigatingChannelRef = React.useRef(false);
|
|
56844
|
-
var
|
|
56845
|
-
realEditorState =
|
|
56846
|
-
setRealEditorState =
|
|
56847
|
-
var
|
|
56848
|
-
floatingAnchorElem =
|
|
56849
|
-
setFloatingAnchorElem =
|
|
56850
|
-
var _useState33 = React.useState(false),
|
|
56851
|
-
isSmallWidthViewport = _useState33[0],
|
|
56852
|
-
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];
|
|
56853
56918
|
var _useState34 = React.useState(false),
|
|
56854
|
-
|
|
56855
|
-
|
|
56856
|
-
var _useState35 = React.useState(
|
|
56857
|
-
|
|
56858
|
-
|
|
56919
|
+
isSmallWidthViewport = _useState34[0],
|
|
56920
|
+
setIsSmallWidthViewport = _useState34[1];
|
|
56921
|
+
var _useState35 = React.useState(false),
|
|
56922
|
+
isScrolling = _useState35[0],
|
|
56923
|
+
setIsScrolling = _useState35[1];
|
|
56859
56924
|
var _useState36 = React.useState(null),
|
|
56860
|
-
|
|
56861
|
-
|
|
56862
|
-
var _useState37 = React.useState(
|
|
56863
|
-
|
|
56864
|
-
|
|
56865
|
-
var _useState38 = React.useState(
|
|
56866
|
-
|
|
56867
|
-
|
|
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];
|
|
56868
56933
|
var _useState39 = React.useState(false),
|
|
56869
|
-
|
|
56870
|
-
|
|
56934
|
+
isClosingPreview = _useState39[0],
|
|
56935
|
+
setIsClosingPreview = _useState39[1];
|
|
56871
56936
|
var _useState40 = React.useState(false),
|
|
56872
|
-
|
|
56873
|
-
|
|
56937
|
+
replyLinkPreviewImageFailed = _useState40[0],
|
|
56938
|
+
setReplyLinkPreviewImageFailed = _useState40[1];
|
|
56939
|
+
var _useState41 = React.useState(false),
|
|
56940
|
+
linkPreviewImageFailed = _useState41[0],
|
|
56941
|
+
setLinkPreviewImageFailed = _useState41[1];
|
|
56874
56942
|
var addAttachmentByMenu = showChooseFileAttachment && showChooseMediaAttachment;
|
|
56875
56943
|
var linkify = new LinkifyIt();
|
|
56876
56944
|
var oGMetadata = useSelector(function (state) {
|
|
@@ -56881,8 +56949,51 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
56881
56949
|
return setDraftsHydrated(areDraftMessagesHydrated());
|
|
56882
56950
|
});
|
|
56883
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]);
|
|
56884
56995
|
React.useEffect(function () {
|
|
56885
|
-
if (!draftsHydrated || !activeChannel.id) {
|
|
56996
|
+
if (!draftsHydrated || !activeChannel.id || composerChannelId !== activeChannel.id) {
|
|
56886
56997
|
return;
|
|
56887
56998
|
}
|
|
56888
56999
|
var draftMessage = getDraftMessageFromMap(activeChannel.id);
|
|
@@ -56916,7 +57027,27 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
56916
57027
|
draftMessage: draftMessage
|
|
56917
57028
|
});
|
|
56918
57029
|
restoredDraftChannelIdRef.current = activeChannel.id;
|
|
56919
|
-
}, [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]);
|
|
56920
57051
|
React.useEffect(function () {
|
|
56921
57052
|
setReplyLinkPreviewImageFailed(false);
|
|
56922
57053
|
}, [messageForReply === null || messageForReply === void 0 ? void 0 : messageForReply.id, messageForReply === null || messageForReply === void 0 ? void 0 : messageForReply.tid]);
|
|
@@ -57568,9 +57699,11 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
57568
57699
|
dispatch(clearSelectedMessagesAC());
|
|
57569
57700
|
};
|
|
57570
57701
|
var handleSetMentionMember = function handleSetMentionMember(mentionMember) {
|
|
57571
|
-
|
|
57572
|
-
|
|
57573
|
-
|
|
57702
|
+
if (composerChannelId === activeChannel.id) {
|
|
57703
|
+
setMentionedUsers(function (prevState) {
|
|
57704
|
+
return [].concat(prevState, [mentionMember]);
|
|
57705
|
+
});
|
|
57706
|
+
}
|
|
57574
57707
|
};
|
|
57575
57708
|
var createComposePreviewUrl = function createComposePreviewUrl(attachmentTid, blob) {
|
|
57576
57709
|
var url = URL.createObjectURL(blob);
|
|
@@ -57598,7 +57731,7 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
57598
57731
|
if (fileType === 'video') {
|
|
57599
57732
|
beginVideoPreparation(tid, file);
|
|
57600
57733
|
}
|
|
57601
|
-
var type = fileType === 'video'
|
|
57734
|
+
var type = isMediaAttachment && fileType === 'video' ? attachmentTypes.video : isMediaAttachment && fileType === 'image' ? attachmentTypes.image : attachmentTypes.file;
|
|
57602
57735
|
var attachment = _extends({
|
|
57603
57736
|
data: file,
|
|
57604
57737
|
name: file.name,
|
|
@@ -57906,59 +58039,6 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
57906
58039
|
};
|
|
57907
58040
|
}, [isSmallWidthViewport]);
|
|
57908
58041
|
React.useEffect(function () {
|
|
57909
|
-
if (prevActiveChannelId && activeChannel.id && prevActiveChannelId !== activeChannel.id) {
|
|
57910
|
-
setMessageText('');
|
|
57911
|
-
if (messageForReply) {
|
|
57912
|
-
isNavigatingChannelRef.current = true;
|
|
57913
|
-
handleCloseReply(true);
|
|
57914
|
-
}
|
|
57915
|
-
setAttachments([]);
|
|
57916
|
-
attachmentsUpdate = [];
|
|
57917
|
-
handleCloseEditMode(!!messageToEdit);
|
|
57918
|
-
clearTimeout(typingTimout);
|
|
57919
|
-
var draftMessage = getDraftMessageFromMap(activeChannel.id);
|
|
57920
|
-
if (draftMessage) {
|
|
57921
|
-
restoringDraftRef.current = true;
|
|
57922
|
-
if (draftMessage.messageToEdit) {
|
|
57923
|
-
var _ref6, _draftMessage$editMes2, _draftMessage$editBod2, _draftMessage$mention2;
|
|
57924
|
-
var restoredText = (_ref6 = (_draftMessage$editMes2 = draftMessage.editMessageText) != null ? _draftMessage$editMes2 : draftMessage.messageToEdit.body) != null ? _ref6 : '';
|
|
57925
|
-
var restoredEdit = _extends({}, draftMessage.messageToEdit, {
|
|
57926
|
-
body: restoredText,
|
|
57927
|
-
bodyAttributes: (_draftMessage$editBod2 = draftMessage.editBodyAttributes) != null ? _draftMessage$editBod2 : draftMessage.messageToEdit.bodyAttributes,
|
|
57928
|
-
mentionedUsers: (_draftMessage$mention2 = draftMessage.mentionedUsers) != null ? _draftMessage$mention2 : draftMessage.messageToEdit.mentionedUsers
|
|
57929
|
-
});
|
|
57930
|
-
setEditMessageText(restoredText);
|
|
57931
|
-
setMessageBodyAttributes(restoredEdit.bodyAttributes || []);
|
|
57932
|
-
setMentionedUsers(restoredEdit.mentionedUsers || []);
|
|
57933
|
-
setRestoredEditMessage(restoredEdit);
|
|
57934
|
-
dispatch(setMessageToEditAC(draftMessage.messageToEdit));
|
|
57935
|
-
restoredDraftChannelIdRef.current = activeChannel.id;
|
|
57936
|
-
}
|
|
57937
|
-
if (!draftMessage.messageToEdit) {
|
|
57938
|
-
if (draftMessage.messageForReply) {
|
|
57939
|
-
dispatch(setMessageForReplyAC(draftMessage.messageForReply));
|
|
57940
|
-
}
|
|
57941
|
-
setMessageText(draftMessage.text);
|
|
57942
|
-
setMentionedUsers(draftMessage.mentionedUsers);
|
|
57943
|
-
setAttachments(draftMessage.attachments || []);
|
|
57944
|
-
setViewOnce(!!draftMessage.viewOnce);
|
|
57945
|
-
restoredDraftChannelIdRef.current = activeChannel.id;
|
|
57946
|
-
setShouldClearEditor({
|
|
57947
|
-
clear: true,
|
|
57948
|
-
draftMessage: draftMessage
|
|
57949
|
-
});
|
|
57950
|
-
}
|
|
57951
|
-
} else {
|
|
57952
|
-
setMentionedUsers([]);
|
|
57953
|
-
setShouldClearEditor({
|
|
57954
|
-
clear: true,
|
|
57955
|
-
draftMessage: draftMessage
|
|
57956
|
-
});
|
|
57957
|
-
}
|
|
57958
|
-
}
|
|
57959
|
-
if (activeChannel.id) {
|
|
57960
|
-
prevActiveChannelId = activeChannel.id;
|
|
57961
|
-
}
|
|
57962
58042
|
if (activeChannel.id && membersHasNext === undefined && !(activeChannel.type === DEFAULT_CHANNEL_TYPE.DIRECT && activeChannel.memberCount === 2)) {
|
|
57963
58043
|
dispatch(getMembersAC(activeChannel.id));
|
|
57964
58044
|
}
|
|
@@ -57967,6 +58047,9 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
57967
58047
|
if (!draftsHydrated) {
|
|
57968
58048
|
return;
|
|
57969
58049
|
}
|
|
58050
|
+
if (!activeChannel.id || composerChannelId !== activeChannel.id) {
|
|
58051
|
+
return;
|
|
58052
|
+
}
|
|
57970
58053
|
if (restoringDraftRef.current) {
|
|
57971
58054
|
restoringDraftRef.current = false;
|
|
57972
58055
|
return;
|
|
@@ -58053,9 +58136,9 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
58053
58136
|
document.body.removeAttribute('onbeforeunload');
|
|
58054
58137
|
}
|
|
58055
58138
|
}
|
|
58056
|
-
}, [messageText, attachments, editMessageText, readyVideoAttachments, messageBodyAttributes, messageToEdit, viewOnce, draftsHydrated]);
|
|
58139
|
+
}, [messageText, attachments, editMessageText, readyVideoAttachments, messageBodyAttributes, messageToEdit, viewOnce, draftsHydrated, activeChannel.id, composerChannelId]);
|
|
58057
58140
|
useDidUpdate(function () {
|
|
58058
|
-
if (!messageToEdit && mentionedUsers && mentionedUsers.length) {
|
|
58141
|
+
if (composerChannelId === activeChannel.id && !messageToEdit && mentionedUsers && mentionedUsers.length) {
|
|
58059
58142
|
setDraftMessageToMap(activeChannel.id, {
|
|
58060
58143
|
text: messageText,
|
|
58061
58144
|
mentionedUsers: mentionedUsers,
|
|
@@ -58067,7 +58150,7 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
58067
58150
|
persist: !!(messageText.trim() || attachments.length)
|
|
58068
58151
|
});
|
|
58069
58152
|
}
|
|
58070
|
-
}, [mentionedUsers]);
|
|
58153
|
+
}, [mentionedUsers, activeChannel.id, composerChannelId]);
|
|
58071
58154
|
useDidUpdate(function () {
|
|
58072
58155
|
var _getAudioRecordingFro;
|
|
58073
58156
|
if (handleAttachmentSelected) {
|
|
@@ -58114,6 +58197,9 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
58114
58197
|
});
|
|
58115
58198
|
useDidUpdate(function () {
|
|
58116
58199
|
var _draftMessagesMap$act;
|
|
58200
|
+
if (composerChannelId !== activeChannel.id) {
|
|
58201
|
+
return;
|
|
58202
|
+
}
|
|
58117
58203
|
var persistedReply = (_draftMessagesMap$act = draftMessagesMap[activeChannel.id]) === null || _draftMessagesMap$act === void 0 ? void 0 : _draftMessagesMap$act.messageForReply;
|
|
58118
58204
|
if (isNavigatingChannelRef.current) {
|
|
58119
58205
|
isNavigatingChannelRef.current = false;
|
|
@@ -58141,7 +58227,7 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
58141
58227
|
if (messageContRef && messageContRef.current) {
|
|
58142
58228
|
dispatch(setSendMessageInputHeightAC(messageContRef.current.getBoundingClientRect().height));
|
|
58143
58229
|
}
|
|
58144
|
-
}, [messageForReply]);
|
|
58230
|
+
}, [messageForReply, activeChannel.id, composerChannelId]);
|
|
58145
58231
|
useDidUpdate(function () {
|
|
58146
58232
|
if (messageToEdit) {
|
|
58147
58233
|
if (messageForReply) {
|
|
@@ -58174,7 +58260,6 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
58174
58260
|
if (inputHeightTimeout) {
|
|
58175
58261
|
clearTimeout(inputHeightTimeout);
|
|
58176
58262
|
}
|
|
58177
|
-
prevActiveChannelId = undefined;
|
|
58178
58263
|
document.removeEventListener('mousedown', handleClick);
|
|
58179
58264
|
if (messageContRef && messageContRef.current) {
|
|
58180
58265
|
messageContRef.current.removeEventListener('paste', handlePastAttachments);
|
|
@@ -58588,11 +58673,11 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
58588
58673
|
draftMessage: (restoredEditMessage === null || restoredEditMessage === void 0 ? void 0 : restoredEditMessage.id) === (messageToEdit === null || messageToEdit === void 0 ? void 0 : messageToEdit.id) ? restoredEditMessage : null,
|
|
58589
58674
|
contactsMap: contactsMap,
|
|
58590
58675
|
getFromContacts: getFromContacts,
|
|
58591
|
-
setMentionedMember:
|
|
58676
|
+
setMentionedMember: setComposerMentionedUsers
|
|
58592
58677
|
}), /*#__PURE__*/React__default.createElement(FormatMessagePlugin, {
|
|
58593
58678
|
editorState: realEditorState,
|
|
58594
|
-
setMessageBodyAttributes:
|
|
58595
|
-
setMessageText: messageToEdit ?
|
|
58679
|
+
setMessageBodyAttributes: setComposerMessageBodyAttributes,
|
|
58680
|
+
setMessageText: messageToEdit ? setComposerEditMessageText : setComposerMessageText,
|
|
58596
58681
|
messageToEdit: messageToEdit,
|
|
58597
58682
|
activeChannelMembers: activeChannelMembers,
|
|
58598
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) :
|
|
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 =
|
|
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 =
|
|
29563
|
+
_context28.n = 7;
|
|
29556
29564
|
return call(getChannelFromMap, channelId);
|
|
29557
|
-
case
|
|
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.
|
|
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
|
|
29575
|
+
case 10:
|
|
29568
29576
|
return _context28.a(2);
|
|
29569
29577
|
}
|
|
29570
|
-
}, _marked27$1, null, [[0,
|
|
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(
|
|
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
|
|
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
|
|
|
@@ -55058,10 +55074,14 @@ var Emoji$1 = styled.li(_templateObject8$m || (_templateObject8$m = _taggedTempl
|
|
|
55058
55074
|
return props.hoverBackgroundColor;
|
|
55059
55075
|
});
|
|
55060
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
|
+
};
|
|
55061
55081
|
var waitForMediaAttachmentPreparation = function waitForMediaAttachmentPreparation(attachments, preparations) {
|
|
55062
55082
|
try {
|
|
55063
55083
|
return Promise.resolve(Promise.all(attachments.filter(function (attachment) {
|
|
55064
|
-
return attachment.type === attachmentTypes.image ||
|
|
55084
|
+
return attachment.type === attachmentTypes.image || isVideoAttachment(attachment);
|
|
55065
55085
|
}).map(function (attachment) {
|
|
55066
55086
|
return attachment.tid ? preparations.get(attachment.tid) : undefined;
|
|
55067
55087
|
}))).then(function () {});
|
|
@@ -55075,8 +55095,7 @@ var mergePreparedAttachmentPatches = function mergePreparedAttachmentPatches(att
|
|
|
55075
55095
|
});
|
|
55076
55096
|
};
|
|
55077
55097
|
var getOutgoingAttachmentType = function getOutgoingAttachmentType(attachment) {
|
|
55078
|
-
|
|
55079
|
-
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;
|
|
55080
55099
|
};
|
|
55081
55100
|
|
|
55082
55101
|
var CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined';
|
|
@@ -56507,6 +56526,52 @@ var SettingItem = styled.div(_templateObject9$k || (_templateObject9$k = _tagged
|
|
|
56507
56526
|
return props.color;
|
|
56508
56527
|
});
|
|
56509
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
|
+
|
|
56510
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;
|
|
56511
56576
|
function AutoFocusPlugin(_ref) {
|
|
56512
56577
|
var messageForReply = _ref.messageForReply;
|
|
@@ -56571,9 +56636,9 @@ function ClearEditorPlugin(_ref2) {
|
|
|
56571
56636
|
function onError(error) {
|
|
56572
56637
|
log.error(error);
|
|
56573
56638
|
}
|
|
56574
|
-
var prevActiveChannelId;
|
|
56575
56639
|
var attachmentsUpdate = [];
|
|
56576
56640
|
var UNSUPPORTED_PASTED_FILE_MESSAGE = 'This file format is not supported.';
|
|
56641
|
+
var useComposerLayoutEffect = CAN_USE_DOM ? useLayoutEffect : useEffect;
|
|
56577
56642
|
var SendMessageInput = function SendMessageInput(_ref3) {
|
|
56578
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;
|
|
56579
56644
|
var handleAttachmentSelected = _ref3.handleAttachmentSelected,
|
|
@@ -56805,6 +56870,9 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
56805
56870
|
var _useState30 = useState(areDraftMessagesHydrated()),
|
|
56806
56871
|
draftsHydrated = _useState30[0],
|
|
56807
56872
|
setDraftsHydrated = _useState30[1];
|
|
56873
|
+
var _useState31 = useState(activeChannel.id || ''),
|
|
56874
|
+
composerChannelId = _useState31[0],
|
|
56875
|
+
setComposerChannelId = _useState31[1];
|
|
56808
56876
|
var typingOrRecordingIndicator = useSelector(typingOrRecordingIndicatorArraySelector(activeChannel.id));
|
|
56809
56877
|
var contactsMap = useSelector(contactsMapSelector);
|
|
56810
56878
|
var connectionStatus = useSelector(connectionStatusSelector, shallowEqual);
|
|
@@ -56821,36 +56889,36 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
56821
56889
|
var restoringDraftRef = useRef(false);
|
|
56822
56890
|
var restoredDraftChannelIdRef = useRef(null);
|
|
56823
56891
|
var isNavigatingChannelRef = useRef(false);
|
|
56824
|
-
var
|
|
56825
|
-
realEditorState =
|
|
56826
|
-
setRealEditorState =
|
|
56827
|
-
var
|
|
56828
|
-
floatingAnchorElem =
|
|
56829
|
-
setFloatingAnchorElem =
|
|
56830
|
-
var _useState33 = useState(false),
|
|
56831
|
-
isSmallWidthViewport = _useState33[0],
|
|
56832
|
-
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];
|
|
56833
56898
|
var _useState34 = useState(false),
|
|
56834
|
-
|
|
56835
|
-
|
|
56836
|
-
var _useState35 = useState(
|
|
56837
|
-
|
|
56838
|
-
|
|
56899
|
+
isSmallWidthViewport = _useState34[0],
|
|
56900
|
+
setIsSmallWidthViewport = _useState34[1];
|
|
56901
|
+
var _useState35 = useState(false),
|
|
56902
|
+
isScrolling = _useState35[0],
|
|
56903
|
+
setIsScrolling = _useState35[1];
|
|
56839
56904
|
var _useState36 = useState(null),
|
|
56840
|
-
|
|
56841
|
-
|
|
56842
|
-
var _useState37 = useState(
|
|
56843
|
-
|
|
56844
|
-
|
|
56845
|
-
var _useState38 = useState(
|
|
56846
|
-
|
|
56847
|
-
|
|
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];
|
|
56848
56913
|
var _useState39 = useState(false),
|
|
56849
|
-
|
|
56850
|
-
|
|
56914
|
+
isClosingPreview = _useState39[0],
|
|
56915
|
+
setIsClosingPreview = _useState39[1];
|
|
56851
56916
|
var _useState40 = useState(false),
|
|
56852
|
-
|
|
56853
|
-
|
|
56917
|
+
replyLinkPreviewImageFailed = _useState40[0],
|
|
56918
|
+
setReplyLinkPreviewImageFailed = _useState40[1];
|
|
56919
|
+
var _useState41 = useState(false),
|
|
56920
|
+
linkPreviewImageFailed = _useState41[0],
|
|
56921
|
+
setLinkPreviewImageFailed = _useState41[1];
|
|
56854
56922
|
var addAttachmentByMenu = showChooseFileAttachment && showChooseMediaAttachment;
|
|
56855
56923
|
var linkify = new LinkifyIt();
|
|
56856
56924
|
var oGMetadata = useSelector(function (state) {
|
|
@@ -56861,8 +56929,51 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
56861
56929
|
return setDraftsHydrated(areDraftMessagesHydrated());
|
|
56862
56930
|
});
|
|
56863
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]);
|
|
56864
56975
|
useEffect(function () {
|
|
56865
|
-
if (!draftsHydrated || !activeChannel.id) {
|
|
56976
|
+
if (!draftsHydrated || !activeChannel.id || composerChannelId !== activeChannel.id) {
|
|
56866
56977
|
return;
|
|
56867
56978
|
}
|
|
56868
56979
|
var draftMessage = getDraftMessageFromMap(activeChannel.id);
|
|
@@ -56896,7 +57007,27 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
56896
57007
|
draftMessage: draftMessage
|
|
56897
57008
|
});
|
|
56898
57009
|
restoredDraftChannelIdRef.current = activeChannel.id;
|
|
56899
|
-
}, [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]);
|
|
56900
57031
|
useEffect(function () {
|
|
56901
57032
|
setReplyLinkPreviewImageFailed(false);
|
|
56902
57033
|
}, [messageForReply === null || messageForReply === void 0 ? void 0 : messageForReply.id, messageForReply === null || messageForReply === void 0 ? void 0 : messageForReply.tid]);
|
|
@@ -57548,9 +57679,11 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
57548
57679
|
dispatch(clearSelectedMessagesAC());
|
|
57549
57680
|
};
|
|
57550
57681
|
var handleSetMentionMember = function handleSetMentionMember(mentionMember) {
|
|
57551
|
-
|
|
57552
|
-
|
|
57553
|
-
|
|
57682
|
+
if (composerChannelId === activeChannel.id) {
|
|
57683
|
+
setMentionedUsers(function (prevState) {
|
|
57684
|
+
return [].concat(prevState, [mentionMember]);
|
|
57685
|
+
});
|
|
57686
|
+
}
|
|
57554
57687
|
};
|
|
57555
57688
|
var createComposePreviewUrl = function createComposePreviewUrl(attachmentTid, blob) {
|
|
57556
57689
|
var url = URL.createObjectURL(blob);
|
|
@@ -57578,7 +57711,7 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
57578
57711
|
if (fileType === 'video') {
|
|
57579
57712
|
beginVideoPreparation(tid, file);
|
|
57580
57713
|
}
|
|
57581
|
-
var type = fileType === 'video'
|
|
57714
|
+
var type = isMediaAttachment && fileType === 'video' ? attachmentTypes.video : isMediaAttachment && fileType === 'image' ? attachmentTypes.image : attachmentTypes.file;
|
|
57582
57715
|
var attachment = _extends({
|
|
57583
57716
|
data: file,
|
|
57584
57717
|
name: file.name,
|
|
@@ -57886,59 +58019,6 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
57886
58019
|
};
|
|
57887
58020
|
}, [isSmallWidthViewport]);
|
|
57888
58021
|
useEffect(function () {
|
|
57889
|
-
if (prevActiveChannelId && activeChannel.id && prevActiveChannelId !== activeChannel.id) {
|
|
57890
|
-
setMessageText('');
|
|
57891
|
-
if (messageForReply) {
|
|
57892
|
-
isNavigatingChannelRef.current = true;
|
|
57893
|
-
handleCloseReply(true);
|
|
57894
|
-
}
|
|
57895
|
-
setAttachments([]);
|
|
57896
|
-
attachmentsUpdate = [];
|
|
57897
|
-
handleCloseEditMode(!!messageToEdit);
|
|
57898
|
-
clearTimeout(typingTimout);
|
|
57899
|
-
var draftMessage = getDraftMessageFromMap(activeChannel.id);
|
|
57900
|
-
if (draftMessage) {
|
|
57901
|
-
restoringDraftRef.current = true;
|
|
57902
|
-
if (draftMessage.messageToEdit) {
|
|
57903
|
-
var _ref6, _draftMessage$editMes2, _draftMessage$editBod2, _draftMessage$mention2;
|
|
57904
|
-
var restoredText = (_ref6 = (_draftMessage$editMes2 = draftMessage.editMessageText) != null ? _draftMessage$editMes2 : draftMessage.messageToEdit.body) != null ? _ref6 : '';
|
|
57905
|
-
var restoredEdit = _extends({}, draftMessage.messageToEdit, {
|
|
57906
|
-
body: restoredText,
|
|
57907
|
-
bodyAttributes: (_draftMessage$editBod2 = draftMessage.editBodyAttributes) != null ? _draftMessage$editBod2 : draftMessage.messageToEdit.bodyAttributes,
|
|
57908
|
-
mentionedUsers: (_draftMessage$mention2 = draftMessage.mentionedUsers) != null ? _draftMessage$mention2 : draftMessage.messageToEdit.mentionedUsers
|
|
57909
|
-
});
|
|
57910
|
-
setEditMessageText(restoredText);
|
|
57911
|
-
setMessageBodyAttributes(restoredEdit.bodyAttributes || []);
|
|
57912
|
-
setMentionedUsers(restoredEdit.mentionedUsers || []);
|
|
57913
|
-
setRestoredEditMessage(restoredEdit);
|
|
57914
|
-
dispatch(setMessageToEditAC(draftMessage.messageToEdit));
|
|
57915
|
-
restoredDraftChannelIdRef.current = activeChannel.id;
|
|
57916
|
-
}
|
|
57917
|
-
if (!draftMessage.messageToEdit) {
|
|
57918
|
-
if (draftMessage.messageForReply) {
|
|
57919
|
-
dispatch(setMessageForReplyAC(draftMessage.messageForReply));
|
|
57920
|
-
}
|
|
57921
|
-
setMessageText(draftMessage.text);
|
|
57922
|
-
setMentionedUsers(draftMessage.mentionedUsers);
|
|
57923
|
-
setAttachments(draftMessage.attachments || []);
|
|
57924
|
-
setViewOnce(!!draftMessage.viewOnce);
|
|
57925
|
-
restoredDraftChannelIdRef.current = activeChannel.id;
|
|
57926
|
-
setShouldClearEditor({
|
|
57927
|
-
clear: true,
|
|
57928
|
-
draftMessage: draftMessage
|
|
57929
|
-
});
|
|
57930
|
-
}
|
|
57931
|
-
} else {
|
|
57932
|
-
setMentionedUsers([]);
|
|
57933
|
-
setShouldClearEditor({
|
|
57934
|
-
clear: true,
|
|
57935
|
-
draftMessage: draftMessage
|
|
57936
|
-
});
|
|
57937
|
-
}
|
|
57938
|
-
}
|
|
57939
|
-
if (activeChannel.id) {
|
|
57940
|
-
prevActiveChannelId = activeChannel.id;
|
|
57941
|
-
}
|
|
57942
58022
|
if (activeChannel.id && membersHasNext === undefined && !(activeChannel.type === DEFAULT_CHANNEL_TYPE.DIRECT && activeChannel.memberCount === 2)) {
|
|
57943
58023
|
dispatch(getMembersAC(activeChannel.id));
|
|
57944
58024
|
}
|
|
@@ -57947,6 +58027,9 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
57947
58027
|
if (!draftsHydrated) {
|
|
57948
58028
|
return;
|
|
57949
58029
|
}
|
|
58030
|
+
if (!activeChannel.id || composerChannelId !== activeChannel.id) {
|
|
58031
|
+
return;
|
|
58032
|
+
}
|
|
57950
58033
|
if (restoringDraftRef.current) {
|
|
57951
58034
|
restoringDraftRef.current = false;
|
|
57952
58035
|
return;
|
|
@@ -58033,9 +58116,9 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
58033
58116
|
document.body.removeAttribute('onbeforeunload');
|
|
58034
58117
|
}
|
|
58035
58118
|
}
|
|
58036
|
-
}, [messageText, attachments, editMessageText, readyVideoAttachments, messageBodyAttributes, messageToEdit, viewOnce, draftsHydrated]);
|
|
58119
|
+
}, [messageText, attachments, editMessageText, readyVideoAttachments, messageBodyAttributes, messageToEdit, viewOnce, draftsHydrated, activeChannel.id, composerChannelId]);
|
|
58037
58120
|
useDidUpdate(function () {
|
|
58038
|
-
if (!messageToEdit && mentionedUsers && mentionedUsers.length) {
|
|
58121
|
+
if (composerChannelId === activeChannel.id && !messageToEdit && mentionedUsers && mentionedUsers.length) {
|
|
58039
58122
|
setDraftMessageToMap(activeChannel.id, {
|
|
58040
58123
|
text: messageText,
|
|
58041
58124
|
mentionedUsers: mentionedUsers,
|
|
@@ -58047,7 +58130,7 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
58047
58130
|
persist: !!(messageText.trim() || attachments.length)
|
|
58048
58131
|
});
|
|
58049
58132
|
}
|
|
58050
|
-
}, [mentionedUsers]);
|
|
58133
|
+
}, [mentionedUsers, activeChannel.id, composerChannelId]);
|
|
58051
58134
|
useDidUpdate(function () {
|
|
58052
58135
|
var _getAudioRecordingFro;
|
|
58053
58136
|
if (handleAttachmentSelected) {
|
|
@@ -58094,6 +58177,9 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
58094
58177
|
});
|
|
58095
58178
|
useDidUpdate(function () {
|
|
58096
58179
|
var _draftMessagesMap$act;
|
|
58180
|
+
if (composerChannelId !== activeChannel.id) {
|
|
58181
|
+
return;
|
|
58182
|
+
}
|
|
58097
58183
|
var persistedReply = (_draftMessagesMap$act = draftMessagesMap[activeChannel.id]) === null || _draftMessagesMap$act === void 0 ? void 0 : _draftMessagesMap$act.messageForReply;
|
|
58098
58184
|
if (isNavigatingChannelRef.current) {
|
|
58099
58185
|
isNavigatingChannelRef.current = false;
|
|
@@ -58121,7 +58207,7 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
58121
58207
|
if (messageContRef && messageContRef.current) {
|
|
58122
58208
|
dispatch(setSendMessageInputHeightAC(messageContRef.current.getBoundingClientRect().height));
|
|
58123
58209
|
}
|
|
58124
|
-
}, [messageForReply]);
|
|
58210
|
+
}, [messageForReply, activeChannel.id, composerChannelId]);
|
|
58125
58211
|
useDidUpdate(function () {
|
|
58126
58212
|
if (messageToEdit) {
|
|
58127
58213
|
if (messageForReply) {
|
|
@@ -58154,7 +58240,6 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
58154
58240
|
if (inputHeightTimeout) {
|
|
58155
58241
|
clearTimeout(inputHeightTimeout);
|
|
58156
58242
|
}
|
|
58157
|
-
prevActiveChannelId = undefined;
|
|
58158
58243
|
document.removeEventListener('mousedown', handleClick);
|
|
58159
58244
|
if (messageContRef && messageContRef.current) {
|
|
58160
58245
|
messageContRef.current.removeEventListener('paste', handlePastAttachments);
|
|
@@ -58568,11 +58653,11 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
58568
58653
|
draftMessage: (restoredEditMessage === null || restoredEditMessage === void 0 ? void 0 : restoredEditMessage.id) === (messageToEdit === null || messageToEdit === void 0 ? void 0 : messageToEdit.id) ? restoredEditMessage : null,
|
|
58569
58654
|
contactsMap: contactsMap,
|
|
58570
58655
|
getFromContacts: getFromContacts,
|
|
58571
|
-
setMentionedMember:
|
|
58656
|
+
setMentionedMember: setComposerMentionedUsers
|
|
58572
58657
|
}), /*#__PURE__*/React__default.createElement(FormatMessagePlugin, {
|
|
58573
58658
|
editorState: realEditorState,
|
|
58574
|
-
setMessageBodyAttributes:
|
|
58575
|
-
setMessageText: messageToEdit ?
|
|
58659
|
+
setMessageBodyAttributes: setComposerMessageBodyAttributes,
|
|
58660
|
+
setMessageText: messageToEdit ? setComposerEditMessageText : setComposerMessageText,
|
|
58576
58661
|
messageToEdit: messageToEdit,
|
|
58577
58662
|
activeChannelMembers: activeChannelMembers,
|
|
58578
58663
|
contactsMap: contactsMap,
|