Preact: Support auto-rejoin for battle rooms (#2457)

---------

Co-authored-by: Guangcong Luo <guangcongluo@gmail.com>
This commit is contained in:
Dieter Reinert 2025-06-10 15:15:06 +02:00 committed by GitHub
parent 883e2043af
commit a6b02147fa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 1 deletions

View File

@ -304,6 +304,13 @@ class PSPrefs extends PSStreamModel<string | null> {
// send even if `rooms` is empty, for server autojoins
PS.send(cmd);
}
for (const roomid in PS.rooms) {
const room = PS.rooms[roomid]!;
if (room.type === 'battle') {
room.connect();
}
}
}
}

View File

@ -67,7 +67,7 @@ export class ChatRoom extends PSRoom {
this.connect();
}
override connect() {
if (!this.connected) {
if (!this.connected || this.connected === 'autoreconnect') {
if (this.pmTarget === null) PS.send(`/join ${this.id}`);
this.connected = true;
this.connectWhenLoggedIn = false;