diff --git a/dev.html b/dev.html index 1dfbf517b..d1a312a5f 100644 --- a/dev.html +++ b/dev.html @@ -28,6 +28,7 @@ }); converse.initialize({ + theme: 'dracula', auto_away: 300, enable_smacks: true, loglevel: 'debug', diff --git a/src/plugins/muc-views/modals/occupant.js b/src/plugins/muc-views/modals/occupant.js index 0bee536f8..f623fe1a8 100644 --- a/src/plugins/muc-views/modals/occupant.js +++ b/src/plugins/muc-views/modals/occupant.js @@ -28,24 +28,10 @@ export default class OccupantModal extends BaseModal { } renderModal () { - const model = this.model ?? this.message; - const jid = model?.get('jid'); - const vcard = this.getVcard(); - const nick = model.get('nick'); - const occupant_id = model.get('occupant_id'); - const role = this.model?.get('role'); - const affiliation = this.model?.get('affiliation'); - const hats = this.model?.get('hats')?.length ? this.model.get('hats') : null; - const muc = this.model.collection.chatroom; - const addToContacts = api.contacts.get(jid).then(contact => { - if (!contact && muc.features.get('nonanonymous') && jid && jid != _converse.bare_jid) { - return this.addToContacts.bind(this); - } - }); - return tpl_occupant_modal({ jid, vcard, nick, occupant_id, role, affiliation, hats, addToContacts }); + return tpl_occupant_modal(this); } - getModalTitle () { // eslint-disable-line class-methods-use-this + getModalTitle () { const model = this.model ?? this.message; return model?.getDisplayName(); } diff --git a/src/plugins/muc-views/modals/templates/occupant.js b/src/plugins/muc-views/modals/templates/occupant.js index c5de45c68..2c248811e 100644 --- a/src/plugins/muc-views/modals/templates/occupant.js +++ b/src/plugins/muc-views/modals/templates/occupant.js @@ -2,40 +2,59 @@ import 'shared/avatar/avatar.js'; import { __ } from 'i18n'; import { html } from "lit"; import { until } from 'lit/directives/until.js'; +import { _converse, api } from "@converse/headless/core"; -export default (o) => { - const addToContacts = o.addToContacts.then(add => add ? html`
` : ''); +export default (el) => { + const model = el.model ?? el.message; + const jid = model?.get('jid'); + const vcard = el.getVcard(); + const nick = model.get('nick'); + const occupant_id = model.get('occupant_id'); + const role = el.model?.get('role'); + const affiliation = el.model?.get('affiliation'); + const hats = el.model?.get('hats')?.length ? el.model.get('hats') : null; + const muc = el.model.collection.chatroom; + + const i18n_add_to_contacts = __('Add to Contacts'); + + const can_see_real_jids = muc.features.get('nonanonymous') || muc.getOwnRole() === 'moderator'; + const not_me = jid != _converse.bare_jid; + + const add_to_contacts = api.contacts.get(jid) + .then(contact => !contact && not_me && can_see_real_jids) + .then(add => add ? html`` : ''); + return html`