Skip to content

Commit

Permalink
Add tests for sorting behaviour and make album year optional
Browse files Browse the repository at this point in the history
  • Loading branch information
Abestanis committed Aug 25, 2024
1 parent 86ca448 commit 6beb6bd
Show file tree
Hide file tree
Showing 7 changed files with 274 additions and 163 deletions.
8 changes: 0 additions & 8 deletions lib/localization/localization.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ extension AppLocalizationsExtension on AppLocalizations {
return artist;
case SongSortFeature.album:
return album;
default:
throw UnimplementedError();
}
case ContentType.album:
switch (feature as AlbumSortFeature) {
Expand All @@ -78,8 +76,6 @@ extension AppLocalizationsExtension on AppLocalizations {
return year;
case AlbumSortFeature.numberOfSongs:
return numberOfTracks;
default:
throw UnimplementedError();
}
case ContentType.playlist:
switch (feature as PlaylistSortFeature) {
Expand All @@ -89,8 +85,6 @@ extension AppLocalizationsExtension on AppLocalizations {
return dateAdded;
case PlaylistSortFeature.name:
return title;
default:
throw UnimplementedError();
}
case ContentType.artist:
switch (feature as ArtistSortFeature) {
Expand All @@ -100,8 +94,6 @@ extension AppLocalizationsExtension on AppLocalizations {
return numberOfAlbums;
case ArtistSortFeature.numberOfTracks:
return numberOfTracks;
default:
throw UnimplementedError();
}
}
}
Expand Down
9 changes: 2 additions & 7 deletions lib/logic/models/album.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,15 @@ class Album extends PersistentQueue implements PlatformAlbum {
bool get playable => true;

/// Gets album normalized year.
int get year {
return lastYear == null || lastYear! < 1000 ? clock.now().year : lastYear!;
int? get year {
return lastYear ?? firstYear;
}

/// Returns string in format `album name • year`.
String get nameDotYear {
return ContentUtils.appendYearWithDot(album, year);
}

/// Returns string in format `Album • year`.
String albumDotName(AppLocalizations l10n) {
return ContentUtils.appendYearWithDot(l10n.album, year);
}

/// Returns the album artist.
Artist? getArtist() =>
artistId == null ? null : ContentControl.instance.state.artists.firstWhereOrNull((el) => el.id == artistId);
Expand Down
Loading

0 comments on commit 6beb6bd

Please sign in to comment.