![JC Brand](/assets/img/avatar_default.png)
It's now necessary to add a `converse-root` element in the DOM where you want Converse to render (previously it was any element with the id `#conversejs`). Also, turned `converse-chats` element into a Lit element and re-render `converse-root` and `converse-chats` when the `view-mode` or `singleton` settings change. This is a step towards being able to change the view mode on the fly and have the entire chat re-render appropriately. Fixes #2647
19 lines
508 B
JavaScript
19 lines
508 B
JavaScript
import { api } from '@converse/headless/core';
|
|
|
|
|
|
export function ensureElement () {
|
|
if (!api.settings.get('auto_insert')) {
|
|
return;
|
|
}
|
|
const root = api.settings.get('root');
|
|
if (!root.querySelector('converse-root')) {
|
|
const el = document.createElement('converse-root');
|
|
const body = root.querySelector('body');
|
|
if (body) {
|
|
body.appendChild(el);
|
|
} else {
|
|
root.appendChild(el); // Perhaps inside a web component?
|
|
}
|
|
}
|
|
}
|