Skip to content

Commit

Permalink
fix: replace remaining station url ids with uuid, fix discord error s…
Browse files Browse the repository at this point in the history
…pam (#965)
  • Loading branch information
Feichtmeier authored Oct 20, 2024
1 parent 8826781 commit 04a0b5c
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 18 deletions.
26 changes: 22 additions & 4 deletions lib/expose/expose_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,34 @@ class ExposeService {
),
);
}
} on Exception catch (_) {}
} on Exception catch (e) {
_errorController.add(e.toString());
}
}

Future<void> connect() async {
await connectToDiscord();
try {
await _discordRPC?.connect();
} on Exception catch (e) {
_errorController.add(e.toString());
}
}

Future<void> connectToDiscord() async => _discordRPC?.connect();
Future<void> connectToDiscord() async {
try {
await _discordRPC?.connect();
} on Exception catch (e) {
_errorController.add(e.toString());
}
}

Future<void> disconnectFromDiscord() async => _discordRPC?.disconnect();
Future<void> disconnectFromDiscord() async {
try {
await _discordRPC?.disconnect();
} on Exception catch (e) {
_errorController.add(e.toString());
}
}

Future<void> dispose() async {
await _discordRPC?.disconnect();
Expand Down
4 changes: 2 additions & 2 deletions lib/radio/view/next_station_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ class NextStationButton extends StatelessWidget with WatchItMixin {
if (host == null) return null;
return di<SearchModel>().nextSimilarStation(audio).then(
(station) {
if (station == audio) return;
if (station == audio || audio.uuid == null) return;
di<PlayerModel>().startPlaylist(
audios: [station],
listName: station.uuid ?? station.toString(),
listName: station.uuid!,
);
},
);
Expand Down
4 changes: 2 additions & 2 deletions lib/radio/view/radio_history_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ class RadioHistoryTile extends StatelessWidget with PlayerMixin {
if (libraryModel.selectedPageId == entry.value.icyUrl) return;

di<SearchModel>().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,
);
}
});
Expand Down
8 changes: 4 additions & 4 deletions lib/radio/view/station_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<LibraryModel>().push(
builder: (_) => StationPage(station: station!),
pageId: station!.url!,
pageId: station!.uuid!,
),
image: SizedBox.expand(
child: SafeNetworkImage(
Expand Down
14 changes: 8 additions & 6 deletions lib/search/view/sliver_radio_search_results.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,14 @@ class _SliverRadioSearchResultsState extends State<SliverRadioSearchResults> {
selected: currentAudio == station,
pageId: station.description!,
audio: station,
onTap: () {
di<PlayerModel>().startPlaylist(
audios: [station],
listName: station.title ?? station.description ?? station.url!,
).then((_) => di<RadioModel>().clickStation(station));
},
onTap: station.uuid == null
? null
: () {
di<PlayerModel>().startPlaylist(
audios: [station],
listName: station.uuid!,
).then((_) => di<RadioModel>().clickStation(station));
},
);
},
);
Expand Down

0 comments on commit 04a0b5c

Please sign in to comment.