import { __ } from 'i18n'; import { _converse } from '@converse/headless/core'; import { getHeadingDropdownItem, getHeadingStandaloneButton } from 'plugins/chatview/utils.js'; import { html } from "lit"; import { until } from 'lit/directives/until.js'; async function getStandaloneButtons (promise) { const heading_btns = await promise; const standalone_btns = heading_btns.filter(b => b.standalone); return standalone_btns.map(b => getHeadingStandaloneButton(b)) } async function getDropdownButtons (promise) { const heading_btns = await promise; const dropdown_btns = heading_btns.filter(b => !b.standalone); return dropdown_btns.map(b => getHeadingDropdownItem(b)); } export default (o) => { const i18n_profile = __("The User's Profile Image"); const avatar = html` `; const display_name = o.model.getDisplayName(); const tpl_dropdown_btns = () => getDropdownButtons(o.heading_buttons_promise) .then(btns => btns.length ? html`` : ''); const tpl_standalone_btns = () => getStandaloneButtons(o.heading_buttons_promise) .then(btns => btns.reverse().map(b => until(b, ''))); return html`
${ (!_converse.api.settings.get("singleton")) ? html`` : '' } ${ (o.type !== _converse.HEADLINES_TYPE) ? html`${ avatar }` : '' }
${ (o.type !== _converse.HEADLINES_TYPE) ? html`${ display_name }` : display_name }
${ until(tpl_dropdown_btns(), '') } ${ until(tpl_standalone_btns(), '') }
${ o.status ? html`

${ o.status }

` : '' } `; }