whyuzeim 1.1.49 → 1.1.51
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/cjs/ChatBox/index.js +33 -1
- package/es/ChatBox/index.js +34 -2
- package/package.json +1 -1
package/cjs/ChatBox/index.js
CHANGED
|
@@ -13,6 +13,8 @@ var _slicedToArray = require('@babel/runtime-corejs3/helpers/esm/slicedToArray')
|
|
|
13
13
|
var _regeneratorRuntime = require('@babel/runtime-corejs3/regenerator');
|
|
14
14
|
var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
|
|
15
15
|
var _Date$now = require('@babel/runtime-corejs3/core-js-stable/date/now');
|
|
16
|
+
var _trimInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/trim');
|
|
17
|
+
var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find');
|
|
16
18
|
var React = require('react');
|
|
17
19
|
var agoraChatUikit = require('agora-chat-uikit');
|
|
18
20
|
require('./style/index.scss');
|
|
@@ -40,7 +42,8 @@ var Chatbox = function Chatbox(props) {
|
|
|
40
42
|
theme = _useContext.theme;
|
|
41
43
|
var onBack = props.onBack;
|
|
42
44
|
var _useConversationConte = agoraChatUikit.useConversationContext(),
|
|
43
|
-
currentConversation = _useConversationConte.currentConversation
|
|
45
|
+
currentConversation = _useConversationConte.currentConversation,
|
|
46
|
+
conversationList = _useConversationConte.conversationList;
|
|
44
47
|
var _useState = React.useState(false),
|
|
45
48
|
_useState2 = _slicedToArray(_useState, 2),
|
|
46
49
|
isTopMenuOpen = _useState2[0],
|
|
@@ -587,6 +590,11 @@ var Chatbox = function Chatbox(props) {
|
|
|
587
590
|
var _ref12 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
588
591
|
var userid,
|
|
589
592
|
content,
|
|
593
|
+
cuiScrollList,
|
|
594
|
+
cuiScrollListWrap,
|
|
595
|
+
htmlString,
|
|
596
|
+
template,
|
|
597
|
+
node,
|
|
590
598
|
_args4 = arguments;
|
|
591
599
|
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
592
600
|
while (1) switch (_context4.prev = _context4.next) {
|
|
@@ -594,6 +602,20 @@ var Chatbox = function Chatbox(props) {
|
|
|
594
602
|
userid = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : "";
|
|
595
603
|
content = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : "";
|
|
596
604
|
if (isAgent) {
|
|
605
|
+
cuiScrollList = document.querySelector(".cui-messageList .cui-scrollList div");
|
|
606
|
+
cuiScrollListWrap = document.querySelector(".cui-messageList .cui-scrollList");
|
|
607
|
+
if (cuiScrollList) {
|
|
608
|
+
htmlString = "<div id=\"agent-generating-loader\" class=\"cui-messageList-msgItem\"><div><div class=\"thread-container\"><div id=\"1393207307050949578\" class=\"cui-message-base cui-message-base-left cui-message-base-hasAvatar cui-message-base-secondly cui-message-base-square cui-message-base-dark\"><img src=\"/icon/im/avatar_default.svg\" class=\"w-[48px] h-[48px] rounded-full overflow-hidden object-fit\"><div class=\"cui-message-base-box\"><div class=\"cui-message-base-info\"></div><div class=\"cui-message-base-body\"><div class=\"cui-message-base-content\" style=\"background: var(--im-msg-bubble-color-left); border-radius: 9px; padding: 10px 12px; color: var(--im-msg-bubble-font-color);\"><div style=\"display:flex;align-items:center\"><div class=\"generating-loader-wrap\"><div class=\"generating-loader\"></div></div><span class=\"cui-message-text\">Generating</span></div></div><div class=\"cui-message-base-time-and-status-box\"><span class=\"cui-message-status cui-message-status-icon\"></span><span class=\"cui-message-base-time\"></span></div></div></div></div></div></div><div class=\"cui-modal-root\"><div tabindex=\"-1\" class=\"cui-modal-wrap modify-message-modal\" style=\"display: none;\"></div></div></div>";
|
|
609
|
+
template = document.createElement('template');
|
|
610
|
+
template.innerHTML = _trimInstanceProperty(htmlString).call(htmlString);
|
|
611
|
+
node = template.content.firstChild;
|
|
612
|
+
if (node) {
|
|
613
|
+
cuiScrollList.appendChild(node);
|
|
614
|
+
cuiScrollListWrap === null || cuiScrollListWrap === void 0 || cuiScrollListWrap.scrollTo({
|
|
615
|
+
top: 1000000000
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
}
|
|
597
619
|
tools.reportAgentMsg(http, userid, content);
|
|
598
620
|
}
|
|
599
621
|
case 3:
|
|
@@ -632,6 +654,16 @@ var Chatbox = function Chatbox(props) {
|
|
|
632
654
|
setRightComponent && setRightComponent(undefined);
|
|
633
655
|
}
|
|
634
656
|
}, [currentConversation]);
|
|
657
|
+
React.useEffect(function () {
|
|
658
|
+
var _conversationList$fin;
|
|
659
|
+
var cuiScrollList = document.querySelector(".cui-messageList .cui-scrollList div");
|
|
660
|
+
var generatingLoader = document.querySelector("#agent-generating-loader");
|
|
661
|
+
if (cuiScrollList && generatingLoader && ((_conversationList$fin = _findInstanceProperty(conversationList).call(conversationList, function (item) {
|
|
662
|
+
return item.conversationId === agoraChatUikit.rootStore.conversationStore.currentCvs.conversationId;
|
|
663
|
+
})) === null || _conversationList$fin === void 0 || (_conversationList$fin = _conversationList$fin.lastMessage) === null || _conversationList$fin === void 0 ? void 0 : _conversationList$fin.to) !== agoraChatUikit.rootStore.conversationStore.currentCvs.conversationId) {
|
|
664
|
+
cuiScrollList.removeChild(generatingLoader);
|
|
665
|
+
}
|
|
666
|
+
}, [conversationList]);
|
|
635
667
|
return /*#__PURE__*/React.createElement("div", {
|
|
636
668
|
className: "yuze_chat_container w-full h-full overflow-hidden flex flex-col"
|
|
637
669
|
}, currentConversation.conversationId && customHeader(), /*#__PURE__*/React.createElement(agoraChatUikit.Chat, {
|
package/es/ChatBox/index.js
CHANGED
|
@@ -11,8 +11,10 @@ import _slicedToArray from '@babel/runtime-corejs3/helpers/esm/slicedToArray';
|
|
|
11
11
|
import _regeneratorRuntime from '@babel/runtime-corejs3/regenerator';
|
|
12
12
|
import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/for-each';
|
|
13
13
|
import _Date$now from '@babel/runtime-corejs3/core-js-stable/date/now';
|
|
14
|
+
import _trimInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/trim';
|
|
15
|
+
import _findInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/find';
|
|
14
16
|
import React, { useContext, useState, useEffect } from 'react';
|
|
15
|
-
import { useClient, useConversationContext, Chat, MessageList,
|
|
17
|
+
import { useClient, useConversationContext, rootStore, Chat, MessageList, Tooltip, ImageMessage, FileMessage, VideoMessage, AudioMessage, BaseMessage, TextMessage } from 'agora-chat-uikit';
|
|
16
18
|
import './style/index.scss';
|
|
17
19
|
import img$2 from './image/ic_more.svg.js';
|
|
18
20
|
import img from './image/ic_chat_back.svg.js';
|
|
@@ -38,7 +40,8 @@ var Chatbox = function Chatbox(props) {
|
|
|
38
40
|
theme = _useContext.theme;
|
|
39
41
|
var onBack = props.onBack;
|
|
40
42
|
var _useConversationConte = useConversationContext(),
|
|
41
|
-
currentConversation = _useConversationConte.currentConversation
|
|
43
|
+
currentConversation = _useConversationConte.currentConversation,
|
|
44
|
+
conversationList = _useConversationConte.conversationList;
|
|
42
45
|
var _useState = useState(false),
|
|
43
46
|
_useState2 = _slicedToArray(_useState, 2),
|
|
44
47
|
isTopMenuOpen = _useState2[0],
|
|
@@ -585,6 +588,11 @@ var Chatbox = function Chatbox(props) {
|
|
|
585
588
|
var _ref12 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
586
589
|
var userid,
|
|
587
590
|
content,
|
|
591
|
+
cuiScrollList,
|
|
592
|
+
cuiScrollListWrap,
|
|
593
|
+
htmlString,
|
|
594
|
+
template,
|
|
595
|
+
node,
|
|
588
596
|
_args4 = arguments;
|
|
589
597
|
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
590
598
|
while (1) switch (_context4.prev = _context4.next) {
|
|
@@ -592,6 +600,20 @@ var Chatbox = function Chatbox(props) {
|
|
|
592
600
|
userid = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : "";
|
|
593
601
|
content = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : "";
|
|
594
602
|
if (isAgent) {
|
|
603
|
+
cuiScrollList = document.querySelector(".cui-messageList .cui-scrollList div");
|
|
604
|
+
cuiScrollListWrap = document.querySelector(".cui-messageList .cui-scrollList");
|
|
605
|
+
if (cuiScrollList) {
|
|
606
|
+
htmlString = "<div id=\"agent-generating-loader\" class=\"cui-messageList-msgItem\"><div><div class=\"thread-container\"><div id=\"1393207307050949578\" class=\"cui-message-base cui-message-base-left cui-message-base-hasAvatar cui-message-base-secondly cui-message-base-square cui-message-base-dark\"><img src=\"/icon/im/avatar_default.svg\" class=\"w-[48px] h-[48px] rounded-full overflow-hidden object-fit\"><div class=\"cui-message-base-box\"><div class=\"cui-message-base-info\"></div><div class=\"cui-message-base-body\"><div class=\"cui-message-base-content\" style=\"background: var(--im-msg-bubble-color-left); border-radius: 9px; padding: 10px 12px; color: var(--im-msg-bubble-font-color);\"><div style=\"display:flex;align-items:center\"><div class=\"generating-loader-wrap\"><div class=\"generating-loader\"></div></div><span class=\"cui-message-text\">Generating</span></div></div><div class=\"cui-message-base-time-and-status-box\"><span class=\"cui-message-status cui-message-status-icon\"></span><span class=\"cui-message-base-time\"></span></div></div></div></div></div></div><div class=\"cui-modal-root\"><div tabindex=\"-1\" class=\"cui-modal-wrap modify-message-modal\" style=\"display: none;\"></div></div></div>";
|
|
607
|
+
template = document.createElement('template');
|
|
608
|
+
template.innerHTML = _trimInstanceProperty(htmlString).call(htmlString);
|
|
609
|
+
node = template.content.firstChild;
|
|
610
|
+
if (node) {
|
|
611
|
+
cuiScrollList.appendChild(node);
|
|
612
|
+
cuiScrollListWrap === null || cuiScrollListWrap === void 0 || cuiScrollListWrap.scrollTo({
|
|
613
|
+
top: 1000000000
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
}
|
|
595
617
|
reportAgentMsg(http, userid, content);
|
|
596
618
|
}
|
|
597
619
|
case 3:
|
|
@@ -630,6 +652,16 @@ var Chatbox = function Chatbox(props) {
|
|
|
630
652
|
setRightComponent && setRightComponent(undefined);
|
|
631
653
|
}
|
|
632
654
|
}, [currentConversation]);
|
|
655
|
+
useEffect(function () {
|
|
656
|
+
var _conversationList$fin;
|
|
657
|
+
var cuiScrollList = document.querySelector(".cui-messageList .cui-scrollList div");
|
|
658
|
+
var generatingLoader = document.querySelector("#agent-generating-loader");
|
|
659
|
+
if (cuiScrollList && generatingLoader && ((_conversationList$fin = _findInstanceProperty(conversationList).call(conversationList, function (item) {
|
|
660
|
+
return item.conversationId === rootStore.conversationStore.currentCvs.conversationId;
|
|
661
|
+
})) === null || _conversationList$fin === void 0 || (_conversationList$fin = _conversationList$fin.lastMessage) === null || _conversationList$fin === void 0 ? void 0 : _conversationList$fin.to) !== rootStore.conversationStore.currentCvs.conversationId) {
|
|
662
|
+
cuiScrollList.removeChild(generatingLoader);
|
|
663
|
+
}
|
|
664
|
+
}, [conversationList]);
|
|
633
665
|
return /*#__PURE__*/React.createElement("div", {
|
|
634
666
|
className: "yuze_chat_container w-full h-full overflow-hidden flex flex-col"
|
|
635
667
|
}, currentConversation.conversationId && customHeader(), /*#__PURE__*/React.createElement(Chat, {
|