1
0

ServerConnectWizard: don't set autoconnect on user cancel

Don't set the NETWORK_AUTO_CONNECT config if the user checked the custom
server config checkbox and then cancels the wizard, so the next time the
user starts the wizard they again will have the choice instead of
silently being forced into a random server.
Currently if the user cancels the wizard during the network config the
welcome component will already have set the NETWORK_AUTO_CONNECT config
to False (as the user selected the custom server checkbox), preventing
the wizard from starting again on the next startup.
This commit is contained in:
f321x
2026-01-26 13:33:48 +01:00
parent 10aecf66fd
commit 1c5408cccb
2 changed files with 9 additions and 7 deletions

View File

@@ -826,7 +826,7 @@ class ServerConnectWizard(AbstractWizard):
self.navmap = {
'welcome': {
'next': lambda d: 'proxy_config' if d['want_proxy'] else 'server_config',
'accept': self.do_configure_autoconnect,
'accept': lambda d: self.do_enable_autoconnect(d) if d['autoconnect'] else None,
'last': lambda d: bool(d['autoconnect'] and not d['want_proxy'])
},
'proxy_config': {
@@ -869,11 +869,13 @@ class ServerConnectWizard(AbstractWizard):
)
self._daemon.network.run_from_another_thread(self._daemon.network.set_parameters(net_params))
def do_configure_autoconnect(self, wizard_data: dict):
self._logger.debug(f'configuring autoconnect: {wizard_data!r}')
def do_enable_autoconnect(self, wizard_data: dict):
# NETWORK_AUTO_CONNECT will only get explicitly set True, 'autoconnect': False means
# the user requested manual server configuration
self._logger.debug(f'enabling autoconnect: {wizard_data!r}')
assert wizard_data.get('autoconnect'), wizard_data
if self._daemon.config.cv.NETWORK_AUTO_CONNECT.is_modifiable():
if wizard_data.get('autoconnect') is not None:
self._daemon.config.NETWORK_AUTO_CONNECT = wizard_data.get('autoconnect')
self._daemon.config.NETWORK_AUTO_CONNECT = True
def start(self, *, start_viewstate: WizardViewState = None) -> WizardViewState:
self.reset()

View File

@@ -81,7 +81,7 @@ class ServerConnectWizardTestCase(WizardTestCase):
self.assertFalse(w.is_last_view(v_init.view, d))
v = w.resolve_next(v_init.view, d)
self.assertEqual('server_config', v.view)
self.assertEqual(False, self.config.NETWORK_AUTO_CONNECT)
self.assertFalse(self.config.cv.NETWORK_AUTO_CONNECT.is_set())
async def test_proxy(self):
w = ServerConnectWizard(DaemonMock(self.config))
@@ -110,7 +110,7 @@ class ServerConnectWizardTestCase(WizardTestCase):
self.assertFalse(w.is_last_view(v_init.view, d))
v = w.resolve_next(v_init.view, d)
self.assertEqual('proxy_config', v.view)
self.assertEqual(False, self.config.NETWORK_AUTO_CONNECT)
self.assertFalse(self.config.cv.NETWORK_AUTO_CONNECT.is_set())
d_proxy = {'enabled': False}
d.update({'proxy': d_proxy})
v = w.resolve_next(v.view, d)