sceyt-chat-react-uikit 1.8.8-beta.16 → 1.8.8-beta.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +189 -51
- package/index.modern.js +189 -51
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -8498,6 +8498,31 @@ var getAllowEditDeleteIncomingMessage = function getAllowEditDeleteIncomingMessa
|
|
|
8498
8498
|
var compareMessageBodyAttributes = function compareMessageBodyAttributes(attributes1, attributes2) {
|
|
8499
8499
|
return JSON.stringify(attributes1) === JSON.stringify(attributes2);
|
|
8500
8500
|
};
|
|
8501
|
+
var trimMessageBodyWithAttributes = function trimMessageBodyWithAttributes(text, attributes) {
|
|
8502
|
+
var body = text.trim();
|
|
8503
|
+
var leadingTrim = text.length - text.trimStart().length;
|
|
8504
|
+
var bodyAttributes = (attributes || []).map(function (att) {
|
|
8505
|
+
var offset = att.offset - leadingTrim;
|
|
8506
|
+
var length = att.length;
|
|
8507
|
+
if (offset < 0) {
|
|
8508
|
+
length += offset;
|
|
8509
|
+
offset = 0;
|
|
8510
|
+
}
|
|
8511
|
+
if (offset + length > body.length) {
|
|
8512
|
+
length = body.length - offset;
|
|
8513
|
+
}
|
|
8514
|
+
return _extends({}, att, {
|
|
8515
|
+
offset: offset,
|
|
8516
|
+
length: length
|
|
8517
|
+
});
|
|
8518
|
+
}).filter(function (att) {
|
|
8519
|
+
return att.length > 0 && att.offset >= 0 && att.offset < body.length;
|
|
8520
|
+
});
|
|
8521
|
+
return {
|
|
8522
|
+
body: body,
|
|
8523
|
+
bodyAttributes: bodyAttributes
|
|
8524
|
+
};
|
|
8525
|
+
};
|
|
8501
8526
|
var bodyAttributesMapByType = {
|
|
8502
8527
|
1: ['bold'],
|
|
8503
8528
|
2: ['italic'],
|
|
@@ -16014,6 +16039,10 @@ var SDKErrorTypeEnum = {
|
|
|
16014
16039
|
Authentication: {
|
|
16015
16040
|
value: 'Authentication',
|
|
16016
16041
|
isResendable: true
|
|
16042
|
+
},
|
|
16043
|
+
AttachmentUnavailable: {
|
|
16044
|
+
value: 'AttachmentUnavailable',
|
|
16045
|
+
isResendable: false
|
|
16017
16046
|
}
|
|
16018
16047
|
};
|
|
16019
16048
|
var fromValue = function fromValue(value) {
|
|
@@ -16031,6 +16060,11 @@ var isResendableError = function isResendableError(value) {
|
|
|
16031
16060
|
var errorType = fromValue(value);
|
|
16032
16061
|
return (_errorType$isResendab = errorType === null || errorType === void 0 ? void 0 : errorType.isResendable) != null ? _errorType$isResendab : true;
|
|
16033
16062
|
};
|
|
16063
|
+
var createAttachmentUnavailableError = function createAttachmentUnavailableError(message) {
|
|
16064
|
+
var error = new Error(message);
|
|
16065
|
+
error.type = SDKErrorTypeEnum.AttachmentUnavailable.value;
|
|
16066
|
+
return error;
|
|
16067
|
+
};
|
|
16034
16068
|
|
|
16035
16069
|
var _excluded$1 = ["lastMessage"];
|
|
16036
16070
|
var _marked = /*#__PURE__*/_regenerator().m(setMessageListLoading),
|
|
@@ -16093,6 +16127,8 @@ var _marked = /*#__PURE__*/_regenerator().m(setMessageListLoading),
|
|
|
16093
16127
|
_marked56 = /*#__PURE__*/_regenerator().m(loadMorePollVotes),
|
|
16094
16128
|
_marked57 = /*#__PURE__*/_regenerator().m(refreshCacheAroundMessage),
|
|
16095
16129
|
_marked58 = /*#__PURE__*/_regenerator().m(MessageSaga);
|
|
16130
|
+
var MAX_AUTO_RESEND_ATTEMPTS = 5;
|
|
16131
|
+
var autoResendAttempts = new Map();
|
|
16096
16132
|
var loadMoreMessagesInFlight = new Set();
|
|
16097
16133
|
var prefetchInFlight = new Set();
|
|
16098
16134
|
var queuedPrefetchRequests = new Map();
|
|
@@ -16316,6 +16352,7 @@ var handleUploadAttachments = function handleUploadAttachments(attachments, mess
|
|
|
16316
16352
|
try {
|
|
16317
16353
|
return Promise.resolve(Promise.all(attachments.map(function (attachment) {
|
|
16318
16354
|
try {
|
|
16355
|
+
var _attachment$url, _attachment$url$type;
|
|
16319
16356
|
var _temp10 = function _temp10() {
|
|
16320
16357
|
function _temp0() {
|
|
16321
16358
|
store.dispatch(updateAttachmentUploadingStateAC(UPLOAD_STATE.SUCCESS, attachment.tid));
|
|
@@ -16337,14 +16374,15 @@ var handleUploadAttachments = function handleUploadAttachments(attachments, mess
|
|
|
16337
16374
|
return attachmentToSend;
|
|
16338
16375
|
}
|
|
16339
16376
|
var _temp9 = function () {
|
|
16340
|
-
if (!attachment.cachedUrl &&
|
|
16377
|
+
if (!attachment.cachedUrl && fileType === 'image') {
|
|
16341
16378
|
return _catch(function () {
|
|
16342
16379
|
var _temp2 = function () {
|
|
16343
16380
|
if (blobLocal && blobLocal.type.startsWith('image/')) {
|
|
16381
|
+
var _attachment, _attachment2;
|
|
16344
16382
|
var file = attachment.url instanceof File ? attachment.url : new File([attachment.url], attachment.name || 'image', {
|
|
16345
16383
|
type: attachment.url.type || blobLocal.type
|
|
16346
16384
|
});
|
|
16347
|
-
var _calculateRenderedIma = calculateRenderedImageWidth((attachment === null ||
|
|
16385
|
+
var _calculateRenderedIma = calculateRenderedImageWidth(((_attachment = attachment) === null || _attachment === void 0 ? void 0 : _attachment.metadata.szw) || 1280, ((_attachment2 = attachment) === null || _attachment2 === void 0 ? void 0 : _attachment2.metadata.szh) || 1080),
|
|
16348
16386
|
newWidth = _calculateRenderedIma[0],
|
|
16349
16387
|
newHeight = _calculateRenderedIma[1];
|
|
16350
16388
|
return Promise.resolve(resizeImageWithPica(file, newWidth, newHeight, 1)).then(function (_ref) {
|
|
@@ -16382,10 +16420,11 @@ var handleUploadAttachments = function handleUploadAttachments(attachments, mess
|
|
|
16382
16420
|
});
|
|
16383
16421
|
} else {
|
|
16384
16422
|
var _temp11 = function () {
|
|
16385
|
-
if (!attachment.cachedUrl &&
|
|
16423
|
+
if (!attachment.cachedUrl && fileType === 'video') {
|
|
16386
16424
|
var _temp7 = function () {
|
|
16387
16425
|
if (blobLocal) {
|
|
16388
|
-
var
|
|
16426
|
+
var _attachment3, _attachment4;
|
|
16427
|
+
var _calculateRenderedIma2 = calculateRenderedImageWidth(((_attachment3 = attachment) === null || _attachment3 === void 0 ? void 0 : _attachment3.metadata.szw) || 1280, ((_attachment4 = attachment) === null || _attachment4 === void 0 ? void 0 : _attachment4.metadata.szh) || 1080),
|
|
16389
16428
|
newWidth = _calculateRenderedIma2[0],
|
|
16390
16429
|
newHeight = _calculateRenderedIma2[1];
|
|
16391
16430
|
return Promise.resolve(getVideoFirstFrame(blobLocal, newWidth, newHeight)).then(function (result) {
|
|
@@ -16443,7 +16482,19 @@ var handleUploadAttachments = function handleUploadAttachments(attachments, mess
|
|
|
16443
16482
|
total = _ref2.total;
|
|
16444
16483
|
store.dispatch(updateAttachmentUploadingProgressAC(loaded, total, attachment.tid));
|
|
16445
16484
|
};
|
|
16446
|
-
|
|
16485
|
+
if (!attachment.cachedUrl && !(attachment.url instanceof Blob)) {
|
|
16486
|
+
var _getPendingAttachment;
|
|
16487
|
+
var pendingFile = (_getPendingAttachment = getPendingAttachment(attachment.tid)) === null || _getPendingAttachment === void 0 ? void 0 : _getPendingAttachment.file;
|
|
16488
|
+
if (pendingFile instanceof Blob) {
|
|
16489
|
+
attachment = _extends({}, attachment, {
|
|
16490
|
+
url: pendingFile,
|
|
16491
|
+
data: pendingFile
|
|
16492
|
+
});
|
|
16493
|
+
} else {
|
|
16494
|
+
throw createAttachmentUnavailableError("Attachment file for tid " + attachment.tid + " is no longer available for upload");
|
|
16495
|
+
}
|
|
16496
|
+
}
|
|
16497
|
+
var fileType = (_attachment$url = attachment.url) === null || _attachment$url === void 0 ? void 0 : (_attachment$url$type = _attachment$url.type) === null || _attachment$url$type === void 0 ? void 0 : _attachment$url$type.split('/')[0];
|
|
16447
16498
|
var fileSize = attachment.size;
|
|
16448
16499
|
var filePath;
|
|
16449
16500
|
var uriLocal;
|
|
@@ -16946,11 +16997,19 @@ function sendMessage(action) {
|
|
|
16946
16997
|
break;
|
|
16947
16998
|
}
|
|
16948
16999
|
_loop2 = /*#__PURE__*/_regenerator().m(function _callee3() {
|
|
16949
|
-
var attachment, uri, attachmentBuilder, messageAttachment, handleUpdateUploadProgress, _messageBuilder, _messageToSend, messageForSend, _pending;
|
|
17000
|
+
var attachment, _getPendingAttachment2, pendingFile, uri, attachmentBuilder, messageAttachment, handleUpdateUploadProgress, _messageBuilder, _messageToSend, messageForSend, _pending;
|
|
16950
17001
|
return _regenerator().w(function (_context11) {
|
|
16951
17002
|
while (1) switch (_context11.n) {
|
|
16952
17003
|
case 0:
|
|
16953
17004
|
attachment = mediaAttachments[i];
|
|
17005
|
+
if (customUploader && !attachment.cachedUrl && !(attachment.data instanceof Blob)) {
|
|
17006
|
+
pendingFile = (_getPendingAttachment2 = getPendingAttachment(attachment.tid)) === null || _getPendingAttachment2 === void 0 ? void 0 : _getPendingAttachment2.file;
|
|
17007
|
+
if (pendingFile instanceof Blob) {
|
|
17008
|
+
attachment = _extends({}, attachment, {
|
|
17009
|
+
data: pendingFile
|
|
17010
|
+
});
|
|
17011
|
+
}
|
|
17012
|
+
}
|
|
16954
17013
|
if (attachment.cachedUrl) {
|
|
16955
17014
|
uri = attachment.cachedUrl;
|
|
16956
17015
|
}
|
|
@@ -17251,6 +17310,9 @@ function sendMessage(action) {
|
|
|
17251
17310
|
return effects.call(channel.sendMessage, messageToSend);
|
|
17252
17311
|
case 5:
|
|
17253
17312
|
messageResponse = _context12.v;
|
|
17313
|
+
if (messageToSend.tid) {
|
|
17314
|
+
autoResendAttempts["delete"](messageToSend.tid);
|
|
17315
|
+
}
|
|
17254
17316
|
if (!customUploader) {
|
|
17255
17317
|
_context12.n = 10;
|
|
17256
17318
|
break;
|
|
@@ -17783,12 +17845,17 @@ function forwardMessage(action) {
|
|
|
17783
17845
|
}
|
|
17784
17846
|
function resendMessage(action) {
|
|
17785
17847
|
var _message$attachments;
|
|
17786
|
-
var payload,
|
|
17848
|
+
var payload, payloadMessage, connectionState, channelId, liveMessage, message, attachments, sendAttachmentsAsSeparateMessage, isVoiceMessage;
|
|
17787
17849
|
return _regenerator().w(function (_context16) {
|
|
17788
17850
|
while (1) switch (_context16.n) {
|
|
17789
17851
|
case 0:
|
|
17790
17852
|
payload = action.payload;
|
|
17791
|
-
|
|
17853
|
+
payloadMessage = payload.message, connectionState = payload.connectionState, channelId = payload.channelId;
|
|
17854
|
+
liveMessage = payloadMessage !== null && payloadMessage !== void 0 && payloadMessage.tid || payloadMessage !== null && payloadMessage !== void 0 && payloadMessage.id ? getMessageFromMap(channelId, payloadMessage.tid || payloadMessage.id) : null;
|
|
17855
|
+
message = liveMessage || payloadMessage;
|
|
17856
|
+
if (message !== null && message !== void 0 && message.tid || message !== null && message !== void 0 && message.id) {
|
|
17857
|
+
autoResendAttempts["delete"](message.tid || message.id);
|
|
17858
|
+
}
|
|
17792
17859
|
attachments = message === null || message === void 0 ? void 0 : (_message$attachments = message.attachments) === null || _message$attachments === void 0 ? void 0 : _message$attachments.filter(function (att) {
|
|
17793
17860
|
return (att === null || att === void 0 ? void 0 : att.type) !== attachmentTypes.link;
|
|
17794
17861
|
});
|
|
@@ -17983,7 +18050,7 @@ function editMessage(action) {
|
|
|
17983
18050
|
}, _marked14, null, [[0, 8]]);
|
|
17984
18051
|
}
|
|
17985
18052
|
var sendPendingMessages = /*#__PURE__*/_regenerator().m(function _callee5(connectionState) {
|
|
17986
|
-
var pendingMessagesMap, channelId, _iterator3, _step3, _msg$attachments, msg, attachments, pendingPollActionsMap, _t7, _t8, _t9;
|
|
18053
|
+
var pendingMessagesMap, channelId, _iterator3, _step3, _msg$attachments, msg, attachments, resendKey, attempts, pendingPollActionsMap, _t7, _t8, _t9;
|
|
17987
18054
|
return _regenerator().w(function (_context19) {
|
|
17988
18055
|
while (1) switch (_context19.p = _context19.n) {
|
|
17989
18056
|
case 0:
|
|
@@ -17991,26 +18058,41 @@ var sendPendingMessages = /*#__PURE__*/_regenerator().m(function _callee5(connec
|
|
|
17991
18058
|
_t7 = _regeneratorKeys(pendingMessagesMap);
|
|
17992
18059
|
case 1:
|
|
17993
18060
|
if ((_t8 = _t7()).done) {
|
|
17994
|
-
_context19.n =
|
|
18061
|
+
_context19.n = 13;
|
|
17995
18062
|
break;
|
|
17996
18063
|
}
|
|
17997
18064
|
channelId = _t8.value;
|
|
17998
18065
|
_iterator3 = _createForOfIteratorHelperLoose(pendingMessagesMap[channelId]);
|
|
17999
18066
|
case 2:
|
|
18000
18067
|
if ((_step3 = _iterator3()).done) {
|
|
18001
|
-
_context19.n =
|
|
18068
|
+
_context19.n = 12;
|
|
18002
18069
|
break;
|
|
18003
18070
|
}
|
|
18004
18071
|
msg = _step3.value;
|
|
18005
18072
|
attachments = msg === null || msg === void 0 ? void 0 : (_msg$attachments = msg.attachments) === null || _msg$attachments === void 0 ? void 0 : _msg$attachments.filter(function (att) {
|
|
18006
18073
|
return (att === null || att === void 0 ? void 0 : att.type) !== attachmentTypes.link;
|
|
18007
18074
|
});
|
|
18008
|
-
|
|
18075
|
+
resendKey = (msg === null || msg === void 0 ? void 0 : msg.tid) || (msg === null || msg === void 0 ? void 0 : msg.id);
|
|
18076
|
+
if (!resendKey) {
|
|
18077
|
+
_context19.n = 4;
|
|
18078
|
+
break;
|
|
18079
|
+
}
|
|
18080
|
+
attempts = autoResendAttempts.get(resendKey) || 0;
|
|
18081
|
+
if (!(attempts >= MAX_AUTO_RESEND_ATTEMPTS)) {
|
|
18082
|
+
_context19.n = 3;
|
|
18083
|
+
break;
|
|
18084
|
+
}
|
|
18085
|
+
log.info("Skipping auto-resend of message " + resendKey + " after " + attempts + " failed attempts");
|
|
18086
|
+
return _context19.a(3, 11);
|
|
18087
|
+
case 3:
|
|
18088
|
+
autoResendAttempts.set(resendKey, attempts + 1);
|
|
18089
|
+
case 4:
|
|
18090
|
+
_context19.p = 4;
|
|
18009
18091
|
if (!(msg !== null && msg !== void 0 && msg.forwardingDetails)) {
|
|
18010
|
-
_context19.n =
|
|
18092
|
+
_context19.n = 6;
|
|
18011
18093
|
break;
|
|
18012
18094
|
}
|
|
18013
|
-
_context19.n =
|
|
18095
|
+
_context19.n = 5;
|
|
18014
18096
|
return effects.call(forwardMessage, {
|
|
18015
18097
|
type: RESEND_MESSAGE,
|
|
18016
18098
|
payload: {
|
|
@@ -18020,15 +18102,15 @@ var sendPendingMessages = /*#__PURE__*/_regenerator().m(function _callee5(connec
|
|
|
18020
18102
|
isForward: true
|
|
18021
18103
|
}
|
|
18022
18104
|
});
|
|
18023
|
-
case 4:
|
|
18024
|
-
_context19.n = 8;
|
|
18025
|
-
break;
|
|
18026
18105
|
case 5:
|
|
18106
|
+
_context19.n = 9;
|
|
18107
|
+
break;
|
|
18108
|
+
case 6:
|
|
18027
18109
|
if (!(attachments && attachments.length > 0)) {
|
|
18028
|
-
_context19.n =
|
|
18110
|
+
_context19.n = 8;
|
|
18029
18111
|
break;
|
|
18030
18112
|
}
|
|
18031
|
-
_context19.n =
|
|
18113
|
+
_context19.n = 7;
|
|
18032
18114
|
return effects.call(sendMessage, {
|
|
18033
18115
|
type: RESEND_MESSAGE,
|
|
18034
18116
|
payload: {
|
|
@@ -18038,11 +18120,11 @@ var sendPendingMessages = /*#__PURE__*/_regenerator().m(function _callee5(connec
|
|
|
18038
18120
|
sendAttachmentsAsSeparateMessage: false
|
|
18039
18121
|
}
|
|
18040
18122
|
});
|
|
18041
|
-
case 6:
|
|
18042
|
-
_context19.n = 8;
|
|
18043
|
-
break;
|
|
18044
18123
|
case 7:
|
|
18045
|
-
_context19.n =
|
|
18124
|
+
_context19.n = 9;
|
|
18125
|
+
break;
|
|
18126
|
+
case 8:
|
|
18127
|
+
_context19.n = 9;
|
|
18046
18128
|
return effects.call(sendTextMessage, {
|
|
18047
18129
|
type: RESEND_MESSAGE,
|
|
18048
18130
|
payload: {
|
|
@@ -18051,31 +18133,31 @@ var sendPendingMessages = /*#__PURE__*/_regenerator().m(function _callee5(connec
|
|
|
18051
18133
|
channelId: channelId
|
|
18052
18134
|
}
|
|
18053
18135
|
});
|
|
18054
|
-
case 8:
|
|
18055
|
-
_context19.n = 10;
|
|
18056
|
-
break;
|
|
18057
18136
|
case 9:
|
|
18058
|
-
_context19.
|
|
18137
|
+
_context19.n = 11;
|
|
18138
|
+
break;
|
|
18139
|
+
case 10:
|
|
18140
|
+
_context19.p = 10;
|
|
18059
18141
|
_t9 = _context19.v;
|
|
18060
18142
|
log.error("Failed to send pending message " + (msg.tid || msg.id) + ":", _t9);
|
|
18061
|
-
case
|
|
18143
|
+
case 11:
|
|
18062
18144
|
_context19.n = 2;
|
|
18063
18145
|
break;
|
|
18064
|
-
case
|
|
18146
|
+
case 12:
|
|
18065
18147
|
_context19.n = 1;
|
|
18066
18148
|
break;
|
|
18067
|
-
case
|
|
18149
|
+
case 13:
|
|
18068
18150
|
pendingPollActionsMap = store.getState().MessageReducer.pendingPollActions;
|
|
18069
18151
|
if (!(pendingPollActionsMap && Object.keys(pendingPollActionsMap).length > 0)) {
|
|
18070
|
-
_context19.n =
|
|
18152
|
+
_context19.n = 14;
|
|
18071
18153
|
break;
|
|
18072
18154
|
}
|
|
18073
|
-
_context19.n =
|
|
18155
|
+
_context19.n = 14;
|
|
18074
18156
|
return effects.put(resendPendingPollActionsAC(connectionState));
|
|
18075
|
-
case
|
|
18157
|
+
case 14:
|
|
18076
18158
|
return _context19.a(2);
|
|
18077
18159
|
}
|
|
18078
|
-
}, _callee5, null, [[
|
|
18160
|
+
}, _callee5, null, [[4, 10]]);
|
|
18079
18161
|
});
|
|
18080
18162
|
var shouldAppendPendingMessages = function shouldAppendPendingMessages(channelOrId, messages, options) {
|
|
18081
18163
|
var _getStoredChannel9, _getStoredChannel9$la, _channelOrId$lastMess;
|
|
@@ -18300,7 +18382,7 @@ function loadOGMetadataForLinkMessages(messages, getFromServer) {
|
|
|
18300
18382
|
getFromServer = true;
|
|
18301
18383
|
}
|
|
18302
18384
|
return /*#__PURE__*/_regenerator().m(function _callee6() {
|
|
18303
|
-
var i, _message$attachments2, message, isOnlyLinkAttachments, firstAttachment, j,
|
|
18385
|
+
var i, _message$attachments2, message, isOnlyLinkAttachments, firstAttachment, j, _attachment5, _firstAttachment, _store$getState$Messa, _firstAttachment2, _firstAttachment3, _firstAttachment4, metadata, storedData;
|
|
18304
18386
|
return _regenerator().w(function (_context22) {
|
|
18305
18387
|
while (1) switch (_context22.n) {
|
|
18306
18388
|
case 0:
|
|
@@ -18329,13 +18411,13 @@ function loadOGMetadataForLinkMessages(messages, getFromServer) {
|
|
|
18329
18411
|
_context22.n = 6;
|
|
18330
18412
|
break;
|
|
18331
18413
|
}
|
|
18332
|
-
|
|
18333
|
-
if (!(
|
|
18414
|
+
_attachment5 = message.attachments[j];
|
|
18415
|
+
if (!(_attachment5.type === attachmentTypes.link)) {
|
|
18334
18416
|
_context22.n = 4;
|
|
18335
18417
|
break;
|
|
18336
18418
|
}
|
|
18337
18419
|
if (!firstAttachment) {
|
|
18338
|
-
firstAttachment =
|
|
18420
|
+
firstAttachment = _attachment5;
|
|
18339
18421
|
}
|
|
18340
18422
|
_context22.n = 5;
|
|
18341
18423
|
break;
|
|
@@ -20614,7 +20696,7 @@ function loadMoreReactions(action) {
|
|
|
20614
20696
|
}
|
|
20615
20697
|
function getMessageAttachments(action) {
|
|
20616
20698
|
var _store$getState$Messa2;
|
|
20617
|
-
var _action$payload7, channelId, attachmentType, limit, direction, attachmentId, forPopup, cacheKey, cachedAttachments, SceytChatClient, typeList, AttachmentByTypeQueryBuilder, AttachmentByTypeQuery, result, attachments, attachmentIndex, hasPrev, hasNext, freshAttachments, _t39;
|
|
20699
|
+
var _action$payload7, channelId, attachmentType, limit, direction, attachmentId, forPopup, cacheKey, cachedAttachments, SceytChatClient, typeList, AttachmentByTypeQueryBuilder, AttachmentByTypeQuery, result, attachments, _attachments$2, _attachments, attachmentIndex, hasPrev, hasNext, freshAttachments, _t39;
|
|
20618
20700
|
return _regenerator().w(function (_context42) {
|
|
20619
20701
|
while (1) switch (_context42.p = _context42.n) {
|
|
20620
20702
|
case 0:
|
|
@@ -20693,6 +20775,16 @@ function getMessageAttachments(action) {
|
|
|
20693
20775
|
break;
|
|
20694
20776
|
}
|
|
20695
20777
|
query.AttachmentByTypeQueryForPopup = AttachmentByTypeQuery;
|
|
20778
|
+
console.log('[MEDIA_OPEN] 8.saga-forPopup ' + JSON.stringify({
|
|
20779
|
+
requestedAttId: attachmentId,
|
|
20780
|
+
direction: direction,
|
|
20781
|
+
returned: attachments.length,
|
|
20782
|
+
containsRequested: attachments.some(function (a) {
|
|
20783
|
+
return a.id === attachmentId;
|
|
20784
|
+
}),
|
|
20785
|
+
firstId: (_attachments$2 = attachments[0]) === null || _attachments$2 === void 0 ? void 0 : _attachments$2.id,
|
|
20786
|
+
lastId: (_attachments = attachments[attachments.length - 1]) === null || _attachments === void 0 ? void 0 : _attachments.id
|
|
20787
|
+
}));
|
|
20696
20788
|
_context42.n = 12;
|
|
20697
20789
|
return effects.put(setAttachmentsForPopupAC(JSON.parse(JSON.stringify(attachments))));
|
|
20698
20790
|
case 12:
|
|
@@ -37007,18 +37099,36 @@ var SliderPopup = function SliderPopup(_ref) {
|
|
|
37007
37099
|
log.error('Error getting initial attachment from cache:', error);
|
|
37008
37100
|
});
|
|
37009
37101
|
}
|
|
37010
|
-
|
|
37102
|
+
var foundInStaleList = !!attachmentsList.find(function (item) {
|
|
37011
37103
|
return item.id === currentMediaFile.id;
|
|
37012
|
-
})
|
|
37104
|
+
});
|
|
37105
|
+
console.log('[MEDIA_OPEN] 4.slider-mount ' + JSON.stringify({
|
|
37106
|
+
attId: currentMediaFile.id,
|
|
37107
|
+
name: currentMediaFile.name,
|
|
37108
|
+
msgId: currentMediaFile.messageId,
|
|
37109
|
+
staleListLen: attachmentsList.length,
|
|
37110
|
+
foundInStaleList: foundInStaleList,
|
|
37111
|
+
staleListIds: attachmentsList.slice(0, 5).map(function (item) {
|
|
37112
|
+
return item.id;
|
|
37113
|
+
})
|
|
37114
|
+
}));
|
|
37115
|
+
if (!foundInStaleList) {
|
|
37013
37116
|
dispatch(setAttachmentsForPopupAC([currentMediaFile]));
|
|
37014
37117
|
}
|
|
37015
37118
|
dispatch(getAttachmentsAC(channel.id, channelDetailsTabs.media, 34, queryDirection.NEAR, currentMediaFile.id, true));
|
|
37016
37119
|
}, []);
|
|
37017
37120
|
var activeFileIndex = React.useMemo(function () {
|
|
37018
37121
|
if (!(currentFile !== null && currentFile !== void 0 && currentFile.id)) return -1;
|
|
37019
|
-
|
|
37122
|
+
var index = attachmentsList.findIndex(function (item) {
|
|
37020
37123
|
return item.id === currentFile.id;
|
|
37021
37124
|
});
|
|
37125
|
+
console.log('[MEDIA_OPEN] 5.activeIndex ' + JSON.stringify({
|
|
37126
|
+
index: index,
|
|
37127
|
+
attId: currentFile.id,
|
|
37128
|
+
name: currentFile.name,
|
|
37129
|
+
listLen: attachmentsList.length
|
|
37130
|
+
}));
|
|
37131
|
+
return index;
|
|
37022
37132
|
}, [attachmentsList, currentFile]);
|
|
37023
37133
|
React.useEffect(function () {
|
|
37024
37134
|
var currentFileId = currentFile === null || currentFile === void 0 ? void 0 : currentFile.id;
|
|
@@ -37030,6 +37140,13 @@ var SliderPopup = function SliderPopup(_ref) {
|
|
|
37030
37140
|
var newIndex = attachmentsList.findIndex(function (item) {
|
|
37031
37141
|
return item.id === currentFileId;
|
|
37032
37142
|
});
|
|
37143
|
+
console.log('[MEDIA_OPEN] 6.list-grew ' + JSON.stringify({
|
|
37144
|
+
prevLen: previousLength,
|
|
37145
|
+
newLen: newLength,
|
|
37146
|
+
attId: currentFileId,
|
|
37147
|
+
newIndex: newIndex,
|
|
37148
|
+
activeFileIndex: activeFileIndex
|
|
37149
|
+
}));
|
|
37033
37150
|
if (newIndex >= 0) {
|
|
37034
37151
|
if (newIndex !== activeFileIndex) {
|
|
37035
37152
|
var newFile = attachmentsList[newIndex];
|
|
@@ -37171,6 +37288,12 @@ var SliderPopup = function SliderPopup(_ref) {
|
|
|
37171
37288
|
clearTimeout(timeout);
|
|
37172
37289
|
}, 400);
|
|
37173
37290
|
if (pageIndex >= 0 && pageIndex < attachmentsList.length) {
|
|
37291
|
+
var _attachmentsList$page, _attachmentsList$page2;
|
|
37292
|
+
console.log('[MEDIA_OPEN] 7.carousel-change ' + JSON.stringify({
|
|
37293
|
+
pageIndex: pageIndex,
|
|
37294
|
+
attId: (_attachmentsList$page = attachmentsList[pageIndex]) === null || _attachmentsList$page === void 0 ? void 0 : _attachmentsList$page.id,
|
|
37295
|
+
name: (_attachmentsList$page2 = attachmentsList[pageIndex]) === null || _attachmentsList$page2 === void 0 ? void 0 : _attachmentsList$page2.name
|
|
37296
|
+
}));
|
|
37174
37297
|
setCurrentFile(attachmentsList[pageIndex]);
|
|
37175
37298
|
setNextButtonDisabled(!attachmentsList[pageIndex + 1]);
|
|
37176
37299
|
setPrevButtonDisabled(!attachmentsList[pageIndex - 1]);
|
|
@@ -44741,6 +44864,12 @@ var Message$1 = function Message(_ref) {
|
|
|
44741
44864
|
clearTimeout(messageActionsTimeout.current);
|
|
44742
44865
|
}
|
|
44743
44866
|
lastMediaItemClickTime = Date.now();
|
|
44867
|
+
console.log('[MEDIA_OPEN] 2.wrapper ' + JSON.stringify({
|
|
44868
|
+
msgId: message.id,
|
|
44869
|
+
attId: attachment === null || attachment === void 0 ? void 0 : attachment.id,
|
|
44870
|
+
name: attachment === null || attachment === void 0 ? void 0 : attachment.name,
|
|
44871
|
+
url: attachment === null || attachment === void 0 ? void 0 : attachment.url
|
|
44872
|
+
}));
|
|
44744
44873
|
setMessageActionsShow(false);
|
|
44745
44874
|
dispatch(setMessageMenuOpenedAC(message.id || message.tid));
|
|
44746
44875
|
if (handleMediaItemClick) {
|
|
@@ -48045,6 +48174,11 @@ var MessageList = function MessageList(_ref) {
|
|
|
48045
48174
|
setMediaFile(null);
|
|
48046
48175
|
}, [channel.id]);
|
|
48047
48176
|
var handleMediaItemClickStable = React.useCallback(function (attachment) {
|
|
48177
|
+
console.log('[MEDIA_OPEN] 3.setMediaFile ' + JSON.stringify({
|
|
48178
|
+
attId: attachment === null || attachment === void 0 ? void 0 : attachment.id,
|
|
48179
|
+
name: attachment === null || attachment === void 0 ? void 0 : attachment.name,
|
|
48180
|
+
skipped: !(attachment !== null && attachment !== void 0 && attachment.id)
|
|
48181
|
+
}));
|
|
48048
48182
|
if (attachment !== null && attachment !== void 0 && attachment.id) setMediaFile(attachment);
|
|
48049
48183
|
}, []);
|
|
48050
48184
|
var renderTimelineMessage = function renderTimelineMessage(_ref2) {
|
|
@@ -52330,17 +52464,19 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
52330
52464
|
if (messageToEdit) {
|
|
52331
52465
|
handleEditMessage();
|
|
52332
52466
|
} else if (messageTextForSend !== null && messageTextForSend !== void 0 && messageTextForSend.trim() || attachments.length && attachments.length > 0) {
|
|
52333
|
-
var
|
|
52467
|
+
var _trimMessageBodyWithA = trimMessageBodyWithAttributes(messageText, messageBodyAttributes),
|
|
52468
|
+
messageTexToSend = _trimMessageBodyWithA.body,
|
|
52469
|
+
adjustedBodyAttributes = _trimMessageBodyWithA.bodyAttributes;
|
|
52334
52470
|
var messageToSend = {
|
|
52335
52471
|
body: messageTexToSend,
|
|
52336
|
-
bodyAttributes:
|
|
52472
|
+
bodyAttributes: adjustedBodyAttributes,
|
|
52337
52473
|
mentionedUsers: [],
|
|
52338
52474
|
attachments: [],
|
|
52339
52475
|
type: 'text'
|
|
52340
52476
|
};
|
|
52341
52477
|
var mentionUsersToSend = [];
|
|
52342
|
-
if (
|
|
52343
|
-
|
|
52478
|
+
if (adjustedBodyAttributes && adjustedBodyAttributes.length) {
|
|
52479
|
+
adjustedBodyAttributes.forEach(function (att) {
|
|
52344
52480
|
if (att.type === 'mention') {
|
|
52345
52481
|
var mentionsToFind = [].concat(mentionedUsers);
|
|
52346
52482
|
var draftMessage = getDraftMessageFromMap(activeChannel.id);
|
|
@@ -52468,12 +52604,14 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
52468
52604
|
}
|
|
52469
52605
|
};
|
|
52470
52606
|
var handleEditMessage = function handleEditMessage() {
|
|
52471
|
-
var
|
|
52607
|
+
var _trimMessageBodyWithA2 = trimMessageBodyWithAttributes(editMessageText, messageBodyAttributes),
|
|
52608
|
+
messageTexToSend = _trimMessageBodyWithA2.body,
|
|
52609
|
+
adjustedBodyAttributes = _trimMessageBodyWithA2.bodyAttributes;
|
|
52472
52610
|
var hasTextChanged = messageTexToSend !== messageToEdit.body;
|
|
52473
52611
|
var normalizeAttrs = function normalizeAttrs(attrs) {
|
|
52474
52612
|
return !attrs || attrs.length === 0 ? [] : attrs;
|
|
52475
52613
|
};
|
|
52476
|
-
var hasAttributesChanged = !compareMessageBodyAttributes(normalizeAttrs(
|
|
52614
|
+
var hasAttributesChanged = !compareMessageBodyAttributes(normalizeAttrs(adjustedBodyAttributes), normalizeAttrs(messageToEdit.bodyAttributes));
|
|
52477
52615
|
if (!hasTextChanged && !hasAttributesChanged) {
|
|
52478
52616
|
handleCloseEditMode();
|
|
52479
52617
|
return;
|
|
@@ -52517,8 +52655,8 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
52517
52655
|
var mentionedUsersPositions = [];
|
|
52518
52656
|
var mentionUsersToSend = [];
|
|
52519
52657
|
if (mentionedUsers && mentionedUsers.length) {
|
|
52520
|
-
if (
|
|
52521
|
-
|
|
52658
|
+
if (adjustedBodyAttributes && adjustedBodyAttributes.length) {
|
|
52659
|
+
adjustedBodyAttributes.forEach(function (att) {
|
|
52522
52660
|
if (att.type === 'mention') {
|
|
52523
52661
|
var mentionsToFind = [].concat(mentionedUsers);
|
|
52524
52662
|
var draftMessage = getDraftMessageFromMap(activeChannel.id);
|
|
@@ -52540,7 +52678,7 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
52540
52678
|
var messageToSend = _extends({}, messageToEdit, {
|
|
52541
52679
|
attachments: updatedAttachments,
|
|
52542
52680
|
metadata: mentionedUsersPositions,
|
|
52543
|
-
bodyAttributes:
|
|
52681
|
+
bodyAttributes: adjustedBodyAttributes,
|
|
52544
52682
|
mentionedUsers: mentionUsersToSend,
|
|
52545
52683
|
body: messageTexToSend
|
|
52546
52684
|
});
|
package/index.modern.js
CHANGED
|
@@ -8478,6 +8478,31 @@ var getAllowEditDeleteIncomingMessage = function getAllowEditDeleteIncomingMessa
|
|
|
8478
8478
|
var compareMessageBodyAttributes = function compareMessageBodyAttributes(attributes1, attributes2) {
|
|
8479
8479
|
return JSON.stringify(attributes1) === JSON.stringify(attributes2);
|
|
8480
8480
|
};
|
|
8481
|
+
var trimMessageBodyWithAttributes = function trimMessageBodyWithAttributes(text, attributes) {
|
|
8482
|
+
var body = text.trim();
|
|
8483
|
+
var leadingTrim = text.length - text.trimStart().length;
|
|
8484
|
+
var bodyAttributes = (attributes || []).map(function (att) {
|
|
8485
|
+
var offset = att.offset - leadingTrim;
|
|
8486
|
+
var length = att.length;
|
|
8487
|
+
if (offset < 0) {
|
|
8488
|
+
length += offset;
|
|
8489
|
+
offset = 0;
|
|
8490
|
+
}
|
|
8491
|
+
if (offset + length > body.length) {
|
|
8492
|
+
length = body.length - offset;
|
|
8493
|
+
}
|
|
8494
|
+
return _extends({}, att, {
|
|
8495
|
+
offset: offset,
|
|
8496
|
+
length: length
|
|
8497
|
+
});
|
|
8498
|
+
}).filter(function (att) {
|
|
8499
|
+
return att.length > 0 && att.offset >= 0 && att.offset < body.length;
|
|
8500
|
+
});
|
|
8501
|
+
return {
|
|
8502
|
+
body: body,
|
|
8503
|
+
bodyAttributes: bodyAttributes
|
|
8504
|
+
};
|
|
8505
|
+
};
|
|
8481
8506
|
var bodyAttributesMapByType = {
|
|
8482
8507
|
1: ['bold'],
|
|
8483
8508
|
2: ['italic'],
|
|
@@ -15994,6 +16019,10 @@ var SDKErrorTypeEnum = {
|
|
|
15994
16019
|
Authentication: {
|
|
15995
16020
|
value: 'Authentication',
|
|
15996
16021
|
isResendable: true
|
|
16022
|
+
},
|
|
16023
|
+
AttachmentUnavailable: {
|
|
16024
|
+
value: 'AttachmentUnavailable',
|
|
16025
|
+
isResendable: false
|
|
15997
16026
|
}
|
|
15998
16027
|
};
|
|
15999
16028
|
var fromValue = function fromValue(value) {
|
|
@@ -16011,6 +16040,11 @@ var isResendableError = function isResendableError(value) {
|
|
|
16011
16040
|
var errorType = fromValue(value);
|
|
16012
16041
|
return (_errorType$isResendab = errorType === null || errorType === void 0 ? void 0 : errorType.isResendable) != null ? _errorType$isResendab : true;
|
|
16013
16042
|
};
|
|
16043
|
+
var createAttachmentUnavailableError = function createAttachmentUnavailableError(message) {
|
|
16044
|
+
var error = new Error(message);
|
|
16045
|
+
error.type = SDKErrorTypeEnum.AttachmentUnavailable.value;
|
|
16046
|
+
return error;
|
|
16047
|
+
};
|
|
16014
16048
|
|
|
16015
16049
|
var _excluded$1 = ["lastMessage"];
|
|
16016
16050
|
var _marked = /*#__PURE__*/_regenerator().m(setMessageListLoading),
|
|
@@ -16073,6 +16107,8 @@ var _marked = /*#__PURE__*/_regenerator().m(setMessageListLoading),
|
|
|
16073
16107
|
_marked56 = /*#__PURE__*/_regenerator().m(loadMorePollVotes),
|
|
16074
16108
|
_marked57 = /*#__PURE__*/_regenerator().m(refreshCacheAroundMessage),
|
|
16075
16109
|
_marked58 = /*#__PURE__*/_regenerator().m(MessageSaga);
|
|
16110
|
+
var MAX_AUTO_RESEND_ATTEMPTS = 5;
|
|
16111
|
+
var autoResendAttempts = new Map();
|
|
16076
16112
|
var loadMoreMessagesInFlight = new Set();
|
|
16077
16113
|
var prefetchInFlight = new Set();
|
|
16078
16114
|
var queuedPrefetchRequests = new Map();
|
|
@@ -16296,6 +16332,7 @@ var handleUploadAttachments = function handleUploadAttachments(attachments, mess
|
|
|
16296
16332
|
try {
|
|
16297
16333
|
return Promise.resolve(Promise.all(attachments.map(function (attachment) {
|
|
16298
16334
|
try {
|
|
16335
|
+
var _attachment$url, _attachment$url$type;
|
|
16299
16336
|
var _temp10 = function _temp10() {
|
|
16300
16337
|
function _temp0() {
|
|
16301
16338
|
store.dispatch(updateAttachmentUploadingStateAC(UPLOAD_STATE.SUCCESS, attachment.tid));
|
|
@@ -16317,14 +16354,15 @@ var handleUploadAttachments = function handleUploadAttachments(attachments, mess
|
|
|
16317
16354
|
return attachmentToSend;
|
|
16318
16355
|
}
|
|
16319
16356
|
var _temp9 = function () {
|
|
16320
|
-
if (!attachment.cachedUrl &&
|
|
16357
|
+
if (!attachment.cachedUrl && fileType === 'image') {
|
|
16321
16358
|
return _catch(function () {
|
|
16322
16359
|
var _temp2 = function () {
|
|
16323
16360
|
if (blobLocal && blobLocal.type.startsWith('image/')) {
|
|
16361
|
+
var _attachment, _attachment2;
|
|
16324
16362
|
var file = attachment.url instanceof File ? attachment.url : new File([attachment.url], attachment.name || 'image', {
|
|
16325
16363
|
type: attachment.url.type || blobLocal.type
|
|
16326
16364
|
});
|
|
16327
|
-
var _calculateRenderedIma = calculateRenderedImageWidth((attachment === null ||
|
|
16365
|
+
var _calculateRenderedIma = calculateRenderedImageWidth(((_attachment = attachment) === null || _attachment === void 0 ? void 0 : _attachment.metadata.szw) || 1280, ((_attachment2 = attachment) === null || _attachment2 === void 0 ? void 0 : _attachment2.metadata.szh) || 1080),
|
|
16328
16366
|
newWidth = _calculateRenderedIma[0],
|
|
16329
16367
|
newHeight = _calculateRenderedIma[1];
|
|
16330
16368
|
return Promise.resolve(resizeImageWithPica(file, newWidth, newHeight, 1)).then(function (_ref) {
|
|
@@ -16362,10 +16400,11 @@ var handleUploadAttachments = function handleUploadAttachments(attachments, mess
|
|
|
16362
16400
|
});
|
|
16363
16401
|
} else {
|
|
16364
16402
|
var _temp11 = function () {
|
|
16365
|
-
if (!attachment.cachedUrl &&
|
|
16403
|
+
if (!attachment.cachedUrl && fileType === 'video') {
|
|
16366
16404
|
var _temp7 = function () {
|
|
16367
16405
|
if (blobLocal) {
|
|
16368
|
-
var
|
|
16406
|
+
var _attachment3, _attachment4;
|
|
16407
|
+
var _calculateRenderedIma2 = calculateRenderedImageWidth(((_attachment3 = attachment) === null || _attachment3 === void 0 ? void 0 : _attachment3.metadata.szw) || 1280, ((_attachment4 = attachment) === null || _attachment4 === void 0 ? void 0 : _attachment4.metadata.szh) || 1080),
|
|
16369
16408
|
newWidth = _calculateRenderedIma2[0],
|
|
16370
16409
|
newHeight = _calculateRenderedIma2[1];
|
|
16371
16410
|
return Promise.resolve(getVideoFirstFrame(blobLocal, newWidth, newHeight)).then(function (result) {
|
|
@@ -16423,7 +16462,19 @@ var handleUploadAttachments = function handleUploadAttachments(attachments, mess
|
|
|
16423
16462
|
total = _ref2.total;
|
|
16424
16463
|
store.dispatch(updateAttachmentUploadingProgressAC(loaded, total, attachment.tid));
|
|
16425
16464
|
};
|
|
16426
|
-
|
|
16465
|
+
if (!attachment.cachedUrl && !(attachment.url instanceof Blob)) {
|
|
16466
|
+
var _getPendingAttachment;
|
|
16467
|
+
var pendingFile = (_getPendingAttachment = getPendingAttachment(attachment.tid)) === null || _getPendingAttachment === void 0 ? void 0 : _getPendingAttachment.file;
|
|
16468
|
+
if (pendingFile instanceof Blob) {
|
|
16469
|
+
attachment = _extends({}, attachment, {
|
|
16470
|
+
url: pendingFile,
|
|
16471
|
+
data: pendingFile
|
|
16472
|
+
});
|
|
16473
|
+
} else {
|
|
16474
|
+
throw createAttachmentUnavailableError("Attachment file for tid " + attachment.tid + " is no longer available for upload");
|
|
16475
|
+
}
|
|
16476
|
+
}
|
|
16477
|
+
var fileType = (_attachment$url = attachment.url) === null || _attachment$url === void 0 ? void 0 : (_attachment$url$type = _attachment$url.type) === null || _attachment$url$type === void 0 ? void 0 : _attachment$url$type.split('/')[0];
|
|
16427
16478
|
var fileSize = attachment.size;
|
|
16428
16479
|
var filePath;
|
|
16429
16480
|
var uriLocal;
|
|
@@ -16926,11 +16977,19 @@ function sendMessage(action) {
|
|
|
16926
16977
|
break;
|
|
16927
16978
|
}
|
|
16928
16979
|
_loop2 = /*#__PURE__*/_regenerator().m(function _callee3() {
|
|
16929
|
-
var attachment, uri, attachmentBuilder, messageAttachment, handleUpdateUploadProgress, _messageBuilder, _messageToSend, messageForSend, _pending;
|
|
16980
|
+
var attachment, _getPendingAttachment2, pendingFile, uri, attachmentBuilder, messageAttachment, handleUpdateUploadProgress, _messageBuilder, _messageToSend, messageForSend, _pending;
|
|
16930
16981
|
return _regenerator().w(function (_context11) {
|
|
16931
16982
|
while (1) switch (_context11.n) {
|
|
16932
16983
|
case 0:
|
|
16933
16984
|
attachment = mediaAttachments[i];
|
|
16985
|
+
if (customUploader && !attachment.cachedUrl && !(attachment.data instanceof Blob)) {
|
|
16986
|
+
pendingFile = (_getPendingAttachment2 = getPendingAttachment(attachment.tid)) === null || _getPendingAttachment2 === void 0 ? void 0 : _getPendingAttachment2.file;
|
|
16987
|
+
if (pendingFile instanceof Blob) {
|
|
16988
|
+
attachment = _extends({}, attachment, {
|
|
16989
|
+
data: pendingFile
|
|
16990
|
+
});
|
|
16991
|
+
}
|
|
16992
|
+
}
|
|
16934
16993
|
if (attachment.cachedUrl) {
|
|
16935
16994
|
uri = attachment.cachedUrl;
|
|
16936
16995
|
}
|
|
@@ -17231,6 +17290,9 @@ function sendMessage(action) {
|
|
|
17231
17290
|
return call(channel.sendMessage, messageToSend);
|
|
17232
17291
|
case 5:
|
|
17233
17292
|
messageResponse = _context12.v;
|
|
17293
|
+
if (messageToSend.tid) {
|
|
17294
|
+
autoResendAttempts["delete"](messageToSend.tid);
|
|
17295
|
+
}
|
|
17234
17296
|
if (!customUploader) {
|
|
17235
17297
|
_context12.n = 10;
|
|
17236
17298
|
break;
|
|
@@ -17763,12 +17825,17 @@ function forwardMessage(action) {
|
|
|
17763
17825
|
}
|
|
17764
17826
|
function resendMessage(action) {
|
|
17765
17827
|
var _message$attachments;
|
|
17766
|
-
var payload,
|
|
17828
|
+
var payload, payloadMessage, connectionState, channelId, liveMessage, message, attachments, sendAttachmentsAsSeparateMessage, isVoiceMessage;
|
|
17767
17829
|
return _regenerator().w(function (_context16) {
|
|
17768
17830
|
while (1) switch (_context16.n) {
|
|
17769
17831
|
case 0:
|
|
17770
17832
|
payload = action.payload;
|
|
17771
|
-
|
|
17833
|
+
payloadMessage = payload.message, connectionState = payload.connectionState, channelId = payload.channelId;
|
|
17834
|
+
liveMessage = payloadMessage !== null && payloadMessage !== void 0 && payloadMessage.tid || payloadMessage !== null && payloadMessage !== void 0 && payloadMessage.id ? getMessageFromMap(channelId, payloadMessage.tid || payloadMessage.id) : null;
|
|
17835
|
+
message = liveMessage || payloadMessage;
|
|
17836
|
+
if (message !== null && message !== void 0 && message.tid || message !== null && message !== void 0 && message.id) {
|
|
17837
|
+
autoResendAttempts["delete"](message.tid || message.id);
|
|
17838
|
+
}
|
|
17772
17839
|
attachments = message === null || message === void 0 ? void 0 : (_message$attachments = message.attachments) === null || _message$attachments === void 0 ? void 0 : _message$attachments.filter(function (att) {
|
|
17773
17840
|
return (att === null || att === void 0 ? void 0 : att.type) !== attachmentTypes.link;
|
|
17774
17841
|
});
|
|
@@ -17963,7 +18030,7 @@ function editMessage(action) {
|
|
|
17963
18030
|
}, _marked14, null, [[0, 8]]);
|
|
17964
18031
|
}
|
|
17965
18032
|
var sendPendingMessages = /*#__PURE__*/_regenerator().m(function _callee5(connectionState) {
|
|
17966
|
-
var pendingMessagesMap, channelId, _iterator3, _step3, _msg$attachments, msg, attachments, pendingPollActionsMap, _t7, _t8, _t9;
|
|
18033
|
+
var pendingMessagesMap, channelId, _iterator3, _step3, _msg$attachments, msg, attachments, resendKey, attempts, pendingPollActionsMap, _t7, _t8, _t9;
|
|
17967
18034
|
return _regenerator().w(function (_context19) {
|
|
17968
18035
|
while (1) switch (_context19.p = _context19.n) {
|
|
17969
18036
|
case 0:
|
|
@@ -17971,26 +18038,41 @@ var sendPendingMessages = /*#__PURE__*/_regenerator().m(function _callee5(connec
|
|
|
17971
18038
|
_t7 = _regeneratorKeys(pendingMessagesMap);
|
|
17972
18039
|
case 1:
|
|
17973
18040
|
if ((_t8 = _t7()).done) {
|
|
17974
|
-
_context19.n =
|
|
18041
|
+
_context19.n = 13;
|
|
17975
18042
|
break;
|
|
17976
18043
|
}
|
|
17977
18044
|
channelId = _t8.value;
|
|
17978
18045
|
_iterator3 = _createForOfIteratorHelperLoose(pendingMessagesMap[channelId]);
|
|
17979
18046
|
case 2:
|
|
17980
18047
|
if ((_step3 = _iterator3()).done) {
|
|
17981
|
-
_context19.n =
|
|
18048
|
+
_context19.n = 12;
|
|
17982
18049
|
break;
|
|
17983
18050
|
}
|
|
17984
18051
|
msg = _step3.value;
|
|
17985
18052
|
attachments = msg === null || msg === void 0 ? void 0 : (_msg$attachments = msg.attachments) === null || _msg$attachments === void 0 ? void 0 : _msg$attachments.filter(function (att) {
|
|
17986
18053
|
return (att === null || att === void 0 ? void 0 : att.type) !== attachmentTypes.link;
|
|
17987
18054
|
});
|
|
17988
|
-
|
|
18055
|
+
resendKey = (msg === null || msg === void 0 ? void 0 : msg.tid) || (msg === null || msg === void 0 ? void 0 : msg.id);
|
|
18056
|
+
if (!resendKey) {
|
|
18057
|
+
_context19.n = 4;
|
|
18058
|
+
break;
|
|
18059
|
+
}
|
|
18060
|
+
attempts = autoResendAttempts.get(resendKey) || 0;
|
|
18061
|
+
if (!(attempts >= MAX_AUTO_RESEND_ATTEMPTS)) {
|
|
18062
|
+
_context19.n = 3;
|
|
18063
|
+
break;
|
|
18064
|
+
}
|
|
18065
|
+
log.info("Skipping auto-resend of message " + resendKey + " after " + attempts + " failed attempts");
|
|
18066
|
+
return _context19.a(3, 11);
|
|
18067
|
+
case 3:
|
|
18068
|
+
autoResendAttempts.set(resendKey, attempts + 1);
|
|
18069
|
+
case 4:
|
|
18070
|
+
_context19.p = 4;
|
|
17989
18071
|
if (!(msg !== null && msg !== void 0 && msg.forwardingDetails)) {
|
|
17990
|
-
_context19.n =
|
|
18072
|
+
_context19.n = 6;
|
|
17991
18073
|
break;
|
|
17992
18074
|
}
|
|
17993
|
-
_context19.n =
|
|
18075
|
+
_context19.n = 5;
|
|
17994
18076
|
return call(forwardMessage, {
|
|
17995
18077
|
type: RESEND_MESSAGE,
|
|
17996
18078
|
payload: {
|
|
@@ -18000,15 +18082,15 @@ var sendPendingMessages = /*#__PURE__*/_regenerator().m(function _callee5(connec
|
|
|
18000
18082
|
isForward: true
|
|
18001
18083
|
}
|
|
18002
18084
|
});
|
|
18003
|
-
case 4:
|
|
18004
|
-
_context19.n = 8;
|
|
18005
|
-
break;
|
|
18006
18085
|
case 5:
|
|
18086
|
+
_context19.n = 9;
|
|
18087
|
+
break;
|
|
18088
|
+
case 6:
|
|
18007
18089
|
if (!(attachments && attachments.length > 0)) {
|
|
18008
|
-
_context19.n =
|
|
18090
|
+
_context19.n = 8;
|
|
18009
18091
|
break;
|
|
18010
18092
|
}
|
|
18011
|
-
_context19.n =
|
|
18093
|
+
_context19.n = 7;
|
|
18012
18094
|
return call(sendMessage, {
|
|
18013
18095
|
type: RESEND_MESSAGE,
|
|
18014
18096
|
payload: {
|
|
@@ -18018,11 +18100,11 @@ var sendPendingMessages = /*#__PURE__*/_regenerator().m(function _callee5(connec
|
|
|
18018
18100
|
sendAttachmentsAsSeparateMessage: false
|
|
18019
18101
|
}
|
|
18020
18102
|
});
|
|
18021
|
-
case 6:
|
|
18022
|
-
_context19.n = 8;
|
|
18023
|
-
break;
|
|
18024
18103
|
case 7:
|
|
18025
|
-
_context19.n =
|
|
18104
|
+
_context19.n = 9;
|
|
18105
|
+
break;
|
|
18106
|
+
case 8:
|
|
18107
|
+
_context19.n = 9;
|
|
18026
18108
|
return call(sendTextMessage, {
|
|
18027
18109
|
type: RESEND_MESSAGE,
|
|
18028
18110
|
payload: {
|
|
@@ -18031,31 +18113,31 @@ var sendPendingMessages = /*#__PURE__*/_regenerator().m(function _callee5(connec
|
|
|
18031
18113
|
channelId: channelId
|
|
18032
18114
|
}
|
|
18033
18115
|
});
|
|
18034
|
-
case 8:
|
|
18035
|
-
_context19.n = 10;
|
|
18036
|
-
break;
|
|
18037
18116
|
case 9:
|
|
18038
|
-
_context19.
|
|
18117
|
+
_context19.n = 11;
|
|
18118
|
+
break;
|
|
18119
|
+
case 10:
|
|
18120
|
+
_context19.p = 10;
|
|
18039
18121
|
_t9 = _context19.v;
|
|
18040
18122
|
log.error("Failed to send pending message " + (msg.tid || msg.id) + ":", _t9);
|
|
18041
|
-
case
|
|
18123
|
+
case 11:
|
|
18042
18124
|
_context19.n = 2;
|
|
18043
18125
|
break;
|
|
18044
|
-
case
|
|
18126
|
+
case 12:
|
|
18045
18127
|
_context19.n = 1;
|
|
18046
18128
|
break;
|
|
18047
|
-
case
|
|
18129
|
+
case 13:
|
|
18048
18130
|
pendingPollActionsMap = store.getState().MessageReducer.pendingPollActions;
|
|
18049
18131
|
if (!(pendingPollActionsMap && Object.keys(pendingPollActionsMap).length > 0)) {
|
|
18050
|
-
_context19.n =
|
|
18132
|
+
_context19.n = 14;
|
|
18051
18133
|
break;
|
|
18052
18134
|
}
|
|
18053
|
-
_context19.n =
|
|
18135
|
+
_context19.n = 14;
|
|
18054
18136
|
return put(resendPendingPollActionsAC(connectionState));
|
|
18055
|
-
case
|
|
18137
|
+
case 14:
|
|
18056
18138
|
return _context19.a(2);
|
|
18057
18139
|
}
|
|
18058
|
-
}, _callee5, null, [[
|
|
18140
|
+
}, _callee5, null, [[4, 10]]);
|
|
18059
18141
|
});
|
|
18060
18142
|
var shouldAppendPendingMessages = function shouldAppendPendingMessages(channelOrId, messages, options) {
|
|
18061
18143
|
var _getStoredChannel9, _getStoredChannel9$la, _channelOrId$lastMess;
|
|
@@ -18280,7 +18362,7 @@ function loadOGMetadataForLinkMessages(messages, getFromServer) {
|
|
|
18280
18362
|
getFromServer = true;
|
|
18281
18363
|
}
|
|
18282
18364
|
return /*#__PURE__*/_regenerator().m(function _callee6() {
|
|
18283
|
-
var i, _message$attachments2, message, isOnlyLinkAttachments, firstAttachment, j,
|
|
18365
|
+
var i, _message$attachments2, message, isOnlyLinkAttachments, firstAttachment, j, _attachment5, _firstAttachment, _store$getState$Messa, _firstAttachment2, _firstAttachment3, _firstAttachment4, metadata, storedData;
|
|
18284
18366
|
return _regenerator().w(function (_context22) {
|
|
18285
18367
|
while (1) switch (_context22.n) {
|
|
18286
18368
|
case 0:
|
|
@@ -18309,13 +18391,13 @@ function loadOGMetadataForLinkMessages(messages, getFromServer) {
|
|
|
18309
18391
|
_context22.n = 6;
|
|
18310
18392
|
break;
|
|
18311
18393
|
}
|
|
18312
|
-
|
|
18313
|
-
if (!(
|
|
18394
|
+
_attachment5 = message.attachments[j];
|
|
18395
|
+
if (!(_attachment5.type === attachmentTypes.link)) {
|
|
18314
18396
|
_context22.n = 4;
|
|
18315
18397
|
break;
|
|
18316
18398
|
}
|
|
18317
18399
|
if (!firstAttachment) {
|
|
18318
|
-
firstAttachment =
|
|
18400
|
+
firstAttachment = _attachment5;
|
|
18319
18401
|
}
|
|
18320
18402
|
_context22.n = 5;
|
|
18321
18403
|
break;
|
|
@@ -20594,7 +20676,7 @@ function loadMoreReactions(action) {
|
|
|
20594
20676
|
}
|
|
20595
20677
|
function getMessageAttachments(action) {
|
|
20596
20678
|
var _store$getState$Messa2;
|
|
20597
|
-
var _action$payload7, channelId, attachmentType, limit, direction, attachmentId, forPopup, cacheKey, cachedAttachments, SceytChatClient, typeList, AttachmentByTypeQueryBuilder, AttachmentByTypeQuery, result, attachments, attachmentIndex, hasPrev, hasNext, freshAttachments, _t39;
|
|
20679
|
+
var _action$payload7, channelId, attachmentType, limit, direction, attachmentId, forPopup, cacheKey, cachedAttachments, SceytChatClient, typeList, AttachmentByTypeQueryBuilder, AttachmentByTypeQuery, result, attachments, _attachments$2, _attachments, attachmentIndex, hasPrev, hasNext, freshAttachments, _t39;
|
|
20598
20680
|
return _regenerator().w(function (_context42) {
|
|
20599
20681
|
while (1) switch (_context42.p = _context42.n) {
|
|
20600
20682
|
case 0:
|
|
@@ -20673,6 +20755,16 @@ function getMessageAttachments(action) {
|
|
|
20673
20755
|
break;
|
|
20674
20756
|
}
|
|
20675
20757
|
query.AttachmentByTypeQueryForPopup = AttachmentByTypeQuery;
|
|
20758
|
+
console.log('[MEDIA_OPEN] 8.saga-forPopup ' + JSON.stringify({
|
|
20759
|
+
requestedAttId: attachmentId,
|
|
20760
|
+
direction: direction,
|
|
20761
|
+
returned: attachments.length,
|
|
20762
|
+
containsRequested: attachments.some(function (a) {
|
|
20763
|
+
return a.id === attachmentId;
|
|
20764
|
+
}),
|
|
20765
|
+
firstId: (_attachments$2 = attachments[0]) === null || _attachments$2 === void 0 ? void 0 : _attachments$2.id,
|
|
20766
|
+
lastId: (_attachments = attachments[attachments.length - 1]) === null || _attachments === void 0 ? void 0 : _attachments.id
|
|
20767
|
+
}));
|
|
20676
20768
|
_context42.n = 12;
|
|
20677
20769
|
return put(setAttachmentsForPopupAC(JSON.parse(JSON.stringify(attachments))));
|
|
20678
20770
|
case 12:
|
|
@@ -36987,18 +37079,36 @@ var SliderPopup = function SliderPopup(_ref) {
|
|
|
36987
37079
|
log.error('Error getting initial attachment from cache:', error);
|
|
36988
37080
|
});
|
|
36989
37081
|
}
|
|
36990
|
-
|
|
37082
|
+
var foundInStaleList = !!attachmentsList.find(function (item) {
|
|
36991
37083
|
return item.id === currentMediaFile.id;
|
|
36992
|
-
})
|
|
37084
|
+
});
|
|
37085
|
+
console.log('[MEDIA_OPEN] 4.slider-mount ' + JSON.stringify({
|
|
37086
|
+
attId: currentMediaFile.id,
|
|
37087
|
+
name: currentMediaFile.name,
|
|
37088
|
+
msgId: currentMediaFile.messageId,
|
|
37089
|
+
staleListLen: attachmentsList.length,
|
|
37090
|
+
foundInStaleList: foundInStaleList,
|
|
37091
|
+
staleListIds: attachmentsList.slice(0, 5).map(function (item) {
|
|
37092
|
+
return item.id;
|
|
37093
|
+
})
|
|
37094
|
+
}));
|
|
37095
|
+
if (!foundInStaleList) {
|
|
36993
37096
|
dispatch(setAttachmentsForPopupAC([currentMediaFile]));
|
|
36994
37097
|
}
|
|
36995
37098
|
dispatch(getAttachmentsAC(channel.id, channelDetailsTabs.media, 34, queryDirection.NEAR, currentMediaFile.id, true));
|
|
36996
37099
|
}, []);
|
|
36997
37100
|
var activeFileIndex = useMemo(function () {
|
|
36998
37101
|
if (!(currentFile !== null && currentFile !== void 0 && currentFile.id)) return -1;
|
|
36999
|
-
|
|
37102
|
+
var index = attachmentsList.findIndex(function (item) {
|
|
37000
37103
|
return item.id === currentFile.id;
|
|
37001
37104
|
});
|
|
37105
|
+
console.log('[MEDIA_OPEN] 5.activeIndex ' + JSON.stringify({
|
|
37106
|
+
index: index,
|
|
37107
|
+
attId: currentFile.id,
|
|
37108
|
+
name: currentFile.name,
|
|
37109
|
+
listLen: attachmentsList.length
|
|
37110
|
+
}));
|
|
37111
|
+
return index;
|
|
37002
37112
|
}, [attachmentsList, currentFile]);
|
|
37003
37113
|
useEffect(function () {
|
|
37004
37114
|
var currentFileId = currentFile === null || currentFile === void 0 ? void 0 : currentFile.id;
|
|
@@ -37010,6 +37120,13 @@ var SliderPopup = function SliderPopup(_ref) {
|
|
|
37010
37120
|
var newIndex = attachmentsList.findIndex(function (item) {
|
|
37011
37121
|
return item.id === currentFileId;
|
|
37012
37122
|
});
|
|
37123
|
+
console.log('[MEDIA_OPEN] 6.list-grew ' + JSON.stringify({
|
|
37124
|
+
prevLen: previousLength,
|
|
37125
|
+
newLen: newLength,
|
|
37126
|
+
attId: currentFileId,
|
|
37127
|
+
newIndex: newIndex,
|
|
37128
|
+
activeFileIndex: activeFileIndex
|
|
37129
|
+
}));
|
|
37013
37130
|
if (newIndex >= 0) {
|
|
37014
37131
|
if (newIndex !== activeFileIndex) {
|
|
37015
37132
|
var newFile = attachmentsList[newIndex];
|
|
@@ -37151,6 +37268,12 @@ var SliderPopup = function SliderPopup(_ref) {
|
|
|
37151
37268
|
clearTimeout(timeout);
|
|
37152
37269
|
}, 400);
|
|
37153
37270
|
if (pageIndex >= 0 && pageIndex < attachmentsList.length) {
|
|
37271
|
+
var _attachmentsList$page, _attachmentsList$page2;
|
|
37272
|
+
console.log('[MEDIA_OPEN] 7.carousel-change ' + JSON.stringify({
|
|
37273
|
+
pageIndex: pageIndex,
|
|
37274
|
+
attId: (_attachmentsList$page = attachmentsList[pageIndex]) === null || _attachmentsList$page === void 0 ? void 0 : _attachmentsList$page.id,
|
|
37275
|
+
name: (_attachmentsList$page2 = attachmentsList[pageIndex]) === null || _attachmentsList$page2 === void 0 ? void 0 : _attachmentsList$page2.name
|
|
37276
|
+
}));
|
|
37154
37277
|
setCurrentFile(attachmentsList[pageIndex]);
|
|
37155
37278
|
setNextButtonDisabled(!attachmentsList[pageIndex + 1]);
|
|
37156
37279
|
setPrevButtonDisabled(!attachmentsList[pageIndex - 1]);
|
|
@@ -44721,6 +44844,12 @@ var Message$1 = function Message(_ref) {
|
|
|
44721
44844
|
clearTimeout(messageActionsTimeout.current);
|
|
44722
44845
|
}
|
|
44723
44846
|
lastMediaItemClickTime = Date.now();
|
|
44847
|
+
console.log('[MEDIA_OPEN] 2.wrapper ' + JSON.stringify({
|
|
44848
|
+
msgId: message.id,
|
|
44849
|
+
attId: attachment === null || attachment === void 0 ? void 0 : attachment.id,
|
|
44850
|
+
name: attachment === null || attachment === void 0 ? void 0 : attachment.name,
|
|
44851
|
+
url: attachment === null || attachment === void 0 ? void 0 : attachment.url
|
|
44852
|
+
}));
|
|
44724
44853
|
setMessageActionsShow(false);
|
|
44725
44854
|
dispatch(setMessageMenuOpenedAC(message.id || message.tid));
|
|
44726
44855
|
if (handleMediaItemClick) {
|
|
@@ -48025,6 +48154,11 @@ var MessageList = function MessageList(_ref) {
|
|
|
48025
48154
|
setMediaFile(null);
|
|
48026
48155
|
}, [channel.id]);
|
|
48027
48156
|
var handleMediaItemClickStable = useCallback(function (attachment) {
|
|
48157
|
+
console.log('[MEDIA_OPEN] 3.setMediaFile ' + JSON.stringify({
|
|
48158
|
+
attId: attachment === null || attachment === void 0 ? void 0 : attachment.id,
|
|
48159
|
+
name: attachment === null || attachment === void 0 ? void 0 : attachment.name,
|
|
48160
|
+
skipped: !(attachment !== null && attachment !== void 0 && attachment.id)
|
|
48161
|
+
}));
|
|
48028
48162
|
if (attachment !== null && attachment !== void 0 && attachment.id) setMediaFile(attachment);
|
|
48029
48163
|
}, []);
|
|
48030
48164
|
var renderTimelineMessage = function renderTimelineMessage(_ref2) {
|
|
@@ -52310,17 +52444,19 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
52310
52444
|
if (messageToEdit) {
|
|
52311
52445
|
handleEditMessage();
|
|
52312
52446
|
} else if (messageTextForSend !== null && messageTextForSend !== void 0 && messageTextForSend.trim() || attachments.length && attachments.length > 0) {
|
|
52313
|
-
var
|
|
52447
|
+
var _trimMessageBodyWithA = trimMessageBodyWithAttributes(messageText, messageBodyAttributes),
|
|
52448
|
+
messageTexToSend = _trimMessageBodyWithA.body,
|
|
52449
|
+
adjustedBodyAttributes = _trimMessageBodyWithA.bodyAttributes;
|
|
52314
52450
|
var messageToSend = {
|
|
52315
52451
|
body: messageTexToSend,
|
|
52316
|
-
bodyAttributes:
|
|
52452
|
+
bodyAttributes: adjustedBodyAttributes,
|
|
52317
52453
|
mentionedUsers: [],
|
|
52318
52454
|
attachments: [],
|
|
52319
52455
|
type: 'text'
|
|
52320
52456
|
};
|
|
52321
52457
|
var mentionUsersToSend = [];
|
|
52322
|
-
if (
|
|
52323
|
-
|
|
52458
|
+
if (adjustedBodyAttributes && adjustedBodyAttributes.length) {
|
|
52459
|
+
adjustedBodyAttributes.forEach(function (att) {
|
|
52324
52460
|
if (att.type === 'mention') {
|
|
52325
52461
|
var mentionsToFind = [].concat(mentionedUsers);
|
|
52326
52462
|
var draftMessage = getDraftMessageFromMap(activeChannel.id);
|
|
@@ -52448,12 +52584,14 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
52448
52584
|
}
|
|
52449
52585
|
};
|
|
52450
52586
|
var handleEditMessage = function handleEditMessage() {
|
|
52451
|
-
var
|
|
52587
|
+
var _trimMessageBodyWithA2 = trimMessageBodyWithAttributes(editMessageText, messageBodyAttributes),
|
|
52588
|
+
messageTexToSend = _trimMessageBodyWithA2.body,
|
|
52589
|
+
adjustedBodyAttributes = _trimMessageBodyWithA2.bodyAttributes;
|
|
52452
52590
|
var hasTextChanged = messageTexToSend !== messageToEdit.body;
|
|
52453
52591
|
var normalizeAttrs = function normalizeAttrs(attrs) {
|
|
52454
52592
|
return !attrs || attrs.length === 0 ? [] : attrs;
|
|
52455
52593
|
};
|
|
52456
|
-
var hasAttributesChanged = !compareMessageBodyAttributes(normalizeAttrs(
|
|
52594
|
+
var hasAttributesChanged = !compareMessageBodyAttributes(normalizeAttrs(adjustedBodyAttributes), normalizeAttrs(messageToEdit.bodyAttributes));
|
|
52457
52595
|
if (!hasTextChanged && !hasAttributesChanged) {
|
|
52458
52596
|
handleCloseEditMode();
|
|
52459
52597
|
return;
|
|
@@ -52497,8 +52635,8 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
52497
52635
|
var mentionedUsersPositions = [];
|
|
52498
52636
|
var mentionUsersToSend = [];
|
|
52499
52637
|
if (mentionedUsers && mentionedUsers.length) {
|
|
52500
|
-
if (
|
|
52501
|
-
|
|
52638
|
+
if (adjustedBodyAttributes && adjustedBodyAttributes.length) {
|
|
52639
|
+
adjustedBodyAttributes.forEach(function (att) {
|
|
52502
52640
|
if (att.type === 'mention') {
|
|
52503
52641
|
var mentionsToFind = [].concat(mentionedUsers);
|
|
52504
52642
|
var draftMessage = getDraftMessageFromMap(activeChannel.id);
|
|
@@ -52520,7 +52658,7 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
52520
52658
|
var messageToSend = _extends({}, messageToEdit, {
|
|
52521
52659
|
attachments: updatedAttachments,
|
|
52522
52660
|
metadata: mentionedUsersPositions,
|
|
52523
|
-
bodyAttributes:
|
|
52661
|
+
bodyAttributes: adjustedBodyAttributes,
|
|
52524
52662
|
mentionedUsers: mentionUsersToSend,
|
|
52525
52663
|
body: messageTexToSend
|
|
52526
52664
|
});
|