mirror of
https://git.sr.ht/~emersion/gamja
synced 2024-12-04 21:31:08 -05:00
components/buffer-header: hide action buttons when disconnected
This commit is contained in:
parent
1800b6bea1
commit
86853eb2e5
1 changed files with 45 additions and 27 deletions
|
@ -38,7 +38,12 @@ export default function BufferHeader(props) {
|
||||||
props.onManageNetwork();
|
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) {
|
switch (props.buffer.type) {
|
||||||
case BufferType.SERVER:
|
case BufferType.SERVER:
|
||||||
switch (props.server.status) {
|
switch (props.server.status) {
|
||||||
|
@ -74,43 +79,52 @@ export default function BufferHeader(props) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (props.isBouncer) {
|
let joinButton = html`
|
||||||
if (props.server.isupport.get("BOUNCER_NETID")) {
|
|
||||||
actions = html`
|
|
||||||
<button
|
<button
|
||||||
key="join"
|
key="join"
|
||||||
onClick=${handleJoinClick}
|
onClick=${handleJoinClick}
|
||||||
>Join channel</button>
|
>Join channel</button>
|
||||||
|
`;
|
||||||
|
|
||||||
|
if (props.isBouncer) {
|
||||||
|
if (props.server.isupport.get("BOUNCER_NETID")) {
|
||||||
|
if (fullyConnected) {
|
||||||
|
actions.push(joinButton);
|
||||||
|
actions.push(html`
|
||||||
<button
|
<button
|
||||||
key="manage"
|
key="manage"
|
||||||
onClick=${handleManageNetworkClick}
|
onClick=${handleManageNetworkClick}
|
||||||
>Manage network</button>
|
>Manage network</button>
|
||||||
`;
|
`);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
actions = html`
|
if (fullyConnected) {
|
||||||
|
actions.push(html`
|
||||||
<button
|
<button
|
||||||
key="add"
|
key="add"
|
||||||
onClick=${handleAddNetworkClick}
|
onClick=${handleAddNetworkClick}
|
||||||
>Add network</button>
|
>Add network</button>
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
actions.push(html`
|
||||||
<button
|
<button
|
||||||
key="disconnect"
|
key="disconnect"
|
||||||
class="danger"
|
class="danger"
|
||||||
onClick=${handleCloseClick}
|
onClick=${handleCloseClick}
|
||||||
>Disconnect</button>
|
>Disconnect</button>
|
||||||
`;
|
`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
actions = html`
|
if (fullyConnected) {
|
||||||
<button
|
actions.push(joinButton);
|
||||||
key="join"
|
}
|
||||||
onClick=${handleJoinClick}
|
actions.push(html`
|
||||||
>Join channel</button>
|
|
||||||
<button
|
<button
|
||||||
key="disconnect"
|
key="disconnect"
|
||||||
class="danger"
|
class="danger"
|
||||||
onClick=${handleCloseClick}
|
onClick=${handleCloseClick}
|
||||||
>Disconnect</button>
|
>Disconnect</button>
|
||||||
`;
|
`);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BufferType.CHANNEL:
|
case BufferType.CHANNEL:
|
||||||
|
@ -126,11 +140,15 @@ export default function BufferHeader(props) {
|
||||||
>Leave</button>
|
>Leave</button>
|
||||||
`;
|
`;
|
||||||
} else {
|
} else {
|
||||||
actions = html`
|
if (fullyConnected) {
|
||||||
|
actions.push(html`
|
||||||
<button
|
<button
|
||||||
key="join"
|
key="join"
|
||||||
onClick=${handleJoinClick}
|
onClick=${handleJoinClick}
|
||||||
>Join</button>
|
>Join</button>
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
actions = html`
|
||||||
<button
|
<button
|
||||||
key="part"
|
key="part"
|
||||||
class="danger"
|
class="danger"
|
||||||
|
|
Loading…
Reference in a new issue