Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for sorting behaviour and make album year optional #152

Merged
merged 6 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:
nt4f04uNd marked this conversation as resolved.
Show resolved Hide resolved
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;
Abestanis marked this conversation as resolved.
Show resolved Hide resolved
}

/// 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) {
nt4f04uNd marked this conversation as resolved.
Show resolved Hide resolved
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