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