2020-12-10 11:08:17 +01:00
|
|
|
import 'shared/autocomplete/index.js';
|
2021-02-24 09:51:37 +01:00
|
|
|
import tpl_muc_sidebar from "./templates/muc-sidebar.js";
|
2021-02-12 14:55:00 +01:00
|
|
|
import { CustomElement } from 'components/element.js';
|
2020-12-03 13:40:30 +01:00
|
|
|
import { api, converse } from "@converse/headless/core";
|
2020-10-23 20:49:10 +02:00
|
|
|
|
|
|
|
const u = converse.env.utils;
|
|
|
|
|
|
|
|
|
|
|
|
export default class MUCSidebar extends CustomElement {
|
|
|
|
|
|
|
|
static get properties () {
|
|
|
|
return {
|
|
|
|
chatroom: { type: Object },
|
|
|
|
occupants: { type: Object}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
connectedCallback () {
|
|
|
|
super.connectedCallback();
|
|
|
|
this.listenTo(this.occupants, 'add', this.requestUpdate);
|
|
|
|
this.listenTo(this.occupants, 'remove', this.requestUpdate);
|
|
|
|
this.listenTo(this.occupants, 'change', this.requestUpdate);
|
2021-02-12 14:55:00 +01:00
|
|
|
this.chatroom.initialized.then(() => this.requestUpdate());
|
2020-10-23 20:49:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
|
|
|
const tpl = tpl_muc_sidebar(Object.assign(
|
|
|
|
this.chatroom.toJSON(),
|
|
|
|
{'occupants': [...this.occupants.models] }
|
|
|
|
));
|
|
|
|
return tpl;
|
|
|
|
}
|
|
|
|
|
|
|
|
shouldShow () {
|
|
|
|
return !this.chatroom.get('hidden_occupants') &&
|
|
|
|
this.chatroom.session.get('connection_status') === converse.ROOMSTATUS.ENTERED;
|
|
|
|
}
|
|
|
|
|
|
|
|
setVisibility () {
|
|
|
|
// TODO: We're still manually showing/hiding stuff in ChatRoomView,
|
|
|
|
// eventually we want everything to render declaratively, after which this
|
|
|
|
// method won't be necessary anymore
|
|
|
|
this.shouldShow() ? u.showElement(this) : u.hideElement(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
api.elements.define('converse-muc-sidebar', MUCSidebar);
|