From 04a0b5cfdc1514910045aaa6312fb7fe6e463259 Mon Sep 17 00:00:00 2001 From: Frederik Feichtmeier Date: Mon, 21 Oct 2024 01:00:44 +0200 Subject: [PATCH] fix: replace remaining station url ids with uuid, fix discord error spam (#965) --- lib/expose/expose_service.dart | 26 ++++++++++++++++--- lib/radio/view/next_station_button.dart | 4 +-- lib/radio/view/radio_history_tile.dart | 4 +-- lib/radio/view/station_card.dart | 8 +++--- .../view/sliver_radio_search_results.dart | 14 +++++----- 5 files changed, 38 insertions(+), 18 deletions(-) diff --git a/lib/expose/expose_service.dart b/lib/expose/expose_service.dart index 29faf53ef..30cd8ead3 100644 --- a/lib/expose/expose_service.dart +++ b/lib/expose/expose_service.dart @@ -34,16 +34,34 @@ class ExposeService { ), ); } - } on Exception catch (_) {} + } on Exception catch (e) { + _errorController.add(e.toString()); + } } Future connect() async { - await connectToDiscord(); + try { + await _discordRPC?.connect(); + } on Exception catch (e) { + _errorController.add(e.toString()); + } } - Future connectToDiscord() async => _discordRPC?.connect(); + Future connectToDiscord() async { + try { + await _discordRPC?.connect(); + } on Exception catch (e) { + _errorController.add(e.toString()); + } + } - Future disconnectFromDiscord() async => _discordRPC?.disconnect(); + Future disconnectFromDiscord() async { + try { + await _discordRPC?.disconnect(); + } on Exception catch (e) { + _errorController.add(e.toString()); + } + } Future dispose() async { await _discordRPC?.disconnect(); diff --git a/lib/radio/view/next_station_button.dart b/lib/radio/view/next_station_button.dart index 8d754705d..f66cef16c 100644 --- a/lib/radio/view/next_station_button.dart +++ b/lib/radio/view/next_station_button.dart @@ -25,10 +25,10 @@ class NextStationButton extends StatelessWidget with WatchItMixin { if (host == null) return null; return di().nextSimilarStation(audio).then( (station) { - if (station == audio) return; + if (station == audio || audio.uuid == null) return; di().startPlaylist( audios: [station], - listName: station.uuid ?? station.toString(), + listName: station.uuid!, ); }, ); diff --git a/lib/radio/view/radio_history_tile.dart b/lib/radio/view/radio_history_tile.dart index 47c9c29e6..1cdea41fc 100644 --- a/lib/radio/view/radio_history_tile.dart +++ b/lib/radio/view/radio_history_tile.dart @@ -86,11 +86,11 @@ class RadioHistoryTile extends StatelessWidget with PlayerMixin { if (libraryModel.selectedPageId == entry.value.icyUrl) return; di().radioNameSearch(entry.value.icyName).then((v) { - if (v?.firstOrNull?.urlResolved != null) { + if (v?.firstOrNull?.stationUUID != null) { libraryModel.push( builder: (_) => StationPage(station: Audio.fromStation(v.first)), - pageId: v!.first.urlResolved!, + pageId: v!.first.stationUUID, ); } }); diff --git a/lib/radio/view/station_card.dart b/lib/radio/view/station_card.dart index 5bbea79a7..2eaabe193 100644 --- a/lib/radio/view/station_card.dart +++ b/lib/radio/view/station_card.dart @@ -28,17 +28,17 @@ class StationCard extends StatelessWidget { Widget build(BuildContext context) { return AudioCard( bottom: AudioCardBottom(text: station?.title?.replaceAll('_', '') ?? ''), - onPlay: station?.url == null + onPlay: station?.uuid == null ? null : () => startPlaylist( audios: [station!], - listName: station!.url!, + listName: station!.uuid!, ), - onTap: station?.url == null + onTap: station?.uuid == null ? null : () => di().push( builder: (_) => StationPage(station: station!), - pageId: station!.url!, + pageId: station!.uuid!, ), image: SizedBox.expand( child: SafeNetworkImage( diff --git a/lib/search/view/sliver_radio_search_results.dart b/lib/search/view/sliver_radio_search_results.dart index 287d2b2cf..71d5716b4 100644 --- a/lib/search/view/sliver_radio_search_results.dart +++ b/lib/search/view/sliver_radio_search_results.dart @@ -99,12 +99,14 @@ class _SliverRadioSearchResultsState extends State { selected: currentAudio == station, pageId: station.description!, audio: station, - onTap: () { - di().startPlaylist( - audios: [station], - listName: station.title ?? station.description ?? station.url!, - ).then((_) => di().clickStation(station)); - }, + onTap: station.uuid == null + ? null + : () { + di().startPlaylist( + audios: [station], + listName: station.uuid!, + ).then((_) => di().clickStation(station)); + }, ); }, );