mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-07-26 05:51:18 +02:00
19f69a6090
Service ids ('deezer', 'tidal', 'qobuz', 'spotify', 'amazon', 'local')
were compared as raw string literals in every dispatch chain. Introduce
MusicServices constants and use them at the comparison/switch sites so
a typo becomes a compile error instead of a silently dead branch.
21 lines
819 B
Dart
21 lines
819 B
Dart
import 'package:spotiflac_android/constants/music_services.dart';
|
|
|
|
/// Maps a legacy prefixed resource id (e.g. "deezer:123") to its provider id,
|
|
/// or null when the value carries no known provider prefix.
|
|
String? legacyProviderIdFromResourceId(String value) {
|
|
if (value.startsWith('deezer:')) return MusicServices.deezer;
|
|
if (value.startsWith('qobuz:')) return MusicServices.qobuz;
|
|
if (value.startsWith('tidal:')) return MusicServices.tidal;
|
|
if (value.startsWith('spotify:')) return MusicServices.spotify;
|
|
return null;
|
|
}
|
|
|
|
/// Strips a leading "provider:" prefix from a resource id, if present.
|
|
String stripPrefixedResourceId(String value) {
|
|
final colonIndex = value.indexOf(':');
|
|
if (colonIndex <= 0 || colonIndex == value.length - 1) {
|
|
return value;
|
|
}
|
|
return value.substring(colonIndex + 1);
|
|
}
|