From 6da601b5654dc340599dd1680b7135b7d1276187 Mon Sep 17 00:00:00 2001 From: Naveax Date: Sun, 6 Sep 2026 11:18:24 +0300 Subject: [PATCH] fix(app): persist disclosure acknowledgement after acceptance (#5) Write the disclosure preference only after explicit confirmation so failed persistence does not create a false accepted state. --- lib/components/data_disclosure_dialog.dart | 32 +++++++++++----------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/components/data_disclosure_dialog.dart b/lib/components/data_disclosure_dialog.dart index 85d8132..95a59b5 100644 --- a/lib/components/data_disclosure_dialog.dart +++ b/lib/components/data_disclosure_dialog.dart @@ -19,23 +19,28 @@ class DataDisclosureDialog { if (!context.mounted) return; - await showDialog( + final accepted = await showDialog( context: context, barrierDismissible: false, // Must tap Continue — no tap-outside dismiss. - builder: (_) => _DisclosureDialog( - onContinue: () { - prefs.setBool(_key, true); - Navigator.of(context).pop(); // Dismiss the dialog. - }, - ), + builder: (_) => const _DisclosureDialog(), ); + if (accepted != true) return; + + // Persist only after the user action is complete. If storage fails, do not + // invent an accepted state; the disclosure will simply reappear later. + try { + final saved = await prefs.setBool(_key, true); + if (!saved) { + debugPrint('[Disclosure] Preference write was rejected'); + } + } catch (e) { + debugPrint('[Disclosure] Failed to persist acknowledgement: $e'); + } } } class _DisclosureDialog extends StatelessWidget { - final VoidCallback onContinue; - - const _DisclosureDialog({required this.onContinue}); + const _DisclosureDialog(); @override Widget build(BuildContext context) { @@ -49,7 +54,6 @@ class _DisclosureDialog extends StatelessWidget { mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ - // Title const Text( 'Before you connect', style: TextStyle( @@ -59,8 +63,6 @@ class _DisclosureDialog extends StatelessWidget { ), ), const SizedBox(height: 16), - - // Body const Text( 'Revolt VPN creates a secure VPN tunnel to protect your ' 'traffic. To enforce your data/time quota, we log your ' @@ -76,12 +78,10 @@ class _DisclosureDialog extends StatelessWidget { ), ), const SizedBox(height: 24), - - // Continue button — full-width, accent SizedBox( width: double.infinity, child: ElevatedButton( - onPressed: onContinue, + onPressed: () => Navigator.of(context).pop(true), style: ElevatedButton.styleFrom( backgroundColor: AppColors.accent, foregroundColor: AppColors.bgDeep,