Auto-join previous channels on reconnect

Closes: https://todo.sr.ht/~emersion/gamja/47
This commit is contained in:
Simon Ser 2021-09-21 19:20:39 +02:00
parent 5c90764718
commit 7bf9a0ca25

View File

@ -581,13 +581,6 @@ export default class App extends Component {
let target, channel, affectedBuffers; let target, channel, affectedBuffers;
switch (msg.command) { switch (msg.command) {
case irc.RPL_WELCOME: case irc.RPL_WELCOME:
if (this.state.connectParams.autojoin.length > 0) {
client.send({
command: "JOIN",
params: [this.state.connectParams.autojoin.join(",")],
});
}
let lastReceipt = this.latestReceipt(ReceiptType.DELIVERED); let lastReceipt = this.latestReceipt(ReceiptType.DELIVERED);
if (lastReceipt && lastReceipt.time && client.enabledCaps["draft/chathistory"] && (!client.enabledCaps["soju.im/bouncer-networks"] || client.params.bouncerNetwork)) { if (lastReceipt && lastReceipt.time && client.enabledCaps["draft/chathistory"] && (!client.enabledCaps["soju.im/bouncer-networks"] || client.params.bouncerNetwork)) {
let now = irc.formatDate(new Date()); let now = irc.formatDate(new Date());
@ -604,13 +597,32 @@ export default class App extends Component {
case irc.ERR_NOMOTD: case irc.ERR_NOMOTD:
// These messages are used to indicate the end of the ISUPPORT list // These messages are used to indicate the end of the ISUPPORT list
// Restore opened user query buffers // Restore opened channel and user buffers
let join = [];
for (let buf of this.bufferStore.list(client.params)) { for (let buf of this.bufferStore.list(client.params)) {
if (buf.name === "*" || client.isChannel(buf.name)) { if (buf.name === "*") {
continue; continue;
} }
this.createBuffer(serverID, buf.name);
this.whoUserBuffer(buf.name, serverID); if (client.isChannel(buf.name)) {
if (client.enabledCaps["soju.im/bouncer-networks"]) {
continue;
}
join.push(buf.name);
} else {
this.createBuffer(serverID, buf.name);
this.whoUserBuffer(buf.name, serverID);
}
}
// Auto-join channels given at connect-time
join = join.concat(this.state.connectParams.autojoin);
if (join.length > 0) {
client.send({
command: "JOIN",
params: [join.join(",")],
});
} }
case "MODE": case "MODE":
target = msg.params[0]; target = msg.params[0];