|
| 1 | +import { html, nothing } from 'lit'; |
| 2 | +import { _converse, api, constants } from '@converse/headless'; |
| 3 | +import { isMobileViewport } from 'shared/chat/utils'; |
| 4 | + |
| 5 | +const { CONTROLBOX_TYPE, CONNECTION_STATUS } = constants; |
| 6 | + |
| 7 | +export default () => { |
| 8 | + const { chatboxes, connfeedback } = _converse.state; |
| 9 | + const view_mode = api.settings.get('view_mode'); |
| 10 | + const is_overlayed = view_mode === 'overlayed'; |
| 11 | + const is_mobile = isMobileViewport(); |
| 12 | + const connection = api.connection.get(); |
| 13 | + const logged_out = !connection?.connected || !connection?.authenticated || connection?.disconnecting; |
| 14 | + const connection_status = connfeedback.get('connection_status'); |
| 15 | + const controlbox = chatboxes.find((m) => m.get('type') === CONTROLBOX_TYPE); |
| 16 | + const width = controlbox.get('width'); |
| 17 | + const style = !is_mobile && is_overlayed && width ? `width: ${width}px` : nothing; |
| 18 | + const connecting = ['CONNECTED', 'CONNECTING', 'AUTHENTICATING', 'RECONNECTING'].includes( |
| 19 | + CONNECTION_STATUS[connection_status] |
| 20 | + ); |
| 21 | + |
| 22 | + return html` |
| 23 | + ${!logged_out && is_overlayed |
| 24 | + ? html`<converse-minimized-chats class="col-auto"></converse-minimized-chats>` |
| 25 | + : ''} |
| 26 | + ${is_overlayed && controlbox.get('closed') |
| 27 | + ? html`<converse-controlbox-toggle class="col-auto"></converse-controlbox-toggle>` |
| 28 | + : html`<converse-controlbox |
| 29 | + id="controlbox" |
| 30 | + class="col-auto chatbox ${logged_out && !connecting ? 'logged-out' : ''}" |
| 31 | + style="${style}" |
| 32 | + ></converse-controlbox>`} |
| 33 | + `; |
| 34 | +}; |
0 commit comments