|
|
@ -2,7 +2,7 @@
|
|
|
|
* @Author: ch
|
|
|
|
* @Author: ch
|
|
|
|
* @Date: 2022-05-18 14:54:47
|
|
|
|
* @Date: 2022-05-18 14:54:47
|
|
|
|
* @LastEditors: ch
|
|
|
|
* @LastEditors: ch
|
|
|
|
* @LastEditTime: 2022-06-13 10:51:59
|
|
|
|
* @LastEditTime: 2022-06-13 19:52:36
|
|
|
|
* @Description: file content
|
|
|
|
* @Description: file content
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
import { CreateUUID, FormatDate, ToAsyncAwait } from "@/plugins/utils";
|
|
|
|
import { CreateUUID, FormatDate, ToAsyncAwait } from "@/plugins/utils";
|
|
|
@ -192,9 +192,9 @@ class MsbIm {
|
|
|
|
newData = [
|
|
|
|
newData = [
|
|
|
|
...historyData,
|
|
|
|
...historyData,
|
|
|
|
{
|
|
|
|
{
|
|
|
|
fromAvatar: ctx.fromAvatar,
|
|
|
|
fromAvatar: ctx.session.fromAvatar,
|
|
|
|
fromId: ctx.fromId,
|
|
|
|
fromId: ctx.fromId,
|
|
|
|
fromNickname: ctx.fromNickname,
|
|
|
|
fromNickname: ctx.session.fromNickname,
|
|
|
|
id: ctx.sessionId,
|
|
|
|
id: ctx.sessionId,
|
|
|
|
lastMessage: ctx,
|
|
|
|
lastMessage: ctx,
|
|
|
|
messageList: [ctx],
|
|
|
|
messageList: [ctx],
|
|
|
@ -269,6 +269,7 @@ class MsbIm {
|
|
|
|
return Promise.reject(error);
|
|
|
|
return Promise.reject(error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const { content } = result;
|
|
|
|
const { content } = result;
|
|
|
|
|
|
|
|
let newData = [];
|
|
|
|
|
|
|
|
|
|
|
|
content.sessionVOS.forEach((item) => {
|
|
|
|
content.sessionVOS.forEach((item) => {
|
|
|
|
if (item.lastMessage) {
|
|
|
|
if (item.lastMessage) {
|
|
|
@ -279,13 +280,14 @@ class MsbIm {
|
|
|
|
if (hisIndex >= 0) {
|
|
|
|
if (hisIndex >= 0) {
|
|
|
|
historyData[hisIndex].lastMessage = item.lastMessage;
|
|
|
|
historyData[hisIndex].lastMessage = item.lastMessage;
|
|
|
|
historyData[hisIndex].unreadCount++;
|
|
|
|
historyData[hisIndex].unreadCount++;
|
|
|
|
this.setSessionData(historyData);
|
|
|
|
newData.push(historyData);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
item.messageList = [];
|
|
|
|
item.messageList = [];
|
|
|
|
const newData = [...historyData, item];
|
|
|
|
newData = [...newData, item];
|
|
|
|
this.setSessionData(newData);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.setSessionData(newData);
|
|
|
|
return Promise.resolve(result);
|
|
|
|
return Promise.resolve(result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -364,10 +366,12 @@ class MsbIm {
|
|
|
|
sendStatus: 'loading',
|
|
|
|
sendStatus: 'loading',
|
|
|
|
};
|
|
|
|
};
|
|
|
|
if (typeof msgCtx.payload === 'string') {
|
|
|
|
if (typeof msgCtx.payload === 'string') {
|
|
|
|
msgCtx.payload = JSON.parse(msgCtx.payload)
|
|
|
|
msgCtx.payload = JSON.parse(msgCtx.payload);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 点发送,立即把消息加入消息列表,标记为发送中状态
|
|
|
|
// 点发送,立即把消息加入消息列表,标记为发送中状态
|
|
|
|
curSession.messageList.push(msgCtx);
|
|
|
|
curSession.messageList.push(msgCtx);
|
|
|
|
|
|
|
|
this.setSessionData(this.sessionData);
|
|
|
|
|
|
|
|
|
|
|
|
// 超过时间未返回视为发送失败
|
|
|
|
// 超过时间未返回视为发送失败
|
|
|
|
this.timerStatus(msgCtx);
|
|
|
|
this.timerStatus(msgCtx);
|
|
|
|
|
|
|
|
|
|
|
@ -454,11 +458,5 @@ class MsbIm {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Promise.resolve(result);
|
|
|
|
return Promise.resolve(result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close() {
|
|
|
|
|
|
|
|
this.socket.close();
|
|
|
|
|
|
|
|
this.socket = null;
|
|
|
|
|
|
|
|
this.isOpen = false;
|
|
|
|
|
|
|
|
this.setSessionData([]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
export default MsbIm;
|
|
|
|
export default MsbIm;
|