components/buffer-header: hide action buttons when disconnected

This commit is contained in:
Simon Ser 2021-11-29 11:44:28 +01:00
parent 1800b6bea1
commit 86853eb2e5

View file

@ -38,7 +38,12 @@ export default function BufferHeader(props) {
props.onManageNetwork();
}
let description = null, actions = null;
let fullyConnected = props.server.status === ServerStatus.REGISTERED;
if (props.bouncerNetwork) {
fullyConnected = fullyConnected && props.bouncerNetwork.state === "connected";
}
let description = null, actions = [];
switch (props.buffer.type) {
case BufferType.SERVER:
switch (props.server.status) {
@ -74,43 +79,52 @@ export default function BufferHeader(props) {
break;
}
if (props.isBouncer) {
if (props.server.isupport.get("BOUNCER_NETID")) {
actions = html`
let joinButton = html`
<button
key="join"
onClick=${handleJoinClick}
>Join channel</button>
`;
if (props.isBouncer) {
if (props.server.isupport.get("BOUNCER_NETID")) {
if (fullyConnected) {
actions.push(joinButton);
actions.push(html`
<button
key="manage"
onClick=${handleManageNetworkClick}
>Manage network</button>
`;
`);
}
} else {
actions = html`
if (fullyConnected) {
actions.push(html`
<button
key="add"
onClick=${handleAddNetworkClick}
>Add network</button>
`);
}
actions.push(html`
<button
key="disconnect"
class="danger"
onClick=${handleCloseClick}
>Disconnect</button>
`;
`);
}
} else {
actions = html`
<button
key="join"
onClick=${handleJoinClick}
>Join channel</button>
if (fullyConnected) {
actions.push(joinButton);
}
actions.push(html`
<button
key="disconnect"
class="danger"
onClick=${handleCloseClick}
>Disconnect</button>
`;
`);
}
break;
case BufferType.CHANNEL:
@ -126,11 +140,15 @@ export default function BufferHeader(props) {
>Leave</button>
`;
} else {
actions = html`
if (fullyConnected) {
actions.push(html`
<button
key="join"
onClick=${handleJoinClick}
>Join</button>
`);
}
actions = html`
<button
key="part"
class="danger"