Bump version to 1.0.2+4, implement native state restoration, and clean up UI

This commit is contained in:
esefxdz committed 2026-06-04 19:00:19 +03:00
1 parent 61be397058
commit 208da38586
4 files changed
+34 -69

No files matched your search

+19
View File
@@ -43,6 +43,11 @@ class VpnConnection extends ChangeNotifier {
VpnStatus _status = VpnStatus.disconnected;
VpnStatus get status => _status;
// True only during the brief window after startup where we detected an
// already-running tunnel — lets SessionTimer know to auto-resume.
bool _isStartupRestoration = false;
bool get isStartupRestoration => _isStartupRestoration;
// Short message shown to the user under the connect button
String _statusMessage = 'Tap to connect';
String get statusMessage => _statusMessage;
@@ -84,6 +89,20 @@ class VpnConnection extends ChangeNotifier {
try {
_stageSub = _wireguard.vpnStageSnapshot.listen(_mapStage);
} catch (_) {}
// Check if the VPN was already running before the app started.
// This handles the case where the user swiped the app away and reopened it.
try {
final currentStage = await _wireguard.stage();
if (currentStage == VpnStage.connected) {
_isStartupRestoration = true;
_mapStage(currentStage);
// Clear the flag after a few seconds — only needed during app startup
Future.delayed(const Duration(seconds: 5), () {
_isStartupRestoration = false;
});
}
} catch (_) {}
}
// ── Native State Mapping ──────────────────────────────────────────────────