Keep track of channel join status

This makes us behave better when we receive a self-PART message
from the server.
This commit is contained in:
Simon Ser
2021-11-05 11:49:56 +01:00
parent 7b19cf48a4
commit 800f5ceb6a
3 changed files with 44 additions and 13 deletions
+14 -4
View File
@@ -1023,7 +1023,9 @@ export default class App extends Component {
}
break;
case BufferType.CHANNEL:
client.send({ command: "PART", params: [buf.name] });
if (buf.joined) {
client.send({ command: "PART", params: [buf.name] });
}
// fallthrough
case BufferType.NICK:
this.switchBuffer({ name: SERVER_BUFFER });
@@ -1150,8 +1152,16 @@ export default class App extends Component {
});
}
handleJoinClick(serverID) {
this.openDialog("join", { server: serverID });
handleJoinClick(buf) {
switch (buf.type) {
case BufferType.SERVER:
this.openDialog("join", { server: buf.server });
break;
case BufferType.CHANNEL:
let client = this.clients.get(buf.server);
client.send({ command: "JOIN", params: [buf.name] });
break;
}
}
handleJoinSubmit(data) {
@@ -1351,7 +1361,7 @@ export default class App extends Component {
bouncerNetwork=${activeBouncerNetwork}
onChannelClick=${this.handleChannelClick}
onClose=${() => this.close(activeBuffer)}
onJoin=${() => this.handleJoinClick(activeBuffer.server)}
onJoin=${() => this.handleJoinClick(activeBuffer)}
onAddNetwork=${this.handleAddNetworkClick}
onManageNetwork=${() => this.handleManageNetworkClick(activeBuffer.server)}
/>
+21 -7
View File
@@ -117,13 +117,27 @@ export default function BufferHeader(props) {
if (props.buffer.topic) {
description = linkify(stripANSI(props.buffer.topic), props.onChannelClick);
}
actions = html`
<button
key="part"
class="danger"
onClick=${handleCloseClick}
>Leave</button>
`;
if (props.buffer.joined) {
actions = html`
<button
key="part"
class="danger"
onClick=${handleCloseClick}
>Leave</button>
`;
} else {
actions = html`
<button
key="join"
onClick=${handleJoinClick}
>Join</button>
<button
key="part"
class="danger"
onClick=${handleCloseClick}
>Close</button>
`;
}
break;
case BufferType.NICK:
if (props.user) {