From 959b0af8a5d2f46039e6f24680aa7a6974d99c55 Mon Sep 17 00:00:00 2001 From: Guangcong Luo Date: Thu, 4 Dec 2025 15:30:41 +0000 Subject: [PATCH] Preact: Fix DMs not reconnecting Fixes the thing where, after reconnecting, DMs still looked disconnected. --- play.pokemonshowdown.com/src/client-main.ts | 2 +- play.pokemonshowdown.com/src/panel-chat.tsx | 17 +++++++++++------ play.pokemonshowdown.com/src/panel-mainmenu.tsx | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/play.pokemonshowdown.com/src/client-main.ts b/play.pokemonshowdown.com/src/client-main.ts index 570eddc37..0c4965b0c 100644 --- a/play.pokemonshowdown.com/src/client-main.ts +++ b/play.pokemonshowdown.com/src/client-main.ts @@ -970,7 +970,7 @@ export class PSRoom extends PSStreamModel implements RoomOptions { * the room isn't connected to the game server but to something * else. * - * `true` for DMs for historical reasons (TODO: fix) + * 'client-only' for DMs */ connected: 'autoreconnect' | 'client-only' | 'expired' | boolean = false; /** diff --git a/play.pokemonshowdown.com/src/panel-chat.tsx b/play.pokemonshowdown.com/src/panel-chat.tsx index 17b678383..3ac73debd 100644 --- a/play.pokemonshowdown.com/src/panel-chat.tsx +++ b/play.pokemonshowdown.com/src/panel-chat.tsx @@ -68,8 +68,12 @@ export class ChatRoom extends PSRoom { } override connect() { if (!this.connected || this.connected === 'autoreconnect') { - if (this.pmTarget === null) PS.send(`/join ${this.id}`); - this.connected = true; + if (this.pmTarget === null) { + PS.send(`/join ${this.id}`); + this.connected = true; + } else { + this.connected = 'client-only'; + } this.connectWhenLoggedIn = false; } } @@ -729,7 +733,6 @@ export class ChatRoom extends PSRoom { } override destroy() { - if (this.pmTarget) this.connected = false; if (this.battle) { // since battle is defined here, we might as well deallocate it here this.battle.destroy(); @@ -1172,19 +1175,21 @@ export class ChatTextEntry extends preact.Component<{ override render() { const { room } = this.props; const OLD_TEXTBOX = false; - const canTalk = PS.user.named || room.id === 'dm-'; if (room.connected === 'client-only' && room.id.startsWith('battle-')) { return
; } + + const canTalk = PS.user.named || room.id === 'dm-'; + const connected = room.connected === true || room.connected === 'client-only'; return
{OLD_TEXTBOX ?