增加removeContact、appendContact

This commit is contained in:
fan
2021-01-27 23:08:36 +08:00
parent 1f00b8128c
commit 1a4fddb482
12 changed files with 131 additions and 13 deletions
+32
View File
@@ -8376,6 +8376,29 @@ var renderDrawerContent = function renderDrawerContent() {};
return a.index.localeCompare(b.index);
});
},
appendContact: function appendContact(contact) {
if (isEmpty(contact.id) || isEmpty(contact.displayName)) {
console.error('id | displayName cant be empty');
return false;
}
if (this.hasContact(contact.id)) return true;
this.contacts.push(Object.assign(_defineProperty({
id: '',
displayName: '',
avatar: '',
index: '',
unread: 0,
lastSendTime: ''
}, "lastSendTime", ''), contact));
return true;
},
removeContact: function removeContact(id) {
var index = this.findContactIndexById(id);
if (index === -1) return false;
this.contacts.splice(index, 1);
return true;
},
/**
* 修改联系人数据
@@ -8409,6 +8432,15 @@ var renderDrawerContent = function renderDrawerContent() {};
return item.id == contactId;
});
},
/**
* 根据 id 查找判断是否存在联系人
* @param contactId 联系人 id
* @return {Boolean}
*/
hasContact: function hasContact(contactId) {
return this.findContactIndexById(contactId) !== -1;
},
findMessage: function findMessage(messageId) {
return Object.values(allMessages).flat().find(function (_ref3) {
var id = _ref3.id;
+32
View File
@@ -8385,6 +8385,29 @@ var renderDrawerContent = function renderDrawerContent() {};
return a.index.localeCompare(b.index);
});
},
appendContact: function appendContact(contact) {
if (isEmpty(contact.id) || isEmpty(contact.displayName)) {
console.error('id | displayName cant be empty');
return false;
}
if (this.hasContact(contact.id)) return true;
this.contacts.push(Object.assign(_defineProperty({
id: '',
displayName: '',
avatar: '',
index: '',
unread: 0,
lastSendTime: ''
}, "lastSendTime", ''), contact));
return true;
},
removeContact: function removeContact(id) {
var index = this.findContactIndexById(id);
if (index === -1) return false;
this.contacts.splice(index, 1);
return true;
},
/**
* 修改联系人数据
@@ -8418,6 +8441,15 @@ var renderDrawerContent = function renderDrawerContent() {};
return item.id == contactId;
});
},
/**
* 根据 id 查找判断是否存在联系人
* @param contactId 联系人 id
* @return {Boolean}
*/
hasContact: function hasContact(contactId) {
return this.findContactIndexById(contactId) !== -1;
},
findMessage: function findMessage(messageId) {
return Object.values(allMessages).flat().find(function (_ref3) {
var id = _ref3.id;
+1 -1
View File
File diff suppressed because one or more lines are too long