Add reconnect button

This commit is contained in:
Simon Ser 2021-12-07 13:39:02 +01:00
parent fc93a8cef5
commit f6895fed32
2 changed files with 20 additions and 26 deletions

View file

@ -1634,6 +1634,7 @@ export default class App extends Component {
onChannelClick=${this.handleChannelClick} onChannelClick=${this.handleChannelClick}
onClose=${() => this.close(activeBuffer)} onClose=${() => this.close(activeBuffer)}
onJoin=${() => this.handleJoinClick(activeBuffer)} onJoin=${() => this.handleJoinClick(activeBuffer)}
onReconnect=${() => this.reconnect()}
onAddNetwork=${this.handleAddNetworkClick} onAddNetwork=${this.handleAddNetworkClick}
onManageNetwork=${() => this.handleManageNetworkClick(activeBuffer.server)} onManageNetwork=${() => this.handleManageNetworkClick(activeBuffer.server)}
/> />

View file

@ -21,23 +21,6 @@ function NickStatus(props) {
} }
export default function BufferHeader(props) { export default function BufferHeader(props) {
function handleCloseClick(event) {
event.preventDefault();
props.onClose();
}
function handleJoinClick(event) {
event.preventDefault();
props.onJoin();
}
function handleAddNetworkClick(event) {
event.preventDefault();
props.onAddNetwork();
}
function handleManageNetworkClick(event) {
event.preventDefault();
props.onManageNetwork();
}
let fullyConnected = props.server.status === ServerStatus.REGISTERED; let fullyConnected = props.server.status === ServerStatus.REGISTERED;
if (props.bouncerNetwork) { if (props.bouncerNetwork) {
fullyConnected = fullyConnected && props.bouncerNetwork.state === "connected"; fullyConnected = fullyConnected && props.bouncerNetwork.state === "connected";
@ -82,9 +65,15 @@ export default function BufferHeader(props) {
let joinButton = html` let joinButton = html`
<button <button
key="join" key="join"
onClick=${handleJoinClick} onClick=${props.onJoin}
>Join channel</button> >Join channel</button>
`; `;
let reconnectButton = html`
<button
key="reconect"
onClick=${props.onReconnect}
>Reconnect</button>
`;
if (props.server.isBouncer) { if (props.server.isBouncer) {
if (props.server.bouncerNetID) { if (props.server.bouncerNetID) {
@ -95,7 +84,7 @@ export default function BufferHeader(props) {
actions.push(html` actions.push(html`
<button <button
key="manage" key="manage"
onClick=${handleManageNetworkClick} onClick=${props.onManageNetwork}
>Manage network</button> >Manage network</button>
`); `);
} }
@ -104,27 +93,31 @@ export default function BufferHeader(props) {
actions.push(html` actions.push(html`
<button <button
key="add" key="add"
onClick=${handleAddNetworkClick} onClick=${props.onAddNetwork}
>Add network</button> >Add network</button>
`); `);
} else if (props.server.status === ServerStatus.DISCONNECTED) {
actions.push(reconnectButton);
} }
actions.push(html` actions.push(html`
<button <button
key="disconnect" key="disconnect"
class="danger" class="danger"
onClick=${handleCloseClick} onClick=${props.onClose}
>Disconnect</button> >Disconnect</button>
`); `);
} }
} else { } else {
if (fullyConnected) { if (fullyConnected) {
actions.push(joinButton); actions.push(joinButton);
} else if (props.server.status === ServerStatus.DISCONNECTED) {
actions.push(reconnectButton);
} }
actions.push(html` actions.push(html`
<button <button
key="disconnect" key="disconnect"
class="danger" class="danger"
onClick=${handleCloseClick} onClick=${props.onClose}
>Disconnect</button> >Disconnect</button>
`); `);
} }
@ -138,7 +131,7 @@ export default function BufferHeader(props) {
<button <button
key="part" key="part"
class="danger" class="danger"
onClick=${handleCloseClick} onClick=${props.onClose}
>Leave</button> >Leave</button>
`); `);
} else { } else {
@ -146,7 +139,7 @@ export default function BufferHeader(props) {
actions.push(html` actions.push(html`
<button <button
key="join" key="join"
onClick=${handleJoinClick} onClick=${props.onJoin}
>Join</button> >Join</button>
`); `);
} }
@ -154,7 +147,7 @@ export default function BufferHeader(props) {
<button <button
key="part" key="part"
class="danger" class="danger"
onClick=${handleCloseClick} onClick=${props.onClose}
>Close</button> >Close</button>
`); `);
} }
@ -213,7 +206,7 @@ export default function BufferHeader(props) {
<button <button
key="close" key="close"
class="danger" class="danger"
onClick=${handleCloseClick} onClick=${props.onClose}
>Close</button> >Close</button>
`; `;
break; break;