From 86853eb2e5521565621efd193481c6a36639ee14 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 29 Nov 2021 11:44:28 +0100 Subject: [PATCH] components/buffer-header: hide action buttons when disconnected --- components/buffer-header.js | 72 +++++++++++++++++++++++-------------- 1 file changed, 45 insertions(+), 27 deletions(-) diff --git a/components/buffer-header.js b/components/buffer-header.js index 30552a6..bb155ed 100644 --- a/components/buffer-header.js +++ b/components/buffer-header.js @@ -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; } + let joinButton = html` + + `; + if (props.isBouncer) { if (props.server.isupport.get("BOUNCER_NETID")) { - actions = html` - - - `; + if (fullyConnected) { + actions.push(joinButton); + actions.push(html` + + `); + } } else { - actions = html` - + if (fullyConnected) { + actions.push(html` + + `); + } + actions.push(html` - `; + `); } } else { - actions = html` - + if (fullyConnected) { + actions.push(joinButton); + } + actions.push(html` - `; + `); } break; case BufferType.CHANNEL: @@ -126,11 +140,15 @@ export default function BufferHeader(props) { >Leave `; } else { + if (fullyConnected) { + actions.push(html` + + `); + } actions = html` -