【更新】更新列表的消息类型

This commit is contained in:
2022-01-25 11:32:52 +08:00
parent 01ff166760
commit 8f8295d541

View File

@@ -60,6 +60,30 @@ const disconnect = () => {
RongIMLib.disconnect()
}
// 允许通知的消息类型,触发更新消息列表操作
const notifyMsgTypes = [
'RC:TxtMsg',
'RC:VcMsg',
'RC:HQVCMsg',
'RC:ImgMsg',
'RC:GIFMsg',
'RC:ImgTextMsg',
'RC:FileMsg',
'RC:LBSMsg',
'RC:SightMsg',
'RC:ReferenceMsg',
'RC:CombineMsg',
]
function inArray(search, array) {
for (var i in array) {
if (array[i] == search) {
return true;
}
}
return false;
}
const addListeners = () => {
// 添加连接状态监听函数
RongIMLib.addConnectionStatusListener((res) => {
@@ -69,7 +93,10 @@ const addListeners = () => {
// 添加消息监听函数
RongIMLib.addReceiveMessageListener((res) => {
console.log('收到消息', res.data.message);
newMessage(res.data.message)
const message = res.data.message
if (inArray(message.objectName, notifyMsgTypes)) {
newMessage(message)
}
})
}