@esvndev/es-react-template-chat 0.0.95 → 0.0.96
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/dist/index.js +60 -57
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +60 -57
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -91798,8 +91798,8 @@ const ADMINISTRATIVE_ITEMS = [
|
|
|
91798
91798
|
const ChatLog = (props) => {
|
|
91799
91799
|
// ** Props & Store
|
|
91800
91800
|
//const clipboard = useClipboard()
|
|
91801
|
-
useLexicalComposerContext();
|
|
91802
|
-
reactI18next.useTranslation();
|
|
91801
|
+
const [editor] = useLexicalComposerContext();
|
|
91802
|
+
const { t } = reactI18next.useTranslation();
|
|
91803
91803
|
useUploadFile();
|
|
91804
91804
|
const { typeChat, contactId, chatRoomId, active, messageByGroup, pinnedMessages, setScroll, checkScroll, pinMessageChatRoom, deleteMessageApi, recallMessageApi, get_message_by_group_cursor_api, getPinMessageChatRoomApi, deletePinMessage,
|
|
91805
91805
|
//updateGroupTagApi,
|
|
@@ -91875,8 +91875,8 @@ const ChatLog = (props) => {
|
|
|
91875
91875
|
React.useState(true);
|
|
91876
91876
|
const [expandedMessages, setExpandedMessages] = React.useState(new Set());
|
|
91877
91877
|
const [clickedImageFile, setClickedImageFile] = React.useState(null);
|
|
91878
|
-
React.useState(false);
|
|
91879
|
-
React.useState(new Set());
|
|
91878
|
+
const [isMultiSelectMode, setIsMultiSelectMode] = React.useState(false);
|
|
91879
|
+
const [selectedMessages, setSelectedMessages] = React.useState(new Set());
|
|
91880
91880
|
const BASE_CONTEXT_ITEMS = [
|
|
91881
91881
|
"reply", "share", "pin", "bookmark",
|
|
91882
91882
|
"selectMultiMessage", "detail", "other", "recall", "delete"
|
|
@@ -92633,59 +92633,62 @@ const ChatLog = (props) => {
|
|
|
92633
92633
|
break;
|
|
92634
92634
|
}
|
|
92635
92635
|
}, [clickedImageFile, handleDelete, handleDownloadClick, handleRecall]);
|
|
92636
|
-
|
|
92637
|
-
|
|
92638
|
-
|
|
92639
|
-
|
|
92640
|
-
|
|
92641
|
-
|
|
92642
|
-
|
|
92643
|
-
|
|
92644
|
-
|
|
92645
|
-
|
|
92646
|
-
|
|
92647
|
-
|
|
92648
|
-
|
|
92649
|
-
|
|
92650
|
-
|
|
92651
|
-
|
|
92652
|
-
|
|
92653
|
-
|
|
92654
|
-
|
|
92655
|
-
|
|
92656
|
-
|
|
92657
|
-
|
|
92658
|
-
|
|
92659
|
-
|
|
92660
|
-
|
|
92661
|
-
|
|
92662
|
-
|
|
92663
|
-
|
|
92664
|
-
|
|
92665
|
-
|
|
92666
|
-
|
|
92667
|
-
|
|
92668
|
-
|
|
92669
|
-
|
|
92670
|
-
|
|
92671
|
-
|
|
92672
|
-
|
|
92673
|
-
|
|
92674
|
-
|
|
92675
|
-
|
|
92676
|
-
|
|
92677
|
-
|
|
92678
|
-
|
|
92679
|
-
|
|
92680
|
-
|
|
92681
|
-
|
|
92682
|
-
|
|
92683
|
-
|
|
92684
|
-
|
|
92685
|
-
|
|
92686
|
-
|
|
92687
|
-
|
|
92688
|
-
|
|
92636
|
+
const handleFocus = React.useCallback(() => {
|
|
92637
|
+
editor.focus();
|
|
92638
|
+
}, [editor]);
|
|
92639
|
+
React.useCallback((data) => {
|
|
92640
|
+
handleFocus();
|
|
92641
|
+
setReplyMessage({ id: "reply", currentMessage: data });
|
|
92642
|
+
}, [handleFocus]);
|
|
92643
|
+
React.useCallback((message) => {
|
|
92644
|
+
setIsMultiSelectMode(true);
|
|
92645
|
+
setSelectedMessages(new Set([message.id]));
|
|
92646
|
+
}, []);
|
|
92647
|
+
const handleExitMultiSelectMode = React.useCallback(() => {
|
|
92648
|
+
setIsMultiSelectMode(false);
|
|
92649
|
+
setSelectedMessages(new Set());
|
|
92650
|
+
}, []);
|
|
92651
|
+
React.useCallback((messageId) => {
|
|
92652
|
+
setSelectedMessages(prev => {
|
|
92653
|
+
const newSet = new Set(prev);
|
|
92654
|
+
if (newSet.has(messageId)) {
|
|
92655
|
+
newSet.delete(messageId);
|
|
92656
|
+
}
|
|
92657
|
+
else {
|
|
92658
|
+
newSet.add(messageId);
|
|
92659
|
+
}
|
|
92660
|
+
return newSet;
|
|
92661
|
+
});
|
|
92662
|
+
}, []);
|
|
92663
|
+
React.useCallback(async () => {
|
|
92664
|
+
if (selectedMessages.size === 0) {
|
|
92665
|
+
return;
|
|
92666
|
+
}
|
|
92667
|
+
MySwal$1.fire({
|
|
92668
|
+
title: t("Confirm"),
|
|
92669
|
+
html: `Bạn có chắc muốn xóa ${selectedMessages.size} tin nhắn đã chọn?`,
|
|
92670
|
+
allowOutsideClick: false,
|
|
92671
|
+
showCancelButton: true,
|
|
92672
|
+
confirmButtonText: t("Delete"),
|
|
92673
|
+
cancelButtonText: t("Cancel"),
|
|
92674
|
+
customClass: {
|
|
92675
|
+
confirmButton: "btn btn-primary",
|
|
92676
|
+
cancelButton: "btn btn-danger ms-1"
|
|
92677
|
+
},
|
|
92678
|
+
buttonsStyling: false
|
|
92679
|
+
}).then(async (result) => {
|
|
92680
|
+
if (result.value) {
|
|
92681
|
+
try {
|
|
92682
|
+
const deletePromises = Array.from(selectedMessages).map(id => deleteMessageApi({ id, chatRoomId: groupChatUsers?.id }));
|
|
92683
|
+
await Promise.all(deletePromises);
|
|
92684
|
+
handleExitMultiSelectMode();
|
|
92685
|
+
}
|
|
92686
|
+
catch (error) {
|
|
92687
|
+
console.error('Error deleting messages:', error);
|
|
92688
|
+
}
|
|
92689
|
+
}
|
|
92690
|
+
});
|
|
92691
|
+
}, [selectedMessages, deleteMessageApi, groupChatUsers?.id, handleExitMultiSelectMode, t]);
|
|
92689
92692
|
// const handleBatchRecall = useCallback(async () => {
|
|
92690
92693
|
// if (selectedMessages.size === 0) { return }
|
|
92691
92694
|
// MySwal.fire({
|