From 70599727d7f8d4f0fe0f10dc526392ed50d9dbb0 Mon Sep 17 00:00:00 2001 From: Frederik Feichtmeier Date: Wed, 30 Oct 2024 21:45:33 +0100 Subject: [PATCH] fix: podcast and radio search jumping on scroll (#991) Fixes #926 --- lib/common/logging.dart | 4 ++-- lib/library/library_model.dart | 3 ++- lib/podcasts/podcast_service.dart | 4 +++- lib/search/view/search_page.dart | 4 +--- lib/search/view/sliver_podcast_search_results.dart | 1 + lib/search/view/sliver_radio_search_results.dart | 1 + 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/common/logging.dart b/lib/common/logging.dart index 1cbb3c50b..adda36b81 100644 --- a/lib/common/logging.dart +++ b/lib/common/logging.dart @@ -1,7 +1,7 @@ import 'package:flutter/foundation.dart'; -void printMessageInDebugMode(String message) { +void printMessageInDebugMode(Object? object) { if (kDebugMode) { - print(message); + print(object); } } diff --git a/lib/library/library_model.dart b/lib/library/library_model.dart index 77181e0eb..3729ddd67 100644 --- a/lib/library/library_model.dart +++ b/lib/library/library_model.dart @@ -5,6 +5,7 @@ import 'package:safe_change_notifier/safe_change_notifier.dart'; import '../common/data/audio.dart'; import '../common/logging.dart'; +import '../common/view/back_gesture.dart'; import '../constants.dart'; import 'library_service.dart'; @@ -202,7 +203,7 @@ class LibraryModel extends SafeChangeNotifier implements NavigatorObserver { await _masterNavigatorKey.currentState?.pushNamed(pageId); } else if (builder != null) { final materialPageRoute = MaterialPageRoute( - builder: builder, + builder: (context) => BackGesture(child: builder(context)), maintainState: maintainState, settings: RouteSettings( name: pageId, diff --git a/lib/podcasts/podcast_service.dart b/lib/podcasts/podcast_service.dart index fbc2dbc88..2450c64bf 100644 --- a/lib/podcasts/podcast_service.dart +++ b/lib/podcasts/podcast_service.dart @@ -5,6 +5,7 @@ import 'package:podcast_search/podcast_search.dart'; import '../common/data/audio.dart'; import '../common/data/podcast_genre.dart'; +import '../common/logging.dart'; import '../common/view/audio_filter.dart'; import '../common/view/languages.dart'; import '../library/library_service.dart'; @@ -70,7 +71,8 @@ class PodcastService { limit: limit, ); } - } catch (_) { + } catch (e) { + printMessageInDebugMode(e); return _searchResult; } diff --git a/lib/search/view/search_page.dart b/lib/search/view/search_page.dart index 65fc6c56a..2ca3d61db 100644 --- a/lib/search/view/search_page.dart +++ b/lib/search/view/search_page.dart @@ -57,10 +57,8 @@ class SearchPage extends StatelessWidget with WatchItMixin { builder: (context, constraints) { return NotificationListener( onNotification: (notification) { - // TODO(#926): improve radio search limit increase by not overwriting the search results - // disabled for radio until then if (notification.direction == ScrollDirection.reverse && - audioType == AudioType.podcast) { + audioType != AudioType.local) { di() ..incrementLimit(8) ..search(); diff --git a/lib/search/view/sliver_podcast_search_results.dart b/lib/search/view/sliver_podcast_search_results.dart index 5c9cbf1d4..b3db28fe9 100644 --- a/lib/search/view/sliver_podcast_search_results.dart +++ b/lib/search/view/sliver_podcast_search_results.dart @@ -112,6 +112,7 @@ class _SliverPodcastSearchResultsState } return AudioCard( + key: ValueKey(feedUrl), bottom: AudioCardBottom( text: podcastItem.collectionName ?? podcastItem.trackName, ), diff --git a/lib/search/view/sliver_radio_search_results.dart b/lib/search/view/sliver_radio_search_results.dart index 8ebe47093..253bc0fc7 100644 --- a/lib/search/view/sliver_radio_search_results.dart +++ b/lib/search/view/sliver_radio_search_results.dart @@ -101,6 +101,7 @@ class _SliverRadioSearchResultsState extends State { itemBuilder: (context, index) { final station = radioSearchResult.elementAt(index); return AudioTile( + key: ValueKey(station.uuid), showLeading: true, audioPageType: AudioPageType.radioSearch, isPlayerPlaying: playing,