|
@@ -189,6 +189,8 @@ export default {
|
|
|
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({
|
|
@@ -508,7 +510,7 @@ export default {
|
|
|
const curactNew = this.currentNewContact;
|
|
|
let defIsShow = true;
|
|
|
for (const name in this.CacheContactContainer.get()) {
|
|
|
- const show = curact.id == name && this.currentIsDefSidebar;
|
|
|
+ const show = curactNew.id == name && this.currentIsDefSidebar;
|
|
|
if(show)defIsShow = !show;
|
|
|
nodes.push(
|
|
|
<div class={cls} v-show={show}>
|
|
@@ -517,14 +519,14 @@ export default {
|
|
|
);
|
|
|
}
|
|
|
for (const name in this.CacheMenuContainer.get()) {
|
|
|
- nodes.push(
|
|
|
- <div
|
|
|
- class={cls}
|
|
|
- v-show={this.activeSidebar == name && !this.currentIsDefSidebar}
|
|
|
- >
|
|
|
- {this.CacheMenuContainer.get(name)}
|
|
|
- </div>,
|
|
|
- );
|
|
|
+ nodes.push(
|
|
|
+ <div
|
|
|
+ class={cls}
|
|
|
+ v-show={this.activeSidebar == name && !this.currentIsDefSidebar}
|
|
|
+ >
|
|
|
+ {this.CacheMenuContainer.get(name)}
|
|
|
+ </div>,
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
//聊天消息View
|
|
@@ -680,9 +682,9 @@ export default {
|
|
|
*/
|
|
|
setDraft(cid, editorValue) {
|
|
|
if (isEmpty(cid) || isEmpty(editorValue)) return false;
|
|
|
- const contact = this.findContact(cid);
|
|
|
- let lastContent = contact.lastContent;
|
|
|
- if (isEmpty(contact)) return false;
|
|
|
+ const conversation = this.findConversation(cid);
|
|
|
+ let lastContent = conversation.lastContent;
|
|
|
+ if (isEmpty(conversation)) return false;
|
|
|
if (this.CacheDraft.has(cid)) {
|
|
|
lastContent = this.CacheDraft.get(cid).lastContent;
|
|
|
}
|
|
@@ -690,6 +692,10 @@ export default {
|
|
|
editorValue,
|
|
|
lastContent,
|
|
|
});
|
|
|
+
|
|
|
+ var tempDraft=this.CacheDraft.get(cid);
|
|
|
+ console.log("qxj editorValue:"+editorValue+",tempDraft:"+JSON.stringify(tempDraft)+"lastContent:"+lastContent);
|
|
|
+
|
|
|
this.updateContact({
|
|
|
id: cid,
|
|
|
lastContent: `<span style="color:red;">[草稿]</span><span>${this.lastContentRender(
|
|
@@ -703,15 +709,14 @@ export default {
|
|
|
clearDraft(contactId) {
|
|
|
const draft = this.CacheDraft.get(contactId);
|
|
|
if (draft) {
|
|
|
- const currentContent = this.findContact(contactId).lastContent;
|
|
|
- if (
|
|
|
- currentContent.indexOf('<span style="color:red;">[草稿]</span>') === 0
|
|
|
- ) {
|
|
|
+ const currentContent = this.findConversation(contactId).lastContent;
|
|
|
+ console.log("qxj currentContent:"+currentContent+",lastContent:"+JSON.stringify(draft));
|
|
|
+ //if (currentContent.indexOf('<span style="color:red;">[草稿]</span>') === 0) {
|
|
|
this.updateContact({
|
|
|
id: contactId,
|
|
|
- lastContent: draft.lastContent,
|
|
|
+ lastContent: draft.lastContent
|
|
|
});
|
|
|
- }
|
|
|
+ //}
|
|
|
this.CacheDraft.remove(contactId);
|
|
|
}
|
|
|
},
|
|
@@ -720,7 +725,6 @@ export default {
|
|
|
* @param contactId 联系人 id
|
|
|
*/
|
|
|
async changeContact(contactId, menuName) {
|
|
|
- console.log("qxj changeContact");
|
|
|
if (menuName) {
|
|
|
this.changeMenu(menuName);
|
|
|
} else {
|
|
@@ -822,7 +826,6 @@ export default {
|
|
|
* @param {String} name 按钮 name
|
|
|
*/
|
|
|
changeMenu(name) {
|
|
|
- console.log("qxj name:"+name);
|
|
|
this.$emit("change-menu", name);
|
|
|
this.activeSidebar = name;
|
|
|
},
|
|
@@ -1009,19 +1012,35 @@ export default {
|
|
|
this.conversations.unshift(conversation);
|
|
|
},
|
|
|
/**
|
|
|
- * 修改联系人数据
|
|
|
+ * 修改会话数据
|
|
|
* @param {Contact} data 修改的数据,根据 Contact.id 查找联系人并覆盖传入的值
|
|
|
*/
|
|
|
updateContact(data) {
|
|
|
const contactId = data.id;
|
|
|
delete data.id;
|
|
|
- const index = this.findContactIndexById(contactId);
|
|
|
+ const index = this.findConversationIndexById(contactId);
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.$set(this.conversations, index, {
|
|
|
+ ...this.conversations[index],
|
|
|
+ ...data,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ updateContact1(data) {
|
|
|
+ const contactId = data.id;
|
|
|
+ delete data.id;
|
|
|
+ const index = this.findContactIndexById(contactId);
|
|
|
if (index !== -1) {
|
|
|
const { unread } = data;
|
|
|
if (isString(unread)) {
|
|
|
if (unread.indexOf("+") === 0 || unread.indexOf("-") === 0) {
|
|
|
- data.unread =
|
|
|
- parseInt(unread) + parseInt(this.contacts[index].unread);
|
|
|
+ data.unread =parseInt(unread) + parseInt(this.contacts[index].unread);
|
|
|
}
|
|
|
}
|
|
|
this.$set(this.contacts, index, {
|
|
@@ -1061,7 +1080,7 @@ export default {
|
|
|
findContact(contactId) {
|
|
|
return this.getContacts().find(({ id }) => id == contactId);
|
|
|
},
|
|
|
- findConversations(currentContactId) {
|
|
|
+ findConversation(currentContactId) {
|
|
|
return this.conversations.find(item => item.conversationId == currentContactId) || {};
|
|
|
},
|
|
|
/**
|