From 1a1ed4e1d0568a1610d5f5da3d541a59afe2b863 Mon Sep 17 00:00:00 2001 From: David Skoland Date: Tue, 24 Mar 2026 12:23:45 +0100 Subject: Add reconnect UI, disconnect button, and visual cleanup - Redesign disconnect overlay as a full-screen modal with dark backdrop - Add working Reconnect button that properly re-establishes WebSocket connection - Add Disconnect button in Settings for testing - Separate disconnect and ban/kick codepaths (no reconnect on ban) - Log disconnect notice in IC log using hrtext style - Refactor area list rendering from client state (renderAreaList) - Extract appendICNotice for reusable IC log notices - Clean up charselect: hide during loading, simplify toolbar layout - Freshen loading screen and charselect styling - Remove loading progress text updates (just show "Loading...") - Guard against undefined client.chars and client.serv Co-Authored-By: Claude Opus 4.6 (1M context) --- webAO/dom/reconnectButton.ts | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'webAO/dom/reconnectButton.ts') diff --git a/webAO/dom/reconnectButton.ts b/webAO/dom/reconnectButton.ts index 079e7fc..ae492fb 100644 --- a/webAO/dom/reconnectButton.ts +++ b/webAO/dom/reconnectButton.ts @@ -1,16 +1,26 @@ -import Client, { client, setClient } from "../client"; +import Client, { client, clientState, setClient } from "../client"; import queryParser from "../utils/queryParser"; -const { ip: serverIP } = queryParser(); +const { ip: serverIP, connect } = queryParser(); /** * Triggered when the reconnect button is pushed. */ export function ReconnectButton() { - client.cleanup(); - setClient(new Client(serverIP)); + document.getElementById("client_errortext")!.textContent = "Reconnecting..."; - if (client) { - document.getElementById("client_error")!.style.display = "none"; + // Build the connection string the same way the initial connection does + let connectionString = connect; + if (!connectionString && serverIP) { + connectionString = `ws://${serverIP}`; } + + const hdid = client.hdid; + client.state = clientState.Reconnecting; + client.cleanup(); + + const newClient = new Client(connectionString); + setClient(newClient); + newClient.hdid = hdid; + newClient.connect(); } window.ReconnectButton = ReconnectButton; -- cgit