sceyt-chat-react-uikit 1.8.9-beta.15 → 1.8.9-beta.17
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/sendMessageUtils.d.ts +11 -0
- package/index.js +47 -56
- package/index.modern.js +47 -56
- package/package.json +1 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const hasSendableTextOrPoll: (messageText: string, isPoll: boolean) => boolean;
|
|
2
|
+
export declare const DEFAULT_MEDIA_EXTENSIONS: string[];
|
|
3
|
+
export declare const isDefaultSupportedMediaMimeType: (mimeType: string) => boolean;
|
|
4
|
+
declare type MediaAttachmentValidationOptions = {
|
|
5
|
+
allowedExtensions?: string[];
|
|
6
|
+
sizeLimitKb?: number;
|
|
7
|
+
invalidTypeMessage?: string;
|
|
8
|
+
sizeLimitMessage?: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const getMediaAttachmentValidationError: (file: Pick<File, 'name' | 'size'>, { allowedExtensions, sizeLimitKb, invalidTypeMessage, sizeLimitMessage }: MediaAttachmentValidationOptions) => string | null;
|
|
11
|
+
export {};
|
package/index.js
CHANGED
|
@@ -48851,6 +48851,33 @@ var createMessageMarkerBatcher = function createMessageMarkerBatcher(_ref) {
|
|
|
48851
48851
|
};
|
|
48852
48852
|
};
|
|
48853
48853
|
|
|
48854
|
+
var hasSendableTextOrPoll = function hasSendableTextOrPoll(messageText, isPoll) {
|
|
48855
|
+
return Boolean(messageText.trim() || isPoll);
|
|
48856
|
+
};
|
|
48857
|
+
var DEFAULT_MEDIA_EXTENSIONS = ['jpg', 'jpeg', 'png', 'gif', 'mp4', 'mov', 'avi', 'wmv', 'flv', 'webm', 'jfif'];
|
|
48858
|
+
var DEFAULT_MEDIA_MIME_TYPES = new Set(['image/jpeg', 'image/png', 'image/gif', 'image/jfif', 'image/pjpeg', 'video/mp4', 'video/quicktime', 'video/x-msvideo', 'video/avi', 'video/x-ms-wmv', 'video/x-flv', 'video/webm']);
|
|
48859
|
+
var isDefaultSupportedMediaMimeType = function isDefaultSupportedMediaMimeType(mimeType) {
|
|
48860
|
+
return DEFAULT_MEDIA_MIME_TYPES.has(mimeType.toLowerCase());
|
|
48861
|
+
};
|
|
48862
|
+
var getMediaAttachmentValidationError = function getMediaAttachmentValidationError(file, _ref) {
|
|
48863
|
+
var _file$name$split$pop;
|
|
48864
|
+
var allowedExtensions = _ref.allowedExtensions,
|
|
48865
|
+
sizeLimitKb = _ref.sizeLimitKb,
|
|
48866
|
+
invalidTypeMessage = _ref.invalidTypeMessage,
|
|
48867
|
+
sizeLimitMessage = _ref.sizeLimitMessage;
|
|
48868
|
+
if (sizeLimitKb && file.size / 1024 > sizeLimitKb) {
|
|
48869
|
+
return sizeLimitMessage != null ? sizeLimitMessage : "File size exceeds the limit of " + sizeLimitKb + " KB.";
|
|
48870
|
+
}
|
|
48871
|
+
var supportedExtensions = (allowedExtensions !== null && allowedExtensions !== void 0 && allowedExtensions.length ? allowedExtensions : DEFAULT_MEDIA_EXTENSIONS).map(function (extension) {
|
|
48872
|
+
return extension.replace(/^\./, '').toLowerCase();
|
|
48873
|
+
});
|
|
48874
|
+
var extension = (_file$name$split$pop = file.name.split('.').pop()) === null || _file$name$split$pop === void 0 ? void 0 : _file$name$split$pop.toLowerCase();
|
|
48875
|
+
if (!extension || !supportedExtensions.includes(extension)) {
|
|
48876
|
+
return invalidTypeMessage != null ? invalidTypeMessage : "Invalid file type. Allowed extensions are: " + supportedExtensions.join(', ') + ".";
|
|
48877
|
+
}
|
|
48878
|
+
return null;
|
|
48879
|
+
};
|
|
48880
|
+
|
|
48854
48881
|
var _templateObject$P, _templateObject2$K, _templateObject3$C, _templateObject4$x, _templateObject5$s, _templateObject6$o, _templateObject7$m, _templateObject8$k, _templateObject9$i, _templateObject0$h, _templateObject1$e, _templateObject10$b, _templateObject11$8;
|
|
48855
48882
|
var MessageList = function MessageList(_ref) {
|
|
48856
48883
|
var _scrollRef$current, _scrollRef$current$of, _scrollRef$current2;
|
|
@@ -49237,8 +49264,7 @@ var MessageList = function MessageList(_ref) {
|
|
|
49237
49264
|
} else {
|
|
49238
49265
|
var fileList = Array.from(e.dataTransfer.items);
|
|
49239
49266
|
var hasMedia = fileList.some(function (item) {
|
|
49240
|
-
|
|
49241
|
-
return fileType === 'image' || fileType === 'video';
|
|
49267
|
+
return isDefaultSupportedMediaMimeType(item.type);
|
|
49242
49268
|
});
|
|
49243
49269
|
filesType = hasMedia ? 'media' : 'file';
|
|
49244
49270
|
}
|
|
@@ -53724,7 +53750,7 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
53724
53750
|
type = event.type,
|
|
53725
53751
|
code = event.code;
|
|
53726
53752
|
var isEnter = (code === 'Enter' || code === 'NumpadEnter') && shiftKey === false;
|
|
53727
|
-
var isPoll = pollDetails && pollDetails.options.length > 0 && pollDetails.name.trim();
|
|
53753
|
+
var isPoll = Boolean(pollDetails && pollDetails.options.length > 0 && pollDetails.name.trim());
|
|
53728
53754
|
var messageTextForSend = isPoll ? pollDetails === null || pollDetails === void 0 ? void 0 : pollDetails.name.trim() : messageText.trim();
|
|
53729
53755
|
var shouldSend = (isEnter || type === 'click') && (messageToEdit || messageTextForSend || attachments.length && attachments.length > 0);
|
|
53730
53756
|
if (isEnter) {
|
|
@@ -53839,7 +53865,7 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
53839
53865
|
});
|
|
53840
53866
|
}
|
|
53841
53867
|
}
|
|
53842
|
-
if (messageTexToSend
|
|
53868
|
+
if (hasSendableTextOrPoll(messageTexToSend, isPoll) && !attachments.length) {
|
|
53843
53869
|
if (linkAttachment) {
|
|
53844
53870
|
messageToSend.attachments = [linkAttachment];
|
|
53845
53871
|
}
|
|
@@ -54069,6 +54095,14 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
54069
54095
|
setUploadErrorMessage('');
|
|
54070
54096
|
}, 3000);
|
|
54071
54097
|
};
|
|
54098
|
+
var validateMediaAttachment = function validateMediaAttachment(file) {
|
|
54099
|
+
return getMediaAttachmentValidationError(file, {
|
|
54100
|
+
allowedExtensions: allowedMediaExtensions,
|
|
54101
|
+
sizeLimitKb: mediaAttachmentSizeLimit,
|
|
54102
|
+
invalidTypeMessage: allowedMediaExtensionsErrorMessage,
|
|
54103
|
+
sizeLimitMessage: attachmentSizeLimitErrorMessage
|
|
54104
|
+
});
|
|
54105
|
+
};
|
|
54072
54106
|
var handleFileUpload = function handleFileUpload(e) {
|
|
54073
54107
|
var isMediaAttachment = e.target.accept === mediaExtensions;
|
|
54074
54108
|
var fileList = Object.values(e.target.files);
|
|
@@ -54085,27 +54119,12 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
54085
54119
|
}
|
|
54086
54120
|
filesToProcess.forEach(function (file) {
|
|
54087
54121
|
try {
|
|
54088
|
-
var
|
|
54089
|
-
var errorMessage = '';
|
|
54090
|
-
if (isMediaAttachment) {
|
|
54091
|
-
if (mediaAttachmentSizeLimit && file.size / 1024 > mediaAttachmentSizeLimit) {
|
|
54092
|
-
allowUpload = false;
|
|
54093
|
-
errorMessage = attachmentSizeLimitErrorMessage != null ? attachmentSizeLimitErrorMessage : "File size exceeds the limit of " + mediaAttachmentSizeLimit + " KB.";
|
|
54094
|
-
}
|
|
54095
|
-
if (allowedMediaExtensions !== null && allowedMediaExtensions !== void 0 && allowedMediaExtensions.length) {
|
|
54096
|
-
var fileName = file.name;
|
|
54097
|
-
var fileExtension = fileName.split('.').pop().toLowerCase();
|
|
54098
|
-
if (!allowedMediaExtensions.includes(fileExtension)) {
|
|
54099
|
-
allowUpload = false;
|
|
54100
|
-
errorMessage = allowedMediaExtensionsErrorMessage != null ? allowedMediaExtensionsErrorMessage : "Invalid file type. Allowed extensions are: " + allowedMediaExtensions.join(', ') + ".";
|
|
54101
|
-
}
|
|
54102
|
-
}
|
|
54103
|
-
}
|
|
54122
|
+
var validationError = isMediaAttachment ? validateMediaAttachment(file) : null;
|
|
54104
54123
|
var _temp8 = function () {
|
|
54105
|
-
if (
|
|
54124
|
+
if (!validationError) {
|
|
54106
54125
|
return Promise.resolve(handleAddAttachmentWithViewOnceCheck(file, isMediaAttachment)).then(function () {});
|
|
54107
54126
|
} else {
|
|
54108
|
-
showFileUploadError(
|
|
54127
|
+
showFileUploadError(validationError);
|
|
54109
54128
|
}
|
|
54110
54129
|
}();
|
|
54111
54130
|
return Promise.resolve(_temp8 && _temp8.then ? _temp8.then(function () {}) : void 0);
|
|
@@ -54145,25 +54164,12 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
54145
54164
|
}
|
|
54146
54165
|
filesToProcess.forEach(function (file) {
|
|
54147
54166
|
try {
|
|
54148
|
-
var
|
|
54149
|
-
var errorMessage = '';
|
|
54150
|
-
if (mediaAttachmentSizeLimit && file.size / 1024 > mediaAttachmentSizeLimit) {
|
|
54151
|
-
allowUpload = false;
|
|
54152
|
-
errorMessage = attachmentSizeLimitErrorMessage != null ? attachmentSizeLimitErrorMessage : "File size exceeds the limit of " + mediaAttachmentSizeLimit + " KB.";
|
|
54153
|
-
}
|
|
54154
|
-
if (allowedMediaExtensions !== null && allowedMediaExtensions !== void 0 && allowedMediaExtensions.length) {
|
|
54155
|
-
var fileName = file.name;
|
|
54156
|
-
var fileExtension = fileName.split('.').pop().toLowerCase();
|
|
54157
|
-
if (!allowedMediaExtensions.includes(fileExtension)) {
|
|
54158
|
-
allowUpload = false;
|
|
54159
|
-
errorMessage = allowedMediaExtensionsErrorMessage != null ? allowedMediaExtensionsErrorMessage : "Invalid file type. Allowed extensions are: " + allowedMediaExtensions.join(', ') + ".";
|
|
54160
|
-
}
|
|
54161
|
-
}
|
|
54167
|
+
var validationError = validateMediaAttachment(file);
|
|
54162
54168
|
var _temp9 = function () {
|
|
54163
|
-
if (
|
|
54169
|
+
if (!validationError) {
|
|
54164
54170
|
return Promise.resolve(handleAddAttachmentWithViewOnceCheck(file, true)).then(function () {});
|
|
54165
54171
|
} else {
|
|
54166
|
-
showFileUploadError(
|
|
54172
|
+
showFileUploadError(validationError);
|
|
54167
54173
|
}
|
|
54168
54174
|
}();
|
|
54169
54175
|
return Promise.resolve(_temp9 && _temp9.then ? _temp9.then(function () {}) : void 0);
|
|
@@ -54499,27 +54505,12 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
54499
54505
|
var isMediaAttachment = draggedAttachments[0].attachmentType === 'media';
|
|
54500
54506
|
filesToProcess.forEach(function (file) {
|
|
54501
54507
|
try {
|
|
54502
|
-
var
|
|
54503
|
-
var errorMessage = '';
|
|
54504
|
-
if (isMediaAttachment) {
|
|
54505
|
-
if (mediaAttachmentSizeLimit && file.size / 1024 > mediaAttachmentSizeLimit) {
|
|
54506
|
-
allowUpload = false;
|
|
54507
|
-
errorMessage = attachmentSizeLimitErrorMessage != null ? attachmentSizeLimitErrorMessage : "File size exceeds the limit of " + mediaAttachmentSizeLimit + " KB.";
|
|
54508
|
-
}
|
|
54509
|
-
if (allowedMediaExtensions !== null && allowedMediaExtensions !== void 0 && allowedMediaExtensions.length) {
|
|
54510
|
-
var fileName = file.name;
|
|
54511
|
-
var fileExtension = fileName.split('.').pop().toLowerCase();
|
|
54512
|
-
if (!allowedMediaExtensions.includes(fileExtension)) {
|
|
54513
|
-
allowUpload = false;
|
|
54514
|
-
errorMessage = allowedMediaExtensionsErrorMessage != null ? allowedMediaExtensionsErrorMessage : "Invalid file type. Allowed extensions are: " + allowedMediaExtensions.join(', ') + ".";
|
|
54515
|
-
}
|
|
54516
|
-
}
|
|
54517
|
-
}
|
|
54508
|
+
var validationError = isMediaAttachment ? validateMediaAttachment(file) : null;
|
|
54518
54509
|
var _temp19 = function () {
|
|
54519
|
-
if (
|
|
54510
|
+
if (!validationError) {
|
|
54520
54511
|
return Promise.resolve(handleAddAttachmentWithViewOnceCheck(file, isMediaAttachment)).then(function () {});
|
|
54521
54512
|
} else {
|
|
54522
|
-
showFileUploadError(
|
|
54513
|
+
showFileUploadError(validationError);
|
|
54523
54514
|
}
|
|
54524
54515
|
}();
|
|
54525
54516
|
return Promise.resolve(_temp19 && _temp19.then ? _temp19.then(function () {}) : void 0);
|
package/index.modern.js
CHANGED
|
@@ -48831,6 +48831,33 @@ var createMessageMarkerBatcher = function createMessageMarkerBatcher(_ref) {
|
|
|
48831
48831
|
};
|
|
48832
48832
|
};
|
|
48833
48833
|
|
|
48834
|
+
var hasSendableTextOrPoll = function hasSendableTextOrPoll(messageText, isPoll) {
|
|
48835
|
+
return Boolean(messageText.trim() || isPoll);
|
|
48836
|
+
};
|
|
48837
|
+
var DEFAULT_MEDIA_EXTENSIONS = ['jpg', 'jpeg', 'png', 'gif', 'mp4', 'mov', 'avi', 'wmv', 'flv', 'webm', 'jfif'];
|
|
48838
|
+
var DEFAULT_MEDIA_MIME_TYPES = new Set(['image/jpeg', 'image/png', 'image/gif', 'image/jfif', 'image/pjpeg', 'video/mp4', 'video/quicktime', 'video/x-msvideo', 'video/avi', 'video/x-ms-wmv', 'video/x-flv', 'video/webm']);
|
|
48839
|
+
var isDefaultSupportedMediaMimeType = function isDefaultSupportedMediaMimeType(mimeType) {
|
|
48840
|
+
return DEFAULT_MEDIA_MIME_TYPES.has(mimeType.toLowerCase());
|
|
48841
|
+
};
|
|
48842
|
+
var getMediaAttachmentValidationError = function getMediaAttachmentValidationError(file, _ref) {
|
|
48843
|
+
var _file$name$split$pop;
|
|
48844
|
+
var allowedExtensions = _ref.allowedExtensions,
|
|
48845
|
+
sizeLimitKb = _ref.sizeLimitKb,
|
|
48846
|
+
invalidTypeMessage = _ref.invalidTypeMessage,
|
|
48847
|
+
sizeLimitMessage = _ref.sizeLimitMessage;
|
|
48848
|
+
if (sizeLimitKb && file.size / 1024 > sizeLimitKb) {
|
|
48849
|
+
return sizeLimitMessage != null ? sizeLimitMessage : "File size exceeds the limit of " + sizeLimitKb + " KB.";
|
|
48850
|
+
}
|
|
48851
|
+
var supportedExtensions = (allowedExtensions !== null && allowedExtensions !== void 0 && allowedExtensions.length ? allowedExtensions : DEFAULT_MEDIA_EXTENSIONS).map(function (extension) {
|
|
48852
|
+
return extension.replace(/^\./, '').toLowerCase();
|
|
48853
|
+
});
|
|
48854
|
+
var extension = (_file$name$split$pop = file.name.split('.').pop()) === null || _file$name$split$pop === void 0 ? void 0 : _file$name$split$pop.toLowerCase();
|
|
48855
|
+
if (!extension || !supportedExtensions.includes(extension)) {
|
|
48856
|
+
return invalidTypeMessage != null ? invalidTypeMessage : "Invalid file type. Allowed extensions are: " + supportedExtensions.join(', ') + ".";
|
|
48857
|
+
}
|
|
48858
|
+
return null;
|
|
48859
|
+
};
|
|
48860
|
+
|
|
48834
48861
|
var _templateObject$P, _templateObject2$K, _templateObject3$C, _templateObject4$x, _templateObject5$s, _templateObject6$o, _templateObject7$m, _templateObject8$k, _templateObject9$i, _templateObject0$h, _templateObject1$e, _templateObject10$b, _templateObject11$8;
|
|
48835
48862
|
var MessageList = function MessageList(_ref) {
|
|
48836
48863
|
var _scrollRef$current, _scrollRef$current$of, _scrollRef$current2;
|
|
@@ -49217,8 +49244,7 @@ var MessageList = function MessageList(_ref) {
|
|
|
49217
49244
|
} else {
|
|
49218
49245
|
var fileList = Array.from(e.dataTransfer.items);
|
|
49219
49246
|
var hasMedia = fileList.some(function (item) {
|
|
49220
|
-
|
|
49221
|
-
return fileType === 'image' || fileType === 'video';
|
|
49247
|
+
return isDefaultSupportedMediaMimeType(item.type);
|
|
49222
49248
|
});
|
|
49223
49249
|
filesType = hasMedia ? 'media' : 'file';
|
|
49224
49250
|
}
|
|
@@ -53704,7 +53730,7 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
53704
53730
|
type = event.type,
|
|
53705
53731
|
code = event.code;
|
|
53706
53732
|
var isEnter = (code === 'Enter' || code === 'NumpadEnter') && shiftKey === false;
|
|
53707
|
-
var isPoll = pollDetails && pollDetails.options.length > 0 && pollDetails.name.trim();
|
|
53733
|
+
var isPoll = Boolean(pollDetails && pollDetails.options.length > 0 && pollDetails.name.trim());
|
|
53708
53734
|
var messageTextForSend = isPoll ? pollDetails === null || pollDetails === void 0 ? void 0 : pollDetails.name.trim() : messageText.trim();
|
|
53709
53735
|
var shouldSend = (isEnter || type === 'click') && (messageToEdit || messageTextForSend || attachments.length && attachments.length > 0);
|
|
53710
53736
|
if (isEnter) {
|
|
@@ -53819,7 +53845,7 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
53819
53845
|
});
|
|
53820
53846
|
}
|
|
53821
53847
|
}
|
|
53822
|
-
if (messageTexToSend
|
|
53848
|
+
if (hasSendableTextOrPoll(messageTexToSend, isPoll) && !attachments.length) {
|
|
53823
53849
|
if (linkAttachment) {
|
|
53824
53850
|
messageToSend.attachments = [linkAttachment];
|
|
53825
53851
|
}
|
|
@@ -54049,6 +54075,14 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
54049
54075
|
setUploadErrorMessage('');
|
|
54050
54076
|
}, 3000);
|
|
54051
54077
|
};
|
|
54078
|
+
var validateMediaAttachment = function validateMediaAttachment(file) {
|
|
54079
|
+
return getMediaAttachmentValidationError(file, {
|
|
54080
|
+
allowedExtensions: allowedMediaExtensions,
|
|
54081
|
+
sizeLimitKb: mediaAttachmentSizeLimit,
|
|
54082
|
+
invalidTypeMessage: allowedMediaExtensionsErrorMessage,
|
|
54083
|
+
sizeLimitMessage: attachmentSizeLimitErrorMessage
|
|
54084
|
+
});
|
|
54085
|
+
};
|
|
54052
54086
|
var handleFileUpload = function handleFileUpload(e) {
|
|
54053
54087
|
var isMediaAttachment = e.target.accept === mediaExtensions;
|
|
54054
54088
|
var fileList = Object.values(e.target.files);
|
|
@@ -54065,27 +54099,12 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
54065
54099
|
}
|
|
54066
54100
|
filesToProcess.forEach(function (file) {
|
|
54067
54101
|
try {
|
|
54068
|
-
var
|
|
54069
|
-
var errorMessage = '';
|
|
54070
|
-
if (isMediaAttachment) {
|
|
54071
|
-
if (mediaAttachmentSizeLimit && file.size / 1024 > mediaAttachmentSizeLimit) {
|
|
54072
|
-
allowUpload = false;
|
|
54073
|
-
errorMessage = attachmentSizeLimitErrorMessage != null ? attachmentSizeLimitErrorMessage : "File size exceeds the limit of " + mediaAttachmentSizeLimit + " KB.";
|
|
54074
|
-
}
|
|
54075
|
-
if (allowedMediaExtensions !== null && allowedMediaExtensions !== void 0 && allowedMediaExtensions.length) {
|
|
54076
|
-
var fileName = file.name;
|
|
54077
|
-
var fileExtension = fileName.split('.').pop().toLowerCase();
|
|
54078
|
-
if (!allowedMediaExtensions.includes(fileExtension)) {
|
|
54079
|
-
allowUpload = false;
|
|
54080
|
-
errorMessage = allowedMediaExtensionsErrorMessage != null ? allowedMediaExtensionsErrorMessage : "Invalid file type. Allowed extensions are: " + allowedMediaExtensions.join(', ') + ".";
|
|
54081
|
-
}
|
|
54082
|
-
}
|
|
54083
|
-
}
|
|
54102
|
+
var validationError = isMediaAttachment ? validateMediaAttachment(file) : null;
|
|
54084
54103
|
var _temp8 = function () {
|
|
54085
|
-
if (
|
|
54104
|
+
if (!validationError) {
|
|
54086
54105
|
return Promise.resolve(handleAddAttachmentWithViewOnceCheck(file, isMediaAttachment)).then(function () {});
|
|
54087
54106
|
} else {
|
|
54088
|
-
showFileUploadError(
|
|
54107
|
+
showFileUploadError(validationError);
|
|
54089
54108
|
}
|
|
54090
54109
|
}();
|
|
54091
54110
|
return Promise.resolve(_temp8 && _temp8.then ? _temp8.then(function () {}) : void 0);
|
|
@@ -54125,25 +54144,12 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
54125
54144
|
}
|
|
54126
54145
|
filesToProcess.forEach(function (file) {
|
|
54127
54146
|
try {
|
|
54128
|
-
var
|
|
54129
|
-
var errorMessage = '';
|
|
54130
|
-
if (mediaAttachmentSizeLimit && file.size / 1024 > mediaAttachmentSizeLimit) {
|
|
54131
|
-
allowUpload = false;
|
|
54132
|
-
errorMessage = attachmentSizeLimitErrorMessage != null ? attachmentSizeLimitErrorMessage : "File size exceeds the limit of " + mediaAttachmentSizeLimit + " KB.";
|
|
54133
|
-
}
|
|
54134
|
-
if (allowedMediaExtensions !== null && allowedMediaExtensions !== void 0 && allowedMediaExtensions.length) {
|
|
54135
|
-
var fileName = file.name;
|
|
54136
|
-
var fileExtension = fileName.split('.').pop().toLowerCase();
|
|
54137
|
-
if (!allowedMediaExtensions.includes(fileExtension)) {
|
|
54138
|
-
allowUpload = false;
|
|
54139
|
-
errorMessage = allowedMediaExtensionsErrorMessage != null ? allowedMediaExtensionsErrorMessage : "Invalid file type. Allowed extensions are: " + allowedMediaExtensions.join(', ') + ".";
|
|
54140
|
-
}
|
|
54141
|
-
}
|
|
54147
|
+
var validationError = validateMediaAttachment(file);
|
|
54142
54148
|
var _temp9 = function () {
|
|
54143
|
-
if (
|
|
54149
|
+
if (!validationError) {
|
|
54144
54150
|
return Promise.resolve(handleAddAttachmentWithViewOnceCheck(file, true)).then(function () {});
|
|
54145
54151
|
} else {
|
|
54146
|
-
showFileUploadError(
|
|
54152
|
+
showFileUploadError(validationError);
|
|
54147
54153
|
}
|
|
54148
54154
|
}();
|
|
54149
54155
|
return Promise.resolve(_temp9 && _temp9.then ? _temp9.then(function () {}) : void 0);
|
|
@@ -54479,27 +54485,12 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
54479
54485
|
var isMediaAttachment = draggedAttachments[0].attachmentType === 'media';
|
|
54480
54486
|
filesToProcess.forEach(function (file) {
|
|
54481
54487
|
try {
|
|
54482
|
-
var
|
|
54483
|
-
var errorMessage = '';
|
|
54484
|
-
if (isMediaAttachment) {
|
|
54485
|
-
if (mediaAttachmentSizeLimit && file.size / 1024 > mediaAttachmentSizeLimit) {
|
|
54486
|
-
allowUpload = false;
|
|
54487
|
-
errorMessage = attachmentSizeLimitErrorMessage != null ? attachmentSizeLimitErrorMessage : "File size exceeds the limit of " + mediaAttachmentSizeLimit + " KB.";
|
|
54488
|
-
}
|
|
54489
|
-
if (allowedMediaExtensions !== null && allowedMediaExtensions !== void 0 && allowedMediaExtensions.length) {
|
|
54490
|
-
var fileName = file.name;
|
|
54491
|
-
var fileExtension = fileName.split('.').pop().toLowerCase();
|
|
54492
|
-
if (!allowedMediaExtensions.includes(fileExtension)) {
|
|
54493
|
-
allowUpload = false;
|
|
54494
|
-
errorMessage = allowedMediaExtensionsErrorMessage != null ? allowedMediaExtensionsErrorMessage : "Invalid file type. Allowed extensions are: " + allowedMediaExtensions.join(', ') + ".";
|
|
54495
|
-
}
|
|
54496
|
-
}
|
|
54497
|
-
}
|
|
54488
|
+
var validationError = isMediaAttachment ? validateMediaAttachment(file) : null;
|
|
54498
54489
|
var _temp19 = function () {
|
|
54499
|
-
if (
|
|
54490
|
+
if (!validationError) {
|
|
54500
54491
|
return Promise.resolve(handleAddAttachmentWithViewOnceCheck(file, isMediaAttachment)).then(function () {});
|
|
54501
54492
|
} else {
|
|
54502
|
-
showFileUploadError(
|
|
54493
|
+
showFileUploadError(validationError);
|
|
54503
54494
|
}
|
|
54504
54495
|
}();
|
|
54505
54496
|
return Promise.resolve(_temp19 && _temp19.then ? _temp19.then(function () {}) : void 0);
|