mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-08-02 09:08:35 +02:00
fix(home): keep search visible during provider changes
This commit is contained in:
@@ -137,6 +137,24 @@ class HomeSearchProviderPolicy {
|
||||
return resolveProvider(explicitSearchProvider, extensions) != null;
|
||||
}
|
||||
|
||||
/// Keeps the Home search surface stable while extension/provider state is
|
||||
/// being reconciled. A transient missing search capability must not remove
|
||||
/// the field above an already-visible Home feed; changing providers should
|
||||
/// never be required just to make Search reappear.
|
||||
static bool shouldShowSearchBar({
|
||||
required bool hasSearchProvider,
|
||||
required bool isSearchProviderLoading,
|
||||
required bool hasHomeFeedExtension,
|
||||
required bool hasExploreContent,
|
||||
required bool hasSearchInput,
|
||||
}) {
|
||||
return hasSearchProvider ||
|
||||
isSearchProviderLoading ||
|
||||
hasHomeFeedExtension ||
|
||||
hasExploreContent ||
|
||||
hasSearchInput;
|
||||
}
|
||||
|
||||
static String? sanitizeFilter(
|
||||
String? filter,
|
||||
String? currentSearchProvider,
|
||||
|
||||
@@ -768,7 +768,13 @@ class _HomeTabState extends ConsumerState<HomeTab>
|
||||
explicitSearchProvider,
|
||||
extensions,
|
||||
);
|
||||
final showSearchBar = hasSearchProvider || isSearchProviderLoading;
|
||||
final showSearchBar = HomeSearchProviderPolicy.shouldShowSearchBar(
|
||||
hasSearchProvider: hasSearchProvider,
|
||||
isSearchProviderLoading: isSearchProviderLoading,
|
||||
hasHomeFeedExtension: hasHomeFeedExtension,
|
||||
hasExploreContent: hasExploreContent,
|
||||
hasSearchInput: hasSearchInput,
|
||||
);
|
||||
final hasResults =
|
||||
hasSearchInput || hasActualResults || isLoading || showRecentAccess;
|
||||
final showExplore =
|
||||
|
||||
@@ -121,6 +121,39 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
test('keeps Search visible across transient provider reconciliation', () {
|
||||
expect(
|
||||
HomeSearchProviderPolicy.shouldShowSearchBar(
|
||||
hasSearchProvider: false,
|
||||
isSearchProviderLoading: false,
|
||||
hasHomeFeedExtension: true,
|
||||
hasExploreContent: true,
|
||||
hasSearchInput: false,
|
||||
),
|
||||
isTrue,
|
||||
);
|
||||
expect(
|
||||
HomeSearchProviderPolicy.shouldShowSearchBar(
|
||||
hasSearchProvider: false,
|
||||
isSearchProviderLoading: false,
|
||||
hasHomeFeedExtension: false,
|
||||
hasExploreContent: false,
|
||||
hasSearchInput: true,
|
||||
),
|
||||
isTrue,
|
||||
);
|
||||
expect(
|
||||
HomeSearchProviderPolicy.shouldShowSearchBar(
|
||||
hasSearchProvider: false,
|
||||
isSearchProviderLoading: false,
|
||||
hasHomeFeedExtension: false,
|
||||
hasExploreContent: false,
|
||||
hasSearchInput: false,
|
||||
),
|
||||
isFalse,
|
||||
);
|
||||
});
|
||||
|
||||
test('canonicalizes built-in and extension search filters', () {
|
||||
final extension = _searchExtension(
|
||||
id: 'provider',
|
||||
|
||||
Reference in New Issue
Block a user