From 9d2ff53f21c73b285e32ba949268ee08523b93f9 Mon Sep 17 00:00:00 2001 From: Suman Biswas Date: Sat, 7 Nov 2026 20:07:24 +0530 Subject: [PATCH] fix(mob): keep HTTPS on while typing a port that starts with 80 The switch turned off as soon as the port field read "80", so typing 8000 or 8080 left HTTPS disabled. Until the user flips the switch, it now follows the whole port (off only for exactly 80); after that the user's choice is kept. Closes #170 --- mobile/lib/pages/settings/server_settings.dart | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/mobile/lib/pages/settings/server_settings.dart b/mobile/lib/pages/settings/server_settings.dart index c52656b..752a5e5 100644 --- a/mobile/lib/pages/settings/server_settings.dart +++ b/mobile/lib/pages/settings/server_settings.dart @@ -34,6 +34,9 @@ class _ServerSettingsFormState extends State<_ServerSettingsForm> { text: Env.port, ); late bool _tls = Env.useTls; + + /// Set once the user flips the switch; until then it follows the port. + bool _tlsChosen = false; _Health _health = _Health.unknown; @override @@ -43,12 +46,11 @@ class _ServerSettingsFormState extends State<_ServerSettingsForm> { super.dispose(); } - /// Port 80 almost always means no TLS and 443 always means TLS, so - /// follow the port when it's one of those; otherwise keep the choice. + /// Port 80 almost always means no TLS, so follow the port until the user + /// chooses. Uses the whole port, so typing 8080 doesn't stop at "80". void _onPortChanged(String port) { setState(() { - if (port == '80') _tls = false; - if (port == '443') _tls = true; + if (!_tlsChosen) _tls = port != '80'; _health = _Health.unknown; }); } @@ -151,6 +153,7 @@ class _ServerSettingsFormState extends State<_ServerSettingsForm> { value: _tls, onChanged: (value) => setState(() { _tls = value; + _tlsChosen = true; _health = _Health.unknown; }), title: const Text('Use HTTPS/WSS'),