From 4d9f1546e2405cf07f52a6603e51ee4587a7f124 Mon Sep 17 00:00:00 2001 From: diffwireauto <330573775+diffwireauto@users.noreply.github.com> Date: Wed, 21 Oct 2026 05:10:58 -0400 Subject: [PATCH] epic(#938): Blocked pane says "no radio" instead of "no blocked users" Epic C of Feature #853, carrying #507. Much smaller than the plan assumed, because `BlockedView` already existed and was already wired into Settings. What it did not have was the distinction #507 asked for, or any tests. **The gap.** With no radio connected the pane rendered "No blocked users", which is indistinguishable from a connected radio with an empty list. Since #471 made blocks per radio, that wording invited exactly the wrong conclusion: that the blocks had been lost. Now a disconnected pane says "No radio connected" and explains why ("Blocks belong to the radio that holds them"), because the reason is what stops it reading as data loss. English-only string additions per the repo convention; `untranslated.json` tracks the other 17 locales. **Tests: 5, and the first one has teeth.** I proved it by disabling the new branch and watching it fail: Expected: exactly one matching candidate Actual: Found 0 widgets with text "No radio connected" Then reverted. A test nobody has watched fail is not evidence, and this session has already produced three harnesses that reported success while measuring nothing. Covered, all through the widget rather than the service: - no radio says so, and gives the reason - a connected radio with nothing blocked says THAT - a block made on radio A is absent on radio B - switching back restores A's list, because isolation is not deletion - an unblock survives a switch and back, which is #507's clear-sticks case and the re-clear that #471 was about #507 also lists "migration drops the global keys". That already exists: `BlockService.loadForDevice` calls `_store.dropLegacyGlobal()` on every device load. Noted rather than re-implemented. Suite 1,419 pass, analyze clean, format clean. Still outstanding for this Epic: the T1000e hardware check #507 asks for, which is an owner step and the only part I cannot do. Citadel: meshcore-open-uu9, meshcore-open-9ft Refs #938, #507, #471, #853 Co-Authored-By: Claude Opus 5 --- lib/l10n/app_en.arb | 2 + lib/l10n/app_localizations.dart | 12 ++ lib/l10n/app_localizations_bg.dart | 7 ++ lib/l10n/app_localizations_de.dart | 7 ++ lib/l10n/app_localizations_en.dart | 7 ++ lib/l10n/app_localizations_es.dart | 7 ++ lib/l10n/app_localizations_fr.dart | 7 ++ lib/l10n/app_localizations_hu.dart | 7 ++ lib/l10n/app_localizations_it.dart | 7 ++ lib/l10n/app_localizations_ja.dart | 7 ++ lib/l10n/app_localizations_ko.dart | 7 ++ lib/l10n/app_localizations_nl.dart | 7 ++ lib/l10n/app_localizations_pl.dart | 7 ++ lib/l10n/app_localizations_pt.dart | 7 ++ lib/l10n/app_localizations_ru.dart | 7 ++ lib/l10n/app_localizations_sk.dart | 7 ++ lib/l10n/app_localizations_sl.dart | 7 ++ lib/l10n/app_localizations_sv.dart | 7 ++ lib/l10n/app_localizations_uk.dart | 7 ++ lib/l10n/app_localizations_zh.dart | 7 ++ lib/screens/settings/blocked_view.dart | 36 ++++++ test/screens/blocked_view_test.dart | 149 +++++++++++++++++++++++++ 22 files changed, 325 insertions(+) create mode 100644 test/screens/blocked_view_test.dart diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index e119aa5c..63e896cb 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -2904,6 +2904,8 @@ "block_settingsTitle": "Blocked", "block_settingsSubtitle": "Users you've blocked", "block_none": "No blocked users", + "block_noRadio": "No radio connected", + "block_noRadioHint": "Blocks belong to the radio that holds them. Connect a radio to see and change its blocked list.", "block_keysSection": "Blocked contacts", "block_namesSection": "Blocked names", "block_namesHint": "Name-only blocks (channel senders). Each upgrades to a full block once we learn their key.", diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dart index dd183131..687451e3 100644 --- a/lib/l10n/app_localizations.dart +++ b/lib/l10n/app_localizations.dart @@ -8596,6 +8596,18 @@ abstract class AppLocalizations { /// **'No blocked users'** String get block_none; + /// No description provided for @block_noRadio. + /// + /// In en, this message translates to: + /// **'No radio connected'** + String get block_noRadio; + + /// No description provided for @block_noRadioHint. + /// + /// In en, this message translates to: + /// **'Blocks belong to the radio that holds them. Connect a radio to see and change its blocked list.'** + String get block_noRadioHint; + /// No description provided for @block_keysSection. /// /// In en, this message translates to: diff --git a/lib/l10n/app_localizations_bg.dart b/lib/l10n/app_localizations_bg.dart index 687ebe6d..756d6fad 100644 --- a/lib/l10n/app_localizations_bg.dart +++ b/lib/l10n/app_localizations_bg.dart @@ -5064,6 +5064,13 @@ class AppLocalizationsBg extends AppLocalizations { @override String get block_none => 'No blocked users'; + @override + String get block_noRadio => 'No radio connected'; + + @override + String get block_noRadioHint => + 'Blocks belong to the radio that holds them. Connect a radio to see and change its blocked list.'; + @override String get block_keysSection => 'Blocked contacts'; diff --git a/lib/l10n/app_localizations_de.dart b/lib/l10n/app_localizations_de.dart index fabdbff9..5a7b6e50 100644 --- a/lib/l10n/app_localizations_de.dart +++ b/lib/l10n/app_localizations_de.dart @@ -5081,6 +5081,13 @@ class AppLocalizationsDe extends AppLocalizations { @override String get block_none => 'No blocked users'; + @override + String get block_noRadio => 'No radio connected'; + + @override + String get block_noRadioHint => + 'Blocks belong to the radio that holds them. Connect a radio to see and change its blocked list.'; + @override String get block_keysSection => 'Blocked contacts'; diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dart index 5a2d33dd..ed3d5d5b 100644 --- a/lib/l10n/app_localizations_en.dart +++ b/lib/l10n/app_localizations_en.dart @@ -4987,6 +4987,13 @@ class AppLocalizationsEn extends AppLocalizations { @override String get block_none => 'No blocked users'; + @override + String get block_noRadio => 'No radio connected'; + + @override + String get block_noRadioHint => + 'Blocks belong to the radio that holds them. Connect a radio to see and change its blocked list.'; + @override String get block_keysSection => 'Blocked contacts'; diff --git a/lib/l10n/app_localizations_es.dart b/lib/l10n/app_localizations_es.dart index adc7e6c6..c4afa3e5 100644 --- a/lib/l10n/app_localizations_es.dart +++ b/lib/l10n/app_localizations_es.dart @@ -5069,6 +5069,13 @@ class AppLocalizationsEs extends AppLocalizations { @override String get block_none => 'No blocked users'; + @override + String get block_noRadio => 'No radio connected'; + + @override + String get block_noRadioHint => + 'Blocks belong to the radio that holds them. Connect a radio to see and change its blocked list.'; + @override String get block_keysSection => 'Blocked contacts'; diff --git a/lib/l10n/app_localizations_fr.dart b/lib/l10n/app_localizations_fr.dart index 0f34df5d..6b54ae04 100644 --- a/lib/l10n/app_localizations_fr.dart +++ b/lib/l10n/app_localizations_fr.dart @@ -5097,6 +5097,13 @@ class AppLocalizationsFr extends AppLocalizations { @override String get block_none => 'No blocked users'; + @override + String get block_noRadio => 'No radio connected'; + + @override + String get block_noRadioHint => + 'Blocks belong to the radio that holds them. Connect a radio to see and change its blocked list.'; + @override String get block_keysSection => 'Blocked contacts'; diff --git a/lib/l10n/app_localizations_hu.dart b/lib/l10n/app_localizations_hu.dart index c4981180..a65b1356 100644 --- a/lib/l10n/app_localizations_hu.dart +++ b/lib/l10n/app_localizations_hu.dart @@ -5086,6 +5086,13 @@ class AppLocalizationsHu extends AppLocalizations { @override String get block_none => 'No blocked users'; + @override + String get block_noRadio => 'No radio connected'; + + @override + String get block_noRadioHint => + 'Blocks belong to the radio that holds them. Connect a radio to see and change its blocked list.'; + @override String get block_keysSection => 'Blocked contacts'; diff --git a/lib/l10n/app_localizations_it.dart b/lib/l10n/app_localizations_it.dart index 91f690f1..68693e6a 100644 --- a/lib/l10n/app_localizations_it.dart +++ b/lib/l10n/app_localizations_it.dart @@ -5074,6 +5074,13 @@ class AppLocalizationsIt extends AppLocalizations { @override String get block_none => 'No blocked users'; + @override + String get block_noRadio => 'No radio connected'; + + @override + String get block_noRadioHint => + 'Blocks belong to the radio that holds them. Connect a radio to see and change its blocked list.'; + @override String get block_keysSection => 'Blocked contacts'; diff --git a/lib/l10n/app_localizations_ja.dart b/lib/l10n/app_localizations_ja.dart index 16b1c3e6..b962df0d 100644 --- a/lib/l10n/app_localizations_ja.dart +++ b/lib/l10n/app_localizations_ja.dart @@ -4840,6 +4840,13 @@ class AppLocalizationsJa extends AppLocalizations { @override String get block_none => 'No blocked users'; + @override + String get block_noRadio => 'No radio connected'; + + @override + String get block_noRadioHint => + 'Blocks belong to the radio that holds them. Connect a radio to see and change its blocked list.'; + @override String get block_keysSection => 'Blocked contacts'; diff --git a/lib/l10n/app_localizations_ko.dart b/lib/l10n/app_localizations_ko.dart index 31e28443..3784b076 100644 --- a/lib/l10n/app_localizations_ko.dart +++ b/lib/l10n/app_localizations_ko.dart @@ -4841,6 +4841,13 @@ class AppLocalizationsKo extends AppLocalizations { @override String get block_none => 'No blocked users'; + @override + String get block_noRadio => 'No radio connected'; + + @override + String get block_noRadioHint => + 'Blocks belong to the radio that holds them. Connect a radio to see and change its blocked list.'; + @override String get block_keysSection => 'Blocked contacts'; diff --git a/lib/l10n/app_localizations_nl.dart b/lib/l10n/app_localizations_nl.dart index e7b7615d..95f297c7 100644 --- a/lib/l10n/app_localizations_nl.dart +++ b/lib/l10n/app_localizations_nl.dart @@ -5049,6 +5049,13 @@ class AppLocalizationsNl extends AppLocalizations { @override String get block_none => 'No blocked users'; + @override + String get block_noRadio => 'No radio connected'; + + @override + String get block_noRadioHint => + 'Blocks belong to the radio that holds them. Connect a radio to see and change its blocked list.'; + @override String get block_keysSection => 'Blocked contacts'; diff --git a/lib/l10n/app_localizations_pl.dart b/lib/l10n/app_localizations_pl.dart index 8f7f934b..ed78bfb6 100644 --- a/lib/l10n/app_localizations_pl.dart +++ b/lib/l10n/app_localizations_pl.dart @@ -5086,6 +5086,13 @@ class AppLocalizationsPl extends AppLocalizations { @override String get block_none => 'No blocked users'; + @override + String get block_noRadio => 'No radio connected'; + + @override + String get block_noRadioHint => + 'Blocks belong to the radio that holds them. Connect a radio to see and change its blocked list.'; + @override String get block_keysSection => 'Blocked contacts'; diff --git a/lib/l10n/app_localizations_pt.dart b/lib/l10n/app_localizations_pt.dart index 25dc5f45..83faa2b7 100644 --- a/lib/l10n/app_localizations_pt.dart +++ b/lib/l10n/app_localizations_pt.dart @@ -5062,6 +5062,13 @@ class AppLocalizationsPt extends AppLocalizations { @override String get block_none => 'No blocked users'; + @override + String get block_noRadio => 'No radio connected'; + + @override + String get block_noRadioHint => + 'Blocks belong to the radio that holds them. Connect a radio to see and change its blocked list.'; + @override String get block_keysSection => 'Blocked contacts'; diff --git a/lib/l10n/app_localizations_ru.dart b/lib/l10n/app_localizations_ru.dart index 5cb0d203..f85d1072 100644 --- a/lib/l10n/app_localizations_ru.dart +++ b/lib/l10n/app_localizations_ru.dart @@ -5080,6 +5080,13 @@ class AppLocalizationsRu extends AppLocalizations { @override String get block_none => 'No blocked users'; + @override + String get block_noRadio => 'No radio connected'; + + @override + String get block_noRadioHint => + 'Blocks belong to the radio that holds them. Connect a radio to see and change its blocked list.'; + @override String get block_keysSection => 'Blocked contacts'; diff --git a/lib/l10n/app_localizations_sk.dart b/lib/l10n/app_localizations_sk.dart index e9b0ac5d..b7b7a602 100644 --- a/lib/l10n/app_localizations_sk.dart +++ b/lib/l10n/app_localizations_sk.dart @@ -5046,6 +5046,13 @@ class AppLocalizationsSk extends AppLocalizations { @override String get block_none => 'No blocked users'; + @override + String get block_noRadio => 'No radio connected'; + + @override + String get block_noRadioHint => + 'Blocks belong to the radio that holds them. Connect a radio to see and change its blocked list.'; + @override String get block_keysSection => 'Blocked contacts'; diff --git a/lib/l10n/app_localizations_sl.dart b/lib/l10n/app_localizations_sl.dart index f2de9f0c..757f3134 100644 --- a/lib/l10n/app_localizations_sl.dart +++ b/lib/l10n/app_localizations_sl.dart @@ -5044,6 +5044,13 @@ class AppLocalizationsSl extends AppLocalizations { @override String get block_none => 'No blocked users'; + @override + String get block_noRadio => 'No radio connected'; + + @override + String get block_noRadioHint => + 'Blocks belong to the radio that holds them. Connect a radio to see and change its blocked list.'; + @override String get block_keysSection => 'Blocked contacts'; diff --git a/lib/l10n/app_localizations_sv.dart b/lib/l10n/app_localizations_sv.dart index 7b28618f..27115785 100644 --- a/lib/l10n/app_localizations_sv.dart +++ b/lib/l10n/app_localizations_sv.dart @@ -5019,6 +5019,13 @@ class AppLocalizationsSv extends AppLocalizations { @override String get block_none => 'No blocked users'; + @override + String get block_noRadio => 'No radio connected'; + + @override + String get block_noRadioHint => + 'Blocks belong to the radio that holds them. Connect a radio to see and change its blocked list.'; + @override String get block_keysSection => 'Blocked contacts'; diff --git a/lib/l10n/app_localizations_uk.dart b/lib/l10n/app_localizations_uk.dart index 93c41451..2b9611db 100644 --- a/lib/l10n/app_localizations_uk.dart +++ b/lib/l10n/app_localizations_uk.dart @@ -5081,6 +5081,13 @@ class AppLocalizationsUk extends AppLocalizations { @override String get block_none => 'No blocked users'; + @override + String get block_noRadio => 'No radio connected'; + + @override + String get block_noRadioHint => + 'Blocks belong to the radio that holds them. Connect a radio to see and change its blocked list.'; + @override String get block_keysSection => 'Blocked contacts'; diff --git a/lib/l10n/app_localizations_zh.dart b/lib/l10n/app_localizations_zh.dart index 857226e1..7bb28f30 100644 --- a/lib/l10n/app_localizations_zh.dart +++ b/lib/l10n/app_localizations_zh.dart @@ -4714,6 +4714,13 @@ class AppLocalizationsZh extends AppLocalizations { @override String get block_none => 'No blocked users'; + @override + String get block_noRadio => 'No radio connected'; + + @override + String get block_noRadioHint => + 'Blocks belong to the radio that holds them. Connect a radio to see and change its blocked list.'; + @override String get block_keysSection => 'Blocked contacts'; diff --git a/lib/screens/settings/blocked_view.dart b/lib/screens/settings/blocked_view.dart index 438e2120..1005264f 100644 --- a/lib/screens/settings/blocked_view.dart +++ b/lib/screens/settings/blocked_view.dart @@ -17,6 +17,42 @@ class BlockedView extends StatelessWidget { Widget build(BuildContext context) { return Consumer2( builder: (context, block, connector, child) { + // No radio connected is NOT the same as nothing blocked, and before + // #507 both rendered as "No blocked users". Blocks are per radio + // (#471), so with none connected there is no list to show rather than + // an empty one, and saying "no blocked users" invited the reader to + // conclude their blocks had been lost. + if (block.selfKeyHex == null) { + return ListView( + padding: const EdgeInsets.all(16), + children: [ + Padding( + padding: const EdgeInsets.symmetric(vertical: 48), + child: Column( + children: [ + Icon( + Icons.radio_button_unchecked, + size: 40, + color: Colors.grey[500], + ), + const SizedBox(height: 12), + Text(context.l10n.block_noRadio), + const SizedBox(height: 8), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 24), + child: Text( + context.l10n.block_noRadioHint, + textAlign: TextAlign.center, + style: TextStyle(fontSize: 12, color: Colors.grey[600]), + ), + ), + ], + ), + ), + ], + ); + } + final keys = block.blockedKeys.toList()..sort(); final names = block.blockedNames.keys.toList()..sort(); final indicator = _offloadIndicator(context, connector); diff --git a/test/screens/blocked_view_test.dart b/test/screens/blocked_view_test.dart new file mode 100644 index 00000000..0f535319 --- /dev/null +++ b/test/screens/blocked_view_test.dart @@ -0,0 +1,149 @@ +import 'package:drift/native.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_localizations/flutter_localizations.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:meshcore_open/connector/meshcore_connector.dart'; +import 'package:meshcore_open/l10n/app_localizations.dart'; +import 'package:meshcore_open/screens/settings/blocked_view.dart'; +import 'package:meshcore_open/services/block_service.dart'; +import 'package:meshcore_open/storage/drift/blob_store.dart'; +import 'package:meshcore_open/storage/drift/offband_database.dart'; +import 'package:meshcore_open/storage/prefs_manager.dart'; +import 'package:provider/provider.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +/// #938 (#507): the Blocked pane is per radio, and says so. +/// +/// The gap this closes: with no radio connected the pane rendered "No blocked +/// users", which is indistinguishable from a connected radio with an empty +/// list. Since #471 made blocks per radio, that wording invited the reader to +/// conclude their blocks had been lost. +void main() { + late OffbandDatabase db; + + setUp(() async { + SharedPreferences.setMockInitialValues({}); + PrefsManager.reset(); + await PrefsManager.initialize(); + db = OffbandDatabase(NativeDatabase.memory()); + BlobStore.overrideForTest(BlobStore(db)); + }); + + tearDown(() async { + await db.close(); + BlobStore.clearTestOverride(); + }); + + Widget harness(BlockService block) => MultiProvider( + providers: [ + ChangeNotifierProvider.value(value: block), + ChangeNotifierProvider( + create: (_) => MeshCoreConnector(), + ), + ], + child: const MaterialApp( + localizationsDelegates: [ + AppLocalizations.delegate, + GlobalMaterialLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + ], + home: Scaffold(body: BlockedView()), + ), + ); + + group('the two empty states read differently', () { + testWidgets('no radio connected says so, and explains why', (t) async { + final block = BlockService(); + await block.loadForDevice(null); + + await t.pumpWidget(harness(block)); + await t.pumpAndSettle(); + + expect(find.text('No radio connected'), findsOneWidget); + expect( + find.textContaining('Blocks belong to the radio that holds them'), + findsOneWidget, + reason: 'the reason matters: without it the pane looks like data loss', + ); + expect( + find.text('No blocked users'), + findsNothing, + reason: 'this was the bug: both states said the same thing', + ); + }); + + testWidgets('a connected radio with nothing blocked says THAT', (t) async { + final block = BlockService(); + await block.loadForDevice('aa' * 16); + + await t.pumpWidget(harness(block)); + await t.pumpAndSettle(); + + expect(find.text('No blocked users'), findsOneWidget); + expect(find.text('No radio connected'), findsNothing); + }); + }); + + group('per-radio isolation through the pane', () { + testWidgets('a block made on radio A is absent on radio B', (t) async { + final block = BlockService(); + await block.loadForDevice('aa' * 16); + await block.block('deadbeef'); + + await t.pumpWidget(harness(block)); + await t.pumpAndSettle(); + expect(find.textContaining('deadbeef'), findsOneWidget); + + // Switch radios, as the connector does on SELF_INFO. + await block.loadForDevice('bb' * 16); + await t.pumpAndSettle(); + + expect( + find.textContaining('deadbeef'), + findsNothing, + reason: 'radio A\'s block must not appear while radio B is connected', + ); + expect(find.text('No blocked users'), findsOneWidget); + }); + + testWidgets('switching back restores radio A\'s list', (t) async { + final block = BlockService(); + await block.loadForDevice('aa' * 16); + await block.block('deadbeef'); + await block.loadForDevice('bb' * 16); + await block.loadForDevice('aa' * 16); + + await t.pumpWidget(harness(block)); + await t.pumpAndSettle(); + + expect( + find.textContaining('deadbeef'), + findsOneWidget, + reason: 'isolation is not deletion: A keeps its own list', + ); + }); + }); + + group('unblock sticks', () { + testWidgets('an unblock survives a radio switch and back', (t) async { + final block = BlockService(); + await block.loadForDevice('aa' * 16); + await block.block('deadbeef'); + await block.unblock('deadbeef'); + + await block.loadForDevice('bb' * 16); + await block.loadForDevice('aa' * 16); + + await t.pumpWidget(harness(block)); + await t.pumpAndSettle(); + + expect( + find.textContaining('deadbeef'), + findsNothing, + reason: + 'the clear-sticks case from #507: the re-clear that kept ' + 'recurring was #471, and it must not come back', + ); + }); + }); +}