From a6b02147fa692a62b70894f432261e3983409657 Mon Sep 17 00:00:00 2001 From: Dieter Reinert Date: Tue, 10 Jun 2025 15:15:06 +0200 Subject: [PATCH] Preact: Support auto-rejoin for battle rooms (#2457) --------- Co-authored-by: Guangcong Luo --- play.pokemonshowdown.com/src/client-main.ts | 7 +++++++ play.pokemonshowdown.com/src/panel-chat.tsx | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/play.pokemonshowdown.com/src/client-main.ts b/play.pokemonshowdown.com/src/client-main.ts index 1ebf96172..35646bb3a 100644 --- a/play.pokemonshowdown.com/src/client-main.ts +++ b/play.pokemonshowdown.com/src/client-main.ts @@ -304,6 +304,13 @@ class PSPrefs extends PSStreamModel { // 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(); + } + } } } diff --git a/play.pokemonshowdown.com/src/panel-chat.tsx b/play.pokemonshowdown.com/src/panel-chat.tsx index 5f805ebd7..074da702a 100644 --- a/play.pokemonshowdown.com/src/panel-chat.tsx +++ b/play.pokemonshowdown.com/src/panel-chat.tsx @@ -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;