From 97294b4caa1d2ef2438a859dfc41b1d8f29ac65e Mon Sep 17 00:00:00 2001 From: kenny lopez Date: Mon, 3 Aug 2026 18:24:57 +0100 Subject: [PATCH] fix mobile status provider layering Signed-off-by: kenny lopez --- mobile/lib/app.dart | 2 +- .../lib/features/channels/channels_page.dart | 1 + .../channels_page/wide_navigation.dart | 18 ++++++++++++++++++ .../lib/features/channels/members_sheet.dart | 4 ++-- .../lib/features/profile/set_status_sheet.dart | 4 ++-- .../profile/settings_profile_header.dart | 2 +- .../features/profile/user_profile_sheet.dart | 2 +- .../profile => shared/relay}/user_status.dart | 2 +- .../relay}/user_status_cache_provider.dart | 2 +- .../relay}/user_status_provider.dart | 2 +- mobile/test/features/home/home_page_test.dart | 4 ++-- .../profile/set_status_sheet_test.dart | 4 ++-- .../profile/settings_profile_header_test.dart | 4 ++-- 13 files changed, 35 insertions(+), 16 deletions(-) rename mobile/lib/{features/profile => shared/relay}/user_status.dart (93%) rename mobile/lib/{features/profile => shared/relay}/user_status_cache_provider.dart (99%) rename mobile/lib/{features/profile => shared/relay}/user_status_provider.dart (98%) diff --git a/mobile/lib/app.dart b/mobile/lib/app.dart index 053821510..db96f1955 100644 --- a/mobile/lib/app.dart +++ b/mobile/lib/app.dart @@ -9,7 +9,7 @@ import 'features/home/home_page.dart'; import 'features/pairing/pairing_page.dart'; import 'features/channels/agent_activity/observer_subscription.dart'; import 'features/channels/deep_link_dispatcher.dart'; -import 'features/profile/user_status_cache_provider.dart'; +import 'shared/relay/user_status_cache_provider.dart'; import 'features/profile/settings_profile_header.dart'; import 'features/settings/settings_page.dart'; import 'shared/auth/auth.dart'; diff --git a/mobile/lib/features/channels/channels_page.dart b/mobile/lib/features/channels/channels_page.dart index 1a2a637d4..523081a86 100644 --- a/mobile/lib/features/channels/channels_page.dart +++ b/mobile/lib/features/channels/channels_page.dart @@ -13,6 +13,7 @@ import 'package:lucide_icons_flutter/lucide_icons.dart'; import '../../shared/auth/auth.dart'; import '../../shared/community/community_icon_provider.dart'; import '../../shared/relay/relay.dart'; +import '../../shared/relay/user_status_provider.dart'; import '../../shared/theme/theme.dart'; import '../../shared/widgets/avatar_image.dart'; import '../../shared/widgets/anchored_popover_menu.dart'; diff --git a/mobile/lib/features/channels/channels_page/wide_navigation.dart b/mobile/lib/features/channels/channels_page/wide_navigation.dart index a47f77fb0..5bef8ac82 100644 --- a/mobile/lib/features/channels/channels_page/wide_navigation.dart +++ b/mobile/lib/features/channels/channels_page/wide_navigation.dart @@ -608,10 +608,17 @@ class _WideNavigationProfile extends ConsumerWidget { Widget build(BuildContext context, WidgetRef ref) { final palette = _wideSidebarPalette(context); final profile = ref.watch(profileProvider).value; + final status = ref.watch(userStatusProvider).asData?.value; final displayName = profile?.displayName?.trim(); final name = displayName != null && displayName.isNotEmpty ? displayName : 'You'; + final statusEmoji = status?.emoji ?? ''; + final statusText = status?.text.trim() ?? ''; + final statusLabel = [ + if (statusEmoji.isNotEmpty) statusEmoji, + if (statusText.isNotEmpty) statusText, + ].join(' '); return SizedBox( key: const Key('wide-navigation-profile'), @@ -652,6 +659,17 @@ class _WideNavigationProfile extends ConsumerWidget { fontWeight: FontWeight.w600, ), ), + if (statusLabel.isNotEmpty) ...[ + const SizedBox(height: Grid.quarter), + Text( + statusLabel, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: context.textTheme.labelSmall?.copyWith( + color: palette.mutedForeground, + ), + ), + ], ], ), ), diff --git a/mobile/lib/features/channels/members_sheet.dart b/mobile/lib/features/channels/members_sheet.dart index e1c79164e..0ca08d717 100644 --- a/mobile/lib/features/channels/members_sheet.dart +++ b/mobile/lib/features/channels/members_sheet.dart @@ -3,13 +3,13 @@ import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:lucide_icons_flutter/lucide_icons.dart'; +import '../../shared/relay/user_status.dart'; +import '../../shared/relay/user_status_cache_provider.dart'; import '../../shared/theme/theme.dart'; import '../../shared/widgets/avatar_image.dart'; import '../../shared/widgets/buzz_loading_indicator.dart'; import '../profile/user_cache_provider.dart'; import '../profile/user_profile.dart'; -import '../profile/user_status.dart'; -import '../profile/user_status_cache_provider.dart'; import 'agent_activity/agent_activity_sheet.dart'; import 'agent_activity/working_bots_provider.dart'; import 'channel.dart'; diff --git a/mobile/lib/features/profile/set_status_sheet.dart b/mobile/lib/features/profile/set_status_sheet.dart index 2e03e4c11..caa0c443f 100644 --- a/mobile/lib/features/profile/set_status_sheet.dart +++ b/mobile/lib/features/profile/set_status_sheet.dart @@ -8,10 +8,10 @@ import 'package:lucide_icons_flutter/lucide_icons.dart'; import '../../shared/custom_emoji/custom_emoji.dart'; import '../../shared/custom_emoji/custom_emoji_provider.dart'; import '../../shared/custom_emoji/custom_emoji_render.dart'; +import '../../shared/relay/user_status.dart'; +import '../../shared/relay/user_status_provider.dart'; import '../../shared/theme/theme.dart'; import '../channels/emoji_picker.dart'; -import 'user_status.dart'; -import 'user_status_provider.dart'; /// The emoji well and the text field are sized to be the two things you reach /// for, so they carry no borders — the sheet has no other controls to compete diff --git a/mobile/lib/features/profile/settings_profile_header.dart b/mobile/lib/features/profile/settings_profile_header.dart index 23816ccaa..e72b4e410 100644 --- a/mobile/lib/features/profile/settings_profile_header.dart +++ b/mobile/lib/features/profile/settings_profile_header.dart @@ -4,12 +4,12 @@ import 'package:lucide_icons_flutter/lucide_icons.dart'; import '../../shared/custom_emoji/custom_emoji_provider.dart'; import '../../shared/custom_emoji/custom_emoji_render.dart'; +import '../../shared/relay/user_status_provider.dart'; import '../../shared/theme/theme.dart'; import '../../shared/widgets/avatar_image.dart'; import '../../shared/widgets/masked_avatar_badge.dart'; import 'profile_provider.dart'; import 'set_status_sheet.dart'; -import 'user_status_provider.dart'; /// Desktop's settings-avatar treatment (`ProfileSettingsCard`): a large centred /// avatar with a circular badge notched out of its bottom-right corner. Desktop diff --git a/mobile/lib/features/profile/user_profile_sheet.dart b/mobile/lib/features/profile/user_profile_sheet.dart index bce99dc84..a3f311b06 100644 --- a/mobile/lib/features/profile/user_profile_sheet.dart +++ b/mobile/lib/features/profile/user_profile_sheet.dart @@ -12,7 +12,7 @@ import '../channels/channel_detail_page.dart'; import '../channels/channel_management_provider.dart'; import 'presence_cache_provider.dart'; import 'user_cache_provider.dart'; -import 'user_status_cache_provider.dart'; +import '../../shared/relay/user_status_cache_provider.dart'; import '../channels/message_content.dart'; /// Show a user profile bottom sheet for the given [pubkey]. diff --git a/mobile/lib/features/profile/user_status.dart b/mobile/lib/shared/relay/user_status.dart similarity index 93% rename from mobile/lib/features/profile/user_status.dart rename to mobile/lib/shared/relay/user_status.dart index 8b28641d4..2a2d5793e 100644 --- a/mobile/lib/features/profile/user_status.dart +++ b/mobile/lib/shared/relay/user_status.dart @@ -1,6 +1,6 @@ import 'package:flutter/foundation.dart'; -import '../../shared/relay/nostr_models.dart'; +import 'nostr_models.dart'; /// A user's NIP-38 status (kind:30315, d=general). @immutable diff --git a/mobile/lib/features/profile/user_status_cache_provider.dart b/mobile/lib/shared/relay/user_status_cache_provider.dart similarity index 99% rename from mobile/lib/features/profile/user_status_cache_provider.dart rename to mobile/lib/shared/relay/user_status_cache_provider.dart index e8873b08e..498bf4f08 100644 --- a/mobile/lib/features/profile/user_status_cache_provider.dart +++ b/mobile/lib/shared/relay/user_status_cache_provider.dart @@ -3,7 +3,7 @@ import 'dart:async'; import 'package:flutter/foundation.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; -import '../../shared/relay/relay.dart'; +import 'relay.dart'; import 'user_status.dart'; /// In-memory cache of other users' NIP-38 statuses (kind:30315, d=general). diff --git a/mobile/lib/features/profile/user_status_provider.dart b/mobile/lib/shared/relay/user_status_provider.dart similarity index 98% rename from mobile/lib/features/profile/user_status_provider.dart rename to mobile/lib/shared/relay/user_status_provider.dart index bdeecfdce..cbf71129e 100644 --- a/mobile/lib/features/profile/user_status_provider.dart +++ b/mobile/lib/shared/relay/user_status_provider.dart @@ -1,7 +1,7 @@ import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:nostr/nostr.dart' as nostr; -import '../../shared/relay/relay.dart'; +import 'relay.dart'; import 'user_status.dart'; import 'user_status_cache_provider.dart'; diff --git a/mobile/test/features/home/home_page_test.dart b/mobile/test/features/home/home_page_test.dart index ad6fa66c7..ac813ad40 100644 --- a/mobile/test/features/home/home_page_test.dart +++ b/mobile/test/features/home/home_page_test.dart @@ -5,8 +5,8 @@ import 'package:buzz/features/channels/channel.dart'; import 'package:buzz/features/channels/channels_page.dart'; import 'package:buzz/features/channels/channels_provider.dart'; import 'package:buzz/features/profile/profile_avatar.dart'; -import 'package:buzz/features/profile/user_status.dart'; -import 'package:buzz/features/profile/user_status_provider.dart'; +import 'package:buzz/shared/relay/user_status.dart'; +import 'package:buzz/shared/relay/user_status_provider.dart'; import 'package:buzz/shared/community/community.dart'; import 'package:buzz/shared/community/community_provider.dart'; import 'package:buzz/shared/theme/theme.dart'; diff --git a/mobile/test/features/profile/set_status_sheet_test.dart b/mobile/test/features/profile/set_status_sheet_test.dart index 53563758d..41e0175e7 100644 --- a/mobile/test/features/profile/set_status_sheet_test.dart +++ b/mobile/test/features/profile/set_status_sheet_test.dart @@ -1,6 +1,6 @@ import 'package:buzz/features/profile/set_status_sheet.dart'; -import 'package:buzz/features/profile/user_status.dart'; -import 'package:buzz/features/profile/user_status_provider.dart'; +import 'package:buzz/shared/relay/user_status.dart'; +import 'package:buzz/shared/relay/user_status_provider.dart'; import 'package:buzz/shared/custom_emoji/custom_emoji_provider.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/mobile/test/features/profile/settings_profile_header_test.dart b/mobile/test/features/profile/settings_profile_header_test.dart index dbf27b5c8..c208734b9 100644 --- a/mobile/test/features/profile/settings_profile_header_test.dart +++ b/mobile/test/features/profile/settings_profile_header_test.dart @@ -1,8 +1,8 @@ import 'package:buzz/features/profile/profile_provider.dart'; import 'package:buzz/features/profile/settings_profile_header.dart'; import 'package:buzz/features/profile/user_profile.dart'; -import 'package:buzz/features/profile/user_status.dart'; -import 'package:buzz/features/profile/user_status_provider.dart'; +import 'package:buzz/shared/relay/user_status.dart'; +import 'package:buzz/shared/relay/user_status_provider.dart'; import 'package:buzz/shared/custom_emoji/custom_emoji_provider.dart'; import 'package:buzz/shared/widgets/masked_avatar_badge.dart'; import 'package:flutter_test/flutter_test.dart';