|
@@ -186,38 +186,37 @@ export default {
|
|
|
* 新增一条消息
|
|
|
*/
|
|
|
appendMessage(message, scrollToBottom = false) {
|
|
|
- let unread = "+1";
|
|
|
- let messageList = allMessages[message.toContactId];
|
|
|
- // 如果是自己的消息需要push,发送的消息不再增加未读条数
|
|
|
- let conversation=this.findConversation(message.toContactId);
|
|
|
- unread=!!conversation.unread?(conversation.unread+1):1;
|
|
|
- if (message.type == 'event' || this.user.id == message.fromUser.id) unread = "+0";
|
|
|
- if (messageList === undefined) {
|
|
|
- this.updateContact({
|
|
|
- id: message.toContactId,
|
|
|
- unread: unread,
|
|
|
- lastSendTime: message.sendTime,
|
|
|
- lastContent: this.lastContentRender(message),
|
|
|
- });
|
|
|
+ let messageList = allMessages[message.toContactId];
|
|
|
+ // 如果是自己的消息需要push,发送的消息不再增加未读条数
|
|
|
+ let conversation=this.findConversation(message.toContactId);
|
|
|
+ let unread=!!conversation.unread && conversation.unread>0?(conversation.unread+1):1;
|
|
|
+ if (message.type == 'event' || this.user.id == message.fromUser.id) unread = "+0";
|
|
|
+ if (messageList === undefined) {
|
|
|
+ this.updateContact({
|
|
|
+ id: message.toContactId,
|
|
|
+ unread: unread,
|
|
|
+ lastSendTime: message.sendTime,
|
|
|
+ lastContent: this.lastContentRender(message),
|
|
|
+ });
|
|
|
} else {
|
|
|
- // 如果消息存在则不再添加
|
|
|
- let hasMsg = messageList.some(({id})=>id == message.id);
|
|
|
- if (hasMsg) return;
|
|
|
- this._addMessage(message, message.toContactId, 1);
|
|
|
- const updateContact = {
|
|
|
- id: message.toContactId,
|
|
|
- lastContent: this.lastContentRender(message),
|
|
|
- lastSendTime: message.sendTime,
|
|
|
- };
|
|
|
- if (message.toContactId == this.currentContactId) {
|
|
|
- if (scrollToBottom == true) {
|
|
|
- this.messageViewToBottom();
|
|
|
+ // 如果消息存在则不再添加
|
|
|
+ let hasMsg = messageList.some(({id})=>id == message.id);
|
|
|
+ if (hasMsg) return;
|
|
|
+ this._addMessage(message, message.toContactId, 1);
|
|
|
+
|
|
|
+ conversation.lastContent=this.lastContentRender(message);
|
|
|
+ conversation.lastSendTime=message.sendTime;
|
|
|
+ if (message.toContactId == this.currentContactId) {
|
|
|
+
|
|
|
+ conversation.unread=0;
|
|
|
+ if (scrollToBottom == true) {
|
|
|
+ this.messageViewToBottom();
|
|
|
+ }
|
|
|
+ this.CacheDraft.remove(message.toContactId);
|
|
|
+ } else {
|
|
|
+ conversation.unread = unread;
|
|
|
}
|
|
|
- this.CacheDraft.remove(message.toContactId);
|
|
|
- } else {
|
|
|
- updateContact.unread = unread;
|
|
|
- }
|
|
|
- this.updateContact(updateContact);
|
|
|
+ this.updateContact(conversation);
|
|
|
}
|
|
|
},
|
|
|
_emitSend(message, next, file) {
|
|
@@ -305,7 +304,6 @@ export default {
|
|
|
this.CacheMessageLoaded.set(this.currentContactId, isEnd);
|
|
|
if (isEnd == true) this.$refs.messages.loaded();
|
|
|
this.updateCurrentMessages();
|
|
|
- console.log("qxj _emitPullMessages");
|
|
|
this._changeContactLock = false;
|
|
|
next(isEnd);
|
|
|
},
|
|
@@ -694,7 +692,7 @@ export default {
|
|
|
});
|
|
|
|
|
|
var tempDraft=this.CacheDraft.get(cid);
|
|
|
- console.log("qxj editorValue:"+editorValue+",tempDraft:"+JSON.stringify(tempDraft)+"lastContent:"+lastContent);
|
|
|
+ //console.log("qxj editorValue:"+editorValue+",tempDraft:"+JSON.stringify(tempDraft)+"lastContent:"+lastContent);
|
|
|
|
|
|
this.updateContact({
|
|
|
id: cid,
|
|
@@ -1016,16 +1014,14 @@ export default {
|
|
|
* @param {Contact} data 修改的数据,根据 Contact.id 查找联系人并覆盖传入的值
|
|
|
*/
|
|
|
updateContact(data) {
|
|
|
- const contactId = data.id;
|
|
|
- delete data.id;
|
|
|
- const index = this.findConversationIndexById(contactId);
|
|
|
+ const conversationId = data.conversationId;
|
|
|
+ const index = this.findConversationIndexById(conversationId);
|
|
|
if (index !== -1) {
|
|
|
- const { unread } = data;
|
|
|
- if (isString(unread)) {
|
|
|
- if (unread.indexOf("+") === 0 || unread.indexOf("-") === 0) {
|
|
|
- data.unread =parseInt(unread) + parseInt(this.conversations[index].unread);
|
|
|
- }
|
|
|
- }
|
|
|
+ // if(isString(data.unread)) {
|
|
|
+ // if (unread.indexOf("+") === 0 || unread.indexOf("-") === 0) {
|
|
|
+ // data.unread =parseInt(unread) + parseInt(this.conversations[index].unread);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
this.$set(this.conversations, index, {
|
|
|
...this.conversations[index],
|
|
|
...data,
|