@naviedu/room-platform-react 0.0.80 → 0.0.81
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.esm.js +25 -82
- package/package.json +1 -1
package/index.esm.js
CHANGED
|
@@ -25944,24 +25944,6 @@ function createChatClient(config) {
|
|
|
25944
25944
|
});
|
|
25945
25945
|
})();
|
|
25946
25946
|
},
|
|
25947
|
-
completeAttachments: function completeAttachments(input) {
|
|
25948
|
-
return _async_to_generator$9(function() {
|
|
25949
|
-
var _input_idempotencyKey;
|
|
25950
|
-
return _ts_generator$9(this, function(_state) {
|
|
25951
|
-
state.getRoom(roomId);
|
|
25952
|
-
return [
|
|
25953
|
-
2,
|
|
25954
|
-
request("/chat/rooms/".concat(encodeURIComponent(roomId), "/attachments/complete"), {
|
|
25955
|
-
body: JSON.stringify({
|
|
25956
|
-
idempotencyKey: (_input_idempotencyKey = input.idempotencyKey) !== null && _input_idempotencyKey !== void 0 ? _input_idempotencyKey : idGenerator(),
|
|
25957
|
-
attachmentIds: input.attachmentIds
|
|
25958
|
-
}),
|
|
25959
|
-
method: 'POST'
|
|
25960
|
-
})
|
|
25961
|
-
];
|
|
25962
|
-
});
|
|
25963
|
-
})();
|
|
25964
|
-
},
|
|
25965
25947
|
renewAttachmentUploadUrl: function renewAttachmentUploadUrl(input) {
|
|
25966
25948
|
return _async_to_generator$9(function() {
|
|
25967
25949
|
var _input_idempotencyKey;
|
|
@@ -58312,12 +58294,10 @@ function MessageComposer(param) {
|
|
|
58312
58294
|
}), 2), selection = _useState5[0], setSelection = _useState5[1];
|
|
58313
58295
|
var _useState6 = _sliced_to_array$b(useState(), 2), pendingCaret = _useState6[0], setPendingCaret = _useState6[1];
|
|
58314
58296
|
var filesRef = useRef(files);
|
|
58315
|
-
var completedAttachmentIdsRef = useRef(new Set());
|
|
58316
58297
|
var isSubmittingRef = useRef(false);
|
|
58317
58298
|
var generationRef = useRef(0);
|
|
58318
58299
|
var presignOperationByBatchRef = useRef(new Map());
|
|
58319
58300
|
var presignOperationByClientRef = useRef(new Map());
|
|
58320
|
-
var completeOperationRef = useRef(undefined);
|
|
58321
58301
|
var sendOperationRef = useRef(undefined);
|
|
58322
58302
|
var renewOperationByAttachmentRef = useRef(new Map());
|
|
58323
58303
|
var uploadOperationByClientRef = useRef(new Map());
|
|
@@ -58437,10 +58417,6 @@ function MessageComposer(param) {
|
|
|
58437
58417
|
});
|
|
58438
58418
|
};
|
|
58439
58419
|
var removeFile = function(clientId) {
|
|
58440
|
-
var removedFile = filesRef.current.find(function(item) {
|
|
58441
|
-
return item.clientId === clientId;
|
|
58442
|
-
});
|
|
58443
|
-
if (removedFile === null || removedFile === void 0 ? void 0 : removedFile.upload) completedAttachmentIdsRef.current.delete(removedFile.upload.attachmentId);
|
|
58444
58420
|
uploadOperationByClientRef.current.delete(clientId);
|
|
58445
58421
|
updateFiles(function(current) {
|
|
58446
58422
|
return current.filter(function(item) {
|
|
@@ -58577,7 +58553,6 @@ function MessageComposer(param) {
|
|
|
58577
58553
|
case 6:
|
|
58578
58554
|
renewError = _state.sent();
|
|
58579
58555
|
if (!hasChatErrorCode(renewError, 'CHAT_MESSAGE_ATTACHMENT_UPLOAD_EXPIRED')) throw renewError;
|
|
58580
|
-
completedAttachmentIdsRef.current.delete(upload.attachmentId);
|
|
58581
58556
|
updateFiles(function(current) {
|
|
58582
58557
|
return current.map(function(candidate) {
|
|
58583
58558
|
return candidate.clientId === item.clientId ? _object_spread_props$6(_object_spread$8({}, candidate), {
|
|
@@ -58898,7 +58873,7 @@ function MessageComposer(param) {
|
|
|
58898
58873
|
};
|
|
58899
58874
|
var uploadAndSend = function(messageText, generation) {
|
|
58900
58875
|
return _async_to_generator$8(function() {
|
|
58901
|
-
var pendingItems, newItems, pendingOperations, incompleteFile, attachmentIds,
|
|
58876
|
+
var pendingItems, newItems, pendingOperations, incompleteFile, attachmentIds, sendPayload, sendKey, uploadError;
|
|
58902
58877
|
return _ts_generator$8(this, function(_state) {
|
|
58903
58878
|
switch(_state.label){
|
|
58904
58879
|
case 0:
|
|
@@ -58913,9 +58888,9 @@ function MessageComposer(param) {
|
|
|
58913
58888
|
case 1:
|
|
58914
58889
|
_state.trys.push([
|
|
58915
58890
|
1,
|
|
58916
|
-
|
|
58891
|
+
4,
|
|
58917
58892
|
,
|
|
58918
|
-
|
|
58893
|
+
5
|
|
58919
58894
|
]);
|
|
58920
58895
|
pendingItems = filesRef.current.filter(function(item) {
|
|
58921
58896
|
return item.status !== 'completed';
|
|
@@ -58945,38 +58920,6 @@ function MessageComposer(param) {
|
|
|
58945
58920
|
return Boolean(attachmentId);
|
|
58946
58921
|
});
|
|
58947
58922
|
if (attachmentIds.length !== filesRef.current.length) throw new Error('Ảnh chưa sẵn sàng để gửi.');
|
|
58948
|
-
attachmentIdsToComplete = attachmentIds.filter(function(attachmentId) {
|
|
58949
|
-
return !completedAttachmentIdsRef.current.has(attachmentId);
|
|
58950
|
-
});
|
|
58951
|
-
if (!attachmentIdsToComplete.length) return [
|
|
58952
|
-
3,
|
|
58953
|
-
4
|
|
58954
|
-
];
|
|
58955
|
-
completePayload = JSON.stringify({
|
|
58956
|
-
attachmentIds: attachmentIdsToComplete
|
|
58957
|
-
});
|
|
58958
|
-
return [
|
|
58959
|
-
4,
|
|
58960
|
-
roomClient.completeAttachments({
|
|
58961
|
-
attachmentIds: attachmentIdsToComplete,
|
|
58962
|
-
idempotencyKey: getOperationKey(completeOperationRef, 'complete', completePayload)
|
|
58963
|
-
})
|
|
58964
|
-
];
|
|
58965
|
-
case 3:
|
|
58966
|
-
completed = _state.sent();
|
|
58967
|
-
assertCurrentGeneration(generation);
|
|
58968
|
-
completedIds = new Set(completed.attachmentIds);
|
|
58969
|
-
if (attachmentIdsToComplete.some(function(attachmentId) {
|
|
58970
|
-
return !completedIds.has(attachmentId);
|
|
58971
|
-
})) {
|
|
58972
|
-
throw new Error('Máy chủ chưa hoàn tất tất cả ảnh.');
|
|
58973
|
-
}
|
|
58974
|
-
attachmentIdsToComplete.forEach(function(attachmentId) {
|
|
58975
|
-
return completedAttachmentIdsRef.current.add(attachmentId);
|
|
58976
|
-
});
|
|
58977
|
-
completeOperationRef.current = undefined;
|
|
58978
|
-
_state.label = 4;
|
|
58979
|
-
case 4:
|
|
58980
58923
|
sendPayload = JSON.stringify({
|
|
58981
58924
|
attachmentIds: attachmentIds,
|
|
58982
58925
|
text: messageText
|
|
@@ -58990,21 +58933,20 @@ function MessageComposer(param) {
|
|
|
58990
58933
|
text: messageText
|
|
58991
58934
|
}, sendKey)
|
|
58992
58935
|
];
|
|
58993
|
-
case
|
|
58936
|
+
case 3:
|
|
58994
58937
|
_state.sent();
|
|
58995
58938
|
assertCurrentGeneration(generation);
|
|
58996
58939
|
updateFiles(function() {
|
|
58997
58940
|
return [];
|
|
58998
58941
|
});
|
|
58999
|
-
completedAttachmentIdsRef.current.clear();
|
|
59000
58942
|
sendOperationRef.current = undefined;
|
|
59001
58943
|
setText('');
|
|
59002
58944
|
setError(undefined);
|
|
59003
58945
|
return [
|
|
59004
58946
|
3,
|
|
59005
|
-
|
|
58947
|
+
5
|
|
59006
58948
|
];
|
|
59007
|
-
case
|
|
58949
|
+
case 4:
|
|
59008
58950
|
uploadError = _state.sent();
|
|
59009
58951
|
if (_instanceof$2(uploadError, StaleComposerOperationError)) return [
|
|
59010
58952
|
2
|
|
@@ -59012,9 +58954,9 @@ function MessageComposer(param) {
|
|
|
59012
58954
|
setError(_instanceof$2(uploadError, Error) ? uploadError.message : 'Không thể gửi ảnh.');
|
|
59013
58955
|
return [
|
|
59014
58956
|
3,
|
|
59015
|
-
|
|
58957
|
+
5
|
|
59016
58958
|
];
|
|
59017
|
-
case
|
|
58959
|
+
case 5:
|
|
59018
58960
|
return [
|
|
59019
58961
|
2
|
|
59020
58962
|
];
|
|
@@ -60060,21 +60002,17 @@ function MessageAttachmentGallery(param) {
|
|
|
60060
60002
|
className: "navi-chat__attachment-state navi-chat__attachment-state--failed",
|
|
60061
60003
|
role: "alert",
|
|
60062
60004
|
children: [
|
|
60063
|
-
/*#__PURE__*/
|
|
60064
|
-
children:
|
|
60065
|
-
"Kh\xf4ng thể xử l\xfd ",
|
|
60066
|
-
attachment.fileName,
|
|
60067
|
-
"."
|
|
60068
|
-
]
|
|
60005
|
+
/*#__PURE__*/ jsx("span", {
|
|
60006
|
+
children: attachment.state === 'rejected' ? "Kh\xf4ng thể sử dụng ".concat(attachment.fileName, ".") : "Kh\xf4ng thể xử l\xfd ".concat(attachment.fileName, ".")
|
|
60069
60007
|
}),
|
|
60070
|
-
/*#__PURE__*/ jsx("button", {
|
|
60008
|
+
attachment.retryable ? /*#__PURE__*/ jsx("button", {
|
|
60071
60009
|
disabled: !onRetryAttachment || retryingIds.has(attachment.id),
|
|
60072
60010
|
onClick: function() {
|
|
60073
60011
|
return void retryAttachment(attachment.id);
|
|
60074
60012
|
},
|
|
60075
60013
|
type: "button",
|
|
60076
60014
|
children: retryingIds.has(attachment.id) ? 'Đang thử lại...' : "Thử lại ".concat(attachment.fileName)
|
|
60077
|
-
}),
|
|
60015
|
+
}) : null,
|
|
60078
60016
|
retryErrors[attachment.id] ? /*#__PURE__*/ jsx("span", {
|
|
60079
60017
|
role: "status",
|
|
60080
60018
|
children: retryErrors[attachment.id]
|
|
@@ -62062,7 +62000,7 @@ var mergeAttachment = function(current, incoming) {
|
|
|
62062
62000
|
};
|
|
62063
62001
|
var getAttachmentRank = function(attachment) {
|
|
62064
62002
|
if ('previewUrl' in attachment) return 2;
|
|
62065
|
-
if (attachment.state === 'failed') return 1;
|
|
62003
|
+
if (attachment.state === 'failed' || attachment.state === 'rejected') return 1;
|
|
62066
62004
|
return 0;
|
|
62067
62005
|
};
|
|
62068
62006
|
var markFailedAttachments = function(messagesByRoom, failureBuffer, retryStates) {
|
|
@@ -62132,9 +62070,10 @@ var applyBufferedFailuresToMessage = function(message, failureBuffer, retryState
|
|
|
62132
62070
|
});
|
|
62133
62071
|
if (!failure) return attachment;
|
|
62134
62072
|
changed = true;
|
|
62135
|
-
if ('previewUrl' in attachment
|
|
62073
|
+
if ('previewUrl' in attachment) return attachment;
|
|
62136
62074
|
return _object_spread_props$4(_object_spread$6({}, attachment), {
|
|
62137
|
-
state:
|
|
62075
|
+
state: failure.state,
|
|
62076
|
+
retryable: failure.retryable
|
|
62138
62077
|
});
|
|
62139
62078
|
});
|
|
62140
62079
|
return changed ? _object_spread_props$4(_object_spread$6({}, message), {
|
|
@@ -62147,8 +62086,9 @@ var markAttachmentProcessing = function(messagesByRoom, roomId, attachmentId) {
|
|
|
62147
62086
|
var _message_attachments;
|
|
62148
62087
|
return _object_spread_props$4(_object_spread$6({}, message), {
|
|
62149
62088
|
attachments: ((_message_attachments = message.attachments) !== null && _message_attachments !== void 0 ? _message_attachments : []).map(function(attachment) {
|
|
62150
|
-
return attachment.id === attachmentId && !('previewUrl' in attachment) && attachment.state === 'failed' ? _object_spread_props$4(_object_spread$6({}, attachment), {
|
|
62151
|
-
state: 'processing'
|
|
62089
|
+
return attachment.id === attachmentId && !('previewUrl' in attachment) && attachment.state === 'failed' && attachment.retryable ? _object_spread_props$4(_object_spread$6({}, attachment), {
|
|
62090
|
+
state: 'processing',
|
|
62091
|
+
retryable: false
|
|
62152
62092
|
}) : attachment;
|
|
62153
62093
|
})
|
|
62154
62094
|
});
|
|
@@ -62161,7 +62101,8 @@ var markAttachmentFailed = function(messagesByRoom, roomId, attachmentId) {
|
|
|
62161
62101
|
return _object_spread_props$4(_object_spread$6({}, message), {
|
|
62162
62102
|
attachments: ((_message_attachments = message.attachments) !== null && _message_attachments !== void 0 ? _message_attachments : []).map(function(attachment) {
|
|
62163
62103
|
return attachment.id === attachmentId && !('previewUrl' in attachment) && attachment.state === 'processing' ? _object_spread_props$4(_object_spread$6({}, attachment), {
|
|
62164
|
-
state: 'failed'
|
|
62104
|
+
state: 'failed',
|
|
62105
|
+
retryable: true
|
|
62165
62106
|
}) : attachment;
|
|
62166
62107
|
})
|
|
62167
62108
|
});
|
|
@@ -62204,7 +62145,7 @@ var parseChatMessageAttachmentsFailedEvent = function(event) {
|
|
|
62204
62145
|
var candidate = event;
|
|
62205
62146
|
if (typeof candidate.appId !== 'string' || typeof candidate.roomId !== 'string' || typeof candidate.messageId !== 'string' || !Array.isArray(candidate.attachmentIds) || !candidate.attachmentIds.every(function(attachmentId) {
|
|
62206
62147
|
return typeof attachmentId === 'string';
|
|
62207
|
-
}) || typeof candidate.attemptId !== 'string' || candidate.attemptId.length === 0) {
|
|
62148
|
+
}) || typeof candidate.attemptId !== 'string' || candidate.attemptId.length === 0 || candidate.state !== 'failed' && candidate.state !== 'rejected' || typeof candidate.retryable !== 'boolean' || candidate.state === 'rejected' && candidate.retryable) {
|
|
62208
62149
|
return undefined;
|
|
62209
62150
|
}
|
|
62210
62151
|
return {
|
|
@@ -62212,7 +62153,9 @@ var parseChatMessageAttachmentsFailedEvent = function(event) {
|
|
|
62212
62153
|
attachmentIds: candidate.attachmentIds,
|
|
62213
62154
|
messageId: candidate.messageId,
|
|
62214
62155
|
roomId: candidate.roomId,
|
|
62215
|
-
attemptId: candidate.attemptId
|
|
62156
|
+
attemptId: candidate.attemptId,
|
|
62157
|
+
state: candidate.state,
|
|
62158
|
+
retryable: candidate.retryable
|
|
62216
62159
|
};
|
|
62217
62160
|
};
|
|
62218
62161
|
var subjectFromToken = function(token) {
|