消息提醒

This commit is contained in:
unknown
2022-06-10 19:53:11 +08:00
parent e868d753bf
commit 03535092c0

View File

@ -231,7 +231,7 @@ const conversation = (props) => {
setMsgPage(msgPage+1)
}
let count = earlierMsg.length
let arr = [...msgList]
let arr = pageNum==1?[] : [...msgList]
while(count>0){
arr.unshift(earlierMsg.pop())
count--
@ -266,14 +266,18 @@ const disconnectedAlert = () =>{
const checkDisconnected = ()=>{
if(window.isCloseChatUIModal!=undefined){ //弹窗没有关闭弹窗开着或者隐藏ws不应该断
console.log('websocket断开重新连接')
if(isModalVisible){ //断连后,用户打开弹窗再发提醒
setConversationId('')
console.log(window.isModalVisibleForCustomerService)
setConversationId('')
if(window.isModalVisibleForCustomerService){ //断连后,用户打开弹窗再发提醒
disconnectedAlert()
}
}else{
setConversationId('')
setMsgPage(0)
delete window.webSocketForCustomerService //释放websocket对象
if(window.webSocketForCustomerService!=undefined) delete window.webSocketForCustomerService //释放websocket对象
if(window.isModalVisibleForCustomerService!=undefined) delete window.isModalVisibleForCustomerService
if(window.isConversationURLChanged!=undefined) delete window.isConversationURLChanged
if(window.msgAlertForCustomerService!=undefined) delete window.msgAlertForCustomerService
}
}
@ -288,6 +292,7 @@ const getToken = ()=>{
setLoading(true)
getMoreMessage(1)
}else{
console.log(window.webSocketForCustomerService)
if(window.webSocketForCustomerService!=undefined){
//别的路由切过来ws没断重新监听
console.log('ws没断重新监听')
@ -316,11 +321,16 @@ const monitorWebSocket = (ws)=>{
ws.onmessage = function (res) {
if(res.data){
let data = JSON.parse(res.data)
if(window.isConversationURLChanged!= true){
if(window.isConversationURLChanged){//路由变化
window.msgAlertForCustomerService = true
showMsg()
}else {
if(window.isBlurForCustomerService){//失焦
window.msgAlertForCustomerService = true
showMsg()
}
setWsMsg(data)
}
window.msgAlertForCustomerService = true
showMsg()
}
};
@ -359,6 +369,9 @@ useEffect(()=>{
}
}
})
if(window.msgAlertForCustomerService){
msgAlert && msgAlert() //侧边栏提醒
}
},[])
useEffect(()=>{
if(!isCloseWs){
@ -368,6 +381,7 @@ useEffect(()=>{
}
},[isCloseWs])
useEffect(() => {
window.isModalVisibleForCustomerService = isModalVisible
if(isModalVisible){
stopMsg()
//登录人的信息的关键字 顺序是固定的。
@ -392,9 +406,6 @@ useEffect(() => {
//校验登录
getToken()
}else{
if(window.msgAlertForCustomerService){
msgAlert && msgAlert() //侧边栏提醒
}
setMsgList([])
}
}, [isModalVisible])