Gate radio station features behind API v7.13.0#168
Conversation
Radio stations are only available since Koel v7.13.0. Hide the library menu item and search results section for older API versions.
📝 WalkthroughWalkthroughThis change adds conditional feature support for radio stations, gating UI rendering based on API version compatibility. A new Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
lib/ui/screens/library.dart (1)
75-81: Add a route/screen-level guard for radio support too.This menu gate is good, but
RadioStationsScreencan still fetch on direct navigation. Consider guarding inlib/ui/screens/radio_stations.dartas well to prevent unsupported API calls outside this menu path.Proposed hardening patch (radio_stations.dart)
+import 'package:app/utils/features.dart'; class _RadioStationsScreenState extends State<RadioStationsScreen> { var _loading = false; + bool get _supported => Feature.radioStations.isSupported(); `@override` void initState() { super.initState(); - _fetchData(); + if (_supported) _fetchData(); } Future<void> _fetchData() async { + if (!_supported) return; if (_loading) return; setState(() => _loading = true);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/ui/screens/library.dart` around lines 75 - 81, Add a screen-level guard inside RadioStationsScreen (e.g., in its initState and/or build) to check Feature.radioStations.isSupported() and prevent any fetch or API calls when unsupported: if unsupported, immediately navigate back or render a fallback/unsupported widget instead of proceeding, and ensure methods that call the API (e.g., fetchRadioStations / any network calls triggered from initState or didChangeDependencies) early-return when the feature is not supported so no unsupported API requests are made.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@lib/ui/screens/library.dart`:
- Around line 75-81: Add a screen-level guard inside RadioStationsScreen (e.g.,
in its initState and/or build) to check Feature.radioStations.isSupported() and
prevent any fetch or API calls when unsupported: if unsupported, immediately
navigate back or render a fallback/unsupported widget instead of proceeding, and
ensure methods that call the API (e.g., fetchRadioStations / any network calls
triggered from initState or didChangeDependencies) early-return when the feature
is not supported so no unsupported API requests are made.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 97caadd2-b6ad-49e1-a997-ade6f30183a3
📒 Files selected for processing (4)
lib/ui/screens/library.dartlib/ui/screens/search.dartlib/utils/features.darttest/utils/features_test.dart
Summary
Feature.radioStationsto the existing feature flag system (same pattern as podcasts)radio_stationskey gracefullyTest plan
Feature.radioStations.isSupported()with various API versionsSummary by CodeRabbit
Bug Fixes
Tests