mirror of
https://git.sr.ht/~emersion/gamja
synced 2024-12-04 13:21:21 -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let joinButton = html`
|
||||||
|
<button
|
||||||
|
key="join"
|
||||||
|
onClick=${handleJoinClick}
|
||||||
|
>Join channel</button>
|
||||||
|
`;
|
||||||
|
|
||||||
if (props.isBouncer) {
|
if (props.isBouncer) {
|
||||||
if (props.server.isupport.get("BOUNCER_NETID")) {
|
if (props.server.isupport.get("BOUNCER_NETID")) {
|
||||||
actions = html`
|
if (fullyConnected) {
|
||||||
<button
|
actions.push(joinButton);
|
||||||
key="join"
|
actions.push(html`
|
||||||
onClick=${handleJoinClick}
|
<button
|
||||||
>Join channel</button>
|
key="manage"
|
||||||
<button
|
onClick=${handleManageNetworkClick}
|
||||||
key="manage"
|
>Manage network</button>
|
||||||
onClick=${handleManageNetworkClick}
|
`);
|
||||||
>Manage network</button>
|
}
|
||||||
`;
|
|
||||||
} else {
|
} else {
|
||||||
actions = html`
|
if (fullyConnected) {
|
||||||
<button
|
actions.push(html`
|
||||||
key="add"
|
<button
|
||||||
onClick=${handleAddNetworkClick}
|
key="add"
|
||||||
>Add network</button>
|
onClick=${handleAddNetworkClick}
|
||||||
|
>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 {
|
||||||
|
if (fullyConnected) {
|
||||||
|
actions.push(html`
|
||||||
|
<button
|
||||||
|
key="join"
|
||||||
|
onClick=${handleJoinClick}
|
||||||
|
>Join</button>
|
||||||
|
`);
|
||||||
|
}
|
||||||
actions = html`
|
actions = html`
|
||||||
<button
|
|
||||||
key="join"
|
|
||||||
onClick=${handleJoinClick}
|
|
||||||
>Join</button>
|
|
||||||
<button
|
<button
|
||||||
key="part"
|
key="part"
|
||||||
class="danger"
|
class="danger"
|
||||||
|
|
Loading…
Reference in a new issue