|
@@ -105,6 +105,7 @@ export default {
|
|
currentMessages: [],
|
|
currentMessages: [],
|
|
activeSidebar: DEFAULT_MENU_LASTMESSAGES,
|
|
activeSidebar: DEFAULT_MENU_LASTMESSAGES,
|
|
contacts: [],
|
|
contacts: [],
|
|
|
|
+ conversations:[],
|
|
menus: [],
|
|
menus: [],
|
|
editorTools: [
|
|
editorTools: [
|
|
{ name: "emoji" },
|
|
{ name: "emoji" },
|
|
@@ -117,8 +118,8 @@ export default {
|
|
render() {
|
|
render() {
|
|
return this._renderWrapper([
|
|
return this._renderWrapper([
|
|
this._renderMenu(),
|
|
this._renderMenu(),
|
|
- this._renderSidebarMessage(),
|
|
|
|
- this._renderSidebarContact(),
|
|
|
|
|
|
+ this._renderSidebarMessage(),//加载会话数据
|
|
|
|
+ this._renderSidebarContact(),//加载联系人
|
|
this._renderContainer(),
|
|
this._renderContainer(),
|
|
this._renderDrawer(),
|
|
this._renderDrawer(),
|
|
]);
|
|
]);
|
|
@@ -140,10 +141,13 @@ export default {
|
|
return DEFAULT_MENUS.includes(this.activeSidebar);
|
|
return DEFAULT_MENUS.includes(this.activeSidebar);
|
|
},
|
|
},
|
|
lastMessages() {
|
|
lastMessages() {
|
|
- const data = this.contacts.filter(item => !isEmpty(item.lastContent));
|
|
|
|
|
|
+ var data = this.contacts.filter(item => !isEmpty(item.lastContent));
|
|
data.sort((a1, a2) => {
|
|
data.sort((a1, a2) => {
|
|
return a2.lastSendTime - a1.lastSendTime;
|
|
return a2.lastSendTime - a1.lastSendTime;
|
|
});
|
|
});
|
|
|
|
+ if(!!this.conversations){
|
|
|
|
+ data=this.conversations;
|
|
|
|
+ }
|
|
return data;
|
|
return data;
|
|
},
|
|
},
|
|
},
|
|
},
|
|
@@ -877,6 +881,15 @@ export default {
|
|
this.contacts = data;
|
|
this.contacts = data;
|
|
this.sortContacts();
|
|
this.sortContacts();
|
|
},
|
|
},
|
|
|
|
+ /**
|
|
|
|
+ * 初始化会话数据
|
|
|
|
+ * @param {Array<Contact>} data 会话列表
|
|
|
|
+ */
|
|
|
|
+ initConversations(data) {
|
|
|
|
+ this.conversations = data;
|
|
|
|
+ this.sortConversations();
|
|
|
|
+ },
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 使用 联系人的 index 值进行排序
|
|
* 使用 联系人的 index 值进行排序
|
|
*/
|
|
*/
|
|
@@ -886,6 +899,12 @@ export default {
|
|
return a.index.localeCompare(b.index);
|
|
return a.index.localeCompare(b.index);
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
+ sortConversations() {
|
|
|
|
+ this.conversations.sort((a, b) => {
|
|
|
|
+ if (!a.index) return;
|
|
|
|
+ return a.index.localeCompare(b.index);
|
|
|
|
+ });
|
|
|
|
+ },
|
|
appendContact(contact) {
|
|
appendContact(contact) {
|
|
if (isEmpty(contact.id) || isEmpty(contact.displayName)) {
|
|
if (isEmpty(contact.id) || isEmpty(contact.displayName)) {
|
|
console.error("id | displayName cant be empty");
|
|
console.error("id | displayName cant be empty");
|