mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
keep stale channels hidden during relay switch
Signed-off-by: kenny lopez <klopez4212@gmail.com>
This commit is contained in:
@@ -442,6 +442,7 @@ class _WideActivityDetail extends HookWidget {
|
||||
|
||||
final navigatorKey = useMemoized(GlobalKey<NavigatorState>.new, [item!.id]);
|
||||
return NavigatorPopHandler(
|
||||
key: ValueKey('wide-activity-detail-${item!.id}'),
|
||||
onPopWithResult: (_) => navigatorKey.currentState?.maybePop(),
|
||||
child: Navigator(
|
||||
key: navigatorKey,
|
||||
|
||||
@@ -95,8 +95,9 @@ class ChannelsNotifier extends AsyncNotifier<List<Channel>> {
|
||||
});
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -457,11 +457,13 @@ void main() {
|
||||
.read(relayConfigProvider.notifier)
|
||||
.update(baseUrl: 'https://new-community.example');
|
||||
await Future<void>.delayed(Duration.zero);
|
||||
expect(container.read(channelsProvider).isLoading, isTrue);
|
||||
expect(container.read(channelsProvider).value?.single.name, 'general');
|
||||
|
||||
session.setStatus(SessionStatus.connected);
|
||||
await Future<void>.delayed(Duration.zero);
|
||||
|
||||
expect(container.read(channelsProvider).isLoading, isFalse);
|
||||
expect(container.read(channelsProvider).value?.single.name, 'random');
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user