2020-08-12 17:57:39 +02:00
|
|
|
import "./message-history";
|
2020-05-15 14:33:31 +02:00
|
|
|
import xss from "xss/dist/xss";
|
|
|
|
import { CustomElement } from './element.js';
|
|
|
|
import { html } from 'lit-element';
|
|
|
|
import { unsafeHTML } from 'lit-html/directives/unsafe-html.js';
|
2020-12-03 13:40:30 +01:00
|
|
|
import { api } from "@converse/headless/core";
|
2020-05-15 14:33:31 +02:00
|
|
|
|
2020-07-01 21:45:18 +02:00
|
|
|
export default class ChatContent extends CustomElement {
|
2020-05-15 14:33:31 +02:00
|
|
|
|
|
|
|
static get properties () {
|
|
|
|
return {
|
2021-02-08 11:27:42 +01:00
|
|
|
chatview: { type: Object}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
connectedCallback () {
|
|
|
|
super.connectedCallback();
|
|
|
|
const model = this.chatview.model;
|
|
|
|
this.listenTo(model.messages, 'add', this.requestUpdate);
|
|
|
|
this.listenTo(model.messages, 'change', this.requestUpdate);
|
|
|
|
this.listenTo(model.messages, 'remove', this.requestUpdate);
|
|
|
|
this.listenTo(model.messages, 'reset', this.requestUpdate);
|
|
|
|
this.listenTo(model.notifications, 'change', this.requestUpdate);
|
|
|
|
if (model.occupants) {
|
|
|
|
this.listenTo(model.occupants, 'change', this.requestUpdate);
|
2020-05-15 14:33:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
2021-02-08 11:27:42 +01:00
|
|
|
const notifications = xss.filterXSS(this.chatview.getNotifications(), {'whiteList': {}});
|
2020-05-15 14:33:31 +02:00
|
|
|
return html`
|
|
|
|
<converse-message-history
|
|
|
|
.chatview=${this.chatview}
|
2021-02-08 11:27:42 +01:00
|
|
|
.messages=${[...this.chatview.model.messages.models]}>
|
2020-05-15 14:33:31 +02:00
|
|
|
</converse-message-history>
|
|
|
|
<div class="chat-content__notifications">${unsafeHTML(notifications)}</div>
|
|
|
|
`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-01 21:45:18 +02:00
|
|
|
api.elements.define('converse-chat-content', ChatContent);
|