refactor(app): remove unsupported runtime and UI state

This commit is contained in:
Naveax committed 2026-09-03 22:44:25 +03:00
1 parent 9ac236a981
commit 0ed7bf27b5
19 files changed
+173 -381

No files matched your search

+15 -6
View File
@@ -18,23 +18,32 @@ abstract final class ConnectionSettings {
final prefs = await SharedPreferences.getInstance();
final storedMode = prefs.getString(_modeKey);
// Any unrecognized value (including the pre-V3 'auto') is TUN. 'proxy' is
// the only persisted value that selects the SOCKS5 mode.
// Only the explicit current proxy value restores SOCKS5. Unknown and
// obsolete values, including the former 'auto'/'ass' labels, fail closed
// to full-tunnel TUN instead of silently selecting a weaker route.
_mode = storedMode == ConnectionMode.proxy.name
? ConnectionMode.proxy
: ConnectionMode.tun;
if (storedMode != _mode.name) {
await prefs.setString(_modeKey, _mode.name);
final migrated = await prefs.setString(_modeKey, _mode.name);
if (!migrated) {
throw StateError('Could not persist migrated connection mode.');
}
}
_initialized = true;
}
static Future<void> setMode(ConnectionMode mode) async {
static Future<bool> setMode(ConnectionMode mode) async {
if (_initialized && _mode == mode) return true;
final prefs = await SharedPreferences.getInstance();
final saved = await prefs.setString(_modeKey, mode.name);
if (!saved) return false;
_mode = mode;
_initialized = true;
final prefs = await SharedPreferences.getInstance();
await prefs.setString(_modeKey, mode.name);
return true;
}
}