Don't render unnecessary components when not in overlayed view mode

Specifically `converse-minimized-chats` and `converse-controlbox-toggle`
This commit is contained in:
JC Brand 2021-01-25 21:43:05 +01:00
parent d1c807ec79
commit fa7443be95
2 changed files with 7 additions and 5 deletions

View File

@ -3,7 +3,7 @@
const u = converse.env.utils;
fdescribe("A list of open groupchats", function () {
describe("A list of open groupchats", function () {
it("is shown in controlbox", mock.initConverse(
['rosterGroupsFetched', 'chatBoxesFetched'],
@ -102,7 +102,7 @@ fdescribe("A list of open groupchats", function () {
expect(Array.from(list.classList).includes('hidden')).toBeFalsy();
const items = list.querySelectorAll('.list-item');
expect(items.length).toBe(1);
expect(items[0].textContent.trim()).toBe('Bookmarked Lounge');
await u.waitUntil(() => list.querySelector('.list-item').textContent.trim() === 'Bookmarked Lounge');
expect(_converse.bookmarks.fetchBookmarks).toHaveBeenCalled();
done();
}));

View File

@ -1,14 +1,16 @@
import { html } from 'lit-html';
import { _converse } from '@converse/headless/core';
import { _converse, api } from '@converse/headless/core';
export default () => {
const { chatboxes, CONTROLBOX_TYPE, CHATROOMS_TYPE } = _converse;
const view_mode = api.settings.get('view_mode');
return html`
<converse-minimized-chats></converse-minimized-chats>
${view_mode === 'overlayed' ? html`<converse-minimized-chats></converse-minimized-chats>` : ''}
${chatboxes.map(m => {
if (m.get('type') === CONTROLBOX_TYPE) {
return html`
<converse-controlbox-toggle class="${!m.get('closed') ? 'hidden' : ''}"></converse-controlbox-toggle>
${view_mode === 'overlayed' ? html`<converse-controlbox-toggle class="${!m.get('closed') ? 'hidden' : ''}"></converse-controlbox-toggle>` : ''}
<converse-controlbox
id="controlbox"
class="chatbox ${m.get('closed') ? 'hidden' : ''}"