diff --git a/src/client-connection.ts b/src/client-connection.ts
index 73387ba81..fec8a04ec 100644
--- a/src/client-connection.ts
+++ b/src/client-connection.ts
@@ -32,8 +32,9 @@ class PSConnection {
};
socket.onclose = () => {
console.log('\u2705 (DISCONNECTED)');
- PS.connected = false;
this.connected = false;
+ PS.connected = false;
+ PS.isOffline = true;
for (const roomid in PS.rooms) {
PS.rooms[roomid]!.connected = false;
}
diff --git a/src/client-main.ts b/src/client-main.ts
index c3259d7cf..ec8b8c1e0 100644
--- a/src/client-main.ts
+++ b/src/client-main.ts
@@ -415,6 +415,15 @@ const PS = new class extends PSModel {
server = new PSServer();
connection: PSConnection | null = null;
connected = false;
+ /**
+ * While PS is technically disconnected while it's trying to connect,
+ * it still shows UI like it's connected, so you can click buttons
+ * before the server connection is established.
+ *
+ * `isOffline` is only set if PS is neither connected nor trying to
+ * connect.
+ */
+ isOffline = false;
router: PSRouter = null!;
diff --git a/src/panel-mainmenu.tsx b/src/panel-mainmenu.tsx
index 291438516..1bd25dd5b 100644
--- a/src/panel-mainmenu.tsx
+++ b/src/panel-mainmenu.tsx
@@ -91,6 +91,7 @@ class MainMenuPanel extends PSRoomPanel {
(this.base!.querySelector('button.big') as HTMLButtonElement).focus();
}
render() {
+ const onlineButton = ' button' + (PS.isOffline ? ' disabled' : '');
const searchButton = (PS.down ?
);
- const onlineButton = ' button' + (PS.connected ? '' : ' disabled');
return
;
}