Clear channel joined field when disconnected

This commit is contained in:
Simon Ser 2021-11-29 11:44:45 +01:00
parent 86853eb2e5
commit 25e69a551e

View file

@ -581,11 +581,26 @@ export default class App extends Component {
client.addEventListener("status", () => { client.addEventListener("status", () => {
this.setServerState(serverID, { status: client.status }); this.setServerState(serverID, { status: client.status });
if (client.status === Client.Status.REGISTERED) { switch (client.status) {
case Client.Status.DISCONNECTED:
this.setServerState(serverID, { account: null });
this.setState((state) => {
let buffers = new Map(state.buffers);
state.buffers.forEach((buf) => {
if (buf.server !== serverID) {
return;
}
buffers.set(buf.id, { ...buf, joined: false });
});
return { buffers };
});
break;
case Client.Status.REGISTERED:
this.setState({ connectForm: false }); this.setState({ connectForm: false });
if (errorID) { if (errorID) {
this.dismissError(errorID); this.dismissError(errorID);
} }
break;
} }
}); });