Skip to content

Commit

Permalink
fix: podcast and radio search jumping on scroll (#991)
Browse files Browse the repository at this point in the history
Fixes #926
  • Loading branch information
Feichtmeier authored Oct 30, 2024
1 parent 27ab963 commit 7059972
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lib/common/logging.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:flutter/foundation.dart';

void printMessageInDebugMode(String message) {
void printMessageInDebugMode(Object? object) {
if (kDebugMode) {
print(message);
print(object);
}
}
3 changes: 2 additions & 1 deletion lib/library/library_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion lib/podcasts/podcast_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -70,7 +71,8 @@ class PodcastService {
limit: limit,
);
}
} catch (_) {
} catch (e) {
printMessageInDebugMode(e);
return _searchResult;
}

Expand Down
4 changes: 1 addition & 3 deletions lib/search/view/search_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,8 @@ class SearchPage extends StatelessWidget with WatchItMixin {
builder: (context, constraints) {
return NotificationListener<UserScrollNotification>(
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<SearchModel>()
..incrementLimit(8)
..search();
Expand Down
1 change: 1 addition & 0 deletions lib/search/view/sliver_podcast_search_results.dart
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ class _SliverPodcastSearchResultsState
}

return AudioCard(
key: ValueKey(feedUrl),
bottom: AudioCardBottom(
text: podcastItem.collectionName ?? podcastItem.trackName,
),
Expand Down
1 change: 1 addition & 0 deletions lib/search/view/sliver_radio_search_results.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class _SliverRadioSearchResultsState extends State<SliverRadioSearchResults> {
itemBuilder: (context, index) {
final station = radioSearchResult.elementAt(index);
return AudioTile(
key: ValueKey(station.uuid),
showLeading: true,
audioPageType: AudioPageType.radioSearch,
isPlayerPlaying: playing,
Expand Down

0 comments on commit 7059972

Please sign in to comment.