From 64a589bd7e33f51f92c8fa4a06f4107ebfdd1769 Mon Sep 17 00:00:00 2001 From: kenny lopez Date: Mon, 3 Aug 2026 14:23:37 +0100 Subject: [PATCH] keep stale channels hidden during relay switch Signed-off-by: kenny lopez --- mobile/lib/features/activity/activity_page.dart | 1 + mobile/lib/features/channels/channels_provider.dart | 5 +++-- mobile/lib/features/home/home_page/wide_navigation.dart | 1 + mobile/test/features/channels/channels_provider_test.dart | 2 ++ 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/mobile/lib/features/activity/activity_page.dart b/mobile/lib/features/activity/activity_page.dart index d60b97984..5a3a7bf04 100644 --- a/mobile/lib/features/activity/activity_page.dart +++ b/mobile/lib/features/activity/activity_page.dart @@ -442,6 +442,7 @@ class _WideActivityDetail extends HookWidget { final navigatorKey = useMemoized(GlobalKey.new, [item!.id]); return NavigatorPopHandler( + key: ValueKey('wide-activity-detail-${item!.id}'), onPopWithResult: (_) => navigatorKey.currentState?.maybePop(), child: Navigator( key: navigatorKey, diff --git a/mobile/lib/features/channels/channels_provider.dart b/mobile/lib/features/channels/channels_provider.dart index c0525a0b2..bc6144fb4 100644 --- a/mobile/lib/features/channels/channels_provider.dart +++ b/mobile/lib/features/channels/channels_provider.dart @@ -95,8 +95,9 @@ class ChannelsNotifier extends AsyncNotifier> { }); if (sessionState.status != SessionStatus.connected) { - // Keep the prior community's cache visible until the new relay connects. - if (_hasLoaded) return state.value ?? const []; + // Preserve the prior community's cache as previous AsyncValue data while + // the new relay connects, but remain loading so consumers cannot expose + // stale channels as interactive rows in the new community. await connected.future; } diff --git a/mobile/lib/features/home/home_page/wide_navigation.dart b/mobile/lib/features/home/home_page/wide_navigation.dart index 91b29a216..0c8e4027e 100644 --- a/mobile/lib/features/home/home_page/wide_navigation.dart +++ b/mobile/lib/features/home/home_page/wide_navigation.dart @@ -756,6 +756,7 @@ class _WideChannelContent extends HookWidget { channel.id, ]); return NavigatorPopHandler( + key: ValueKey('wide-channel-detail-${channel.id}'), onPopWithResult: (_) => navigatorKey.currentState?.maybePop(), child: Navigator( key: navigatorKey, diff --git a/mobile/test/features/channels/channels_provider_test.dart b/mobile/test/features/channels/channels_provider_test.dart index c128b9be5..8058c6813 100644 --- a/mobile/test/features/channels/channels_provider_test.dart +++ b/mobile/test/features/channels/channels_provider_test.dart @@ -457,11 +457,13 @@ void main() { .read(relayConfigProvider.notifier) .update(baseUrl: 'https://new-community.example'); await Future.delayed(Duration.zero); + expect(container.read(channelsProvider).isLoading, isTrue); expect(container.read(channelsProvider).value?.single.name, 'general'); session.setStatus(SessionStatus.connected); await Future.delayed(Duration.zero); + expect(container.read(channelsProvider).isLoading, isFalse); expect(container.read(channelsProvider).value?.single.name, 'random'); }, );