diff --git a/lib/screens/settings_screen.dart b/lib/screens/settings_screen.dart index 4e73b9c..e48e420 100644 --- a/lib/screens/settings_screen.dart +++ b/lib/screens/settings_screen.dart @@ -429,6 +429,7 @@ class _SettingsScreenState extends State { Future _editFastLocationChannel() async { final channels = List.from(context.read().channels) + ..removeWhere((c) => c.isPublicChannel) ..sort((a, b) { final aIdx = a.publicKey.length > 1 ? a.publicKey[1] : 0; final bIdx = b.publicKey.length > 1 ? b.publicKey[1] : 0; diff --git a/lib/widgets/contacts/contact_tile.dart b/lib/widgets/contacts/contact_tile.dart index 4e239c5..13884cb 100644 --- a/lib/widgets/contacts/contact_tile.dart +++ b/lib/widgets/contacts/contact_tile.dart @@ -157,6 +157,7 @@ class ContactTile extends StatelessWidget { icon: Icons.folder_copy_outlined, label: label, ), + ..._buildSignalPills(context), ], ), if (location != null) ...[ @@ -324,6 +325,34 @@ class ContactTile extends StatelessWidget { ); } + List _buildSignalPills(BuildContext context) { + if (!contact.isRepeater && !contact.isSensor) return []; + final contactsProvider = context.read(); + final advert = contactsProvider.pendingAdvertByKey(contact.publicKey); + if (advert == null) return []; + + final pills = []; + if (advert.rxRssiDbm != null) { + pills.add( + _buildMetaPill( + context, + icon: Icons.arrow_downward_rounded, + label: '${advert.rxRssiDbm} dBm', + ), + ); + } + if (advert.repeaterLastRssi != null) { + pills.add( + _buildMetaPill( + context, + icon: Icons.arrow_upward_rounded, + label: '${advert.repeaterLastRssi} dBm', + ), + ); + } + return pills; + } + Widget _buildCompactSubtitle(BuildContext context, String? distanceText) { final location = contact.displayLocation; final compactPills = [ @@ -338,6 +367,7 @@ class ContactTile extends StatelessWidget { icon: Icons.location_disabled_outlined, label: AppLocalizations.of(context)!.noGpsData, ), + ..._buildSignalPills(context), ]; return Padding( diff --git a/test/widgets/recipient_selector_sheet_test.dart b/test/widgets/recipient_selector_sheet_test.dart index 817ef1c..b5bc193 100644 --- a/test/widgets/recipient_selector_sheet_test.dart +++ b/test/widgets/recipient_selector_sheet_test.dart @@ -204,4 +204,43 @@ void main() { expect(find.textContaining('Channel 3'), findsNothing); expect(find.text(channel.publicKeyShort.toUpperCase()), findsNothing); }); + + testWidgets('shows contact activity instead of the public key', ( + tester, + ) async { + final contact = buildContact( + name: 'John Smith', + type: ContactType.chat, + secondByte: 4, + ); + final messagesProvider = MessagesProvider() + ..addMessage( + Message( + id: 'contact-activity', + messageType: MessageType.contact, + recipientPublicKey: contact.publicKey, + pathLen: 1, + textType: MessageTextType.plain, + senderTimestamp: + DateTime.now() + .subtract(const Duration(hours: 2)) + .millisecondsSinceEpoch ~/ + 1000, + text: 'check-in', + receivedAt: DateTime.now().subtract(const Duration(hours: 2)), + ), + ); + + await pumpSheet( + tester, + contacts: [contact], + channels: const [], + messagesProvider: messagesProvider, + showAllOption: false, + ); + + expect(find.text('John Smith'), findsOneWidget); + expect(find.text('2h ago'), findsOneWidget); + expect(find.text(contact.publicKeyShort), findsNothing); + }); }