fix chat render for contacts

This commit is contained in:
Achilles Rasquinha 2018-03-28 13:18:55 +05:30
parent 1519e36a61
commit 80d9a6f504

View file

@ -1547,10 +1547,19 @@ class extends Component {
var contacts = [ ]
if ( 'user_info' in frappe.boot ) {
const emails = frappe.user.get_emails()
for (const room of state.rooms)
if ( room.type === 'Direct' )
if ( !emails.includes(room.owner) || !emails.includes(frappe._.squash(room.users)) )
contacts.append({ owner: frappe.session.user, users: [email] }) // placeholder.
for (const email of emails) {
var exists = false
for (const room of state.rooms) {
if ( room.type === 'Direct' ) {
if ( room.owner === email || frappe._.squash(room.users) === email )
exists = true
}
}
if ( !exists )
contacts.push({ owner: frappe.session.user, users: [email] })
}
}
const rooms = state.query ? frappe.chat.room.search(state.query, state.rooms.concat(contacts)) : frappe.chat.room.sort(state.rooms)