From 9ca5f7b49251607cb01b6d8459129ceb5028e717 Mon Sep 17 00:00:00 2001 From: Thibault Deckers Date: Fri, 8 Jan 2021 11:51:26 +0900 Subject: [PATCH] fixed unique name for albums with the same name on different volumes --- lib/model/source/album.dart | 16 +++++++++++++--- lib/widgets/search/expandable_filter_row.dart | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/model/source/album.dart b/lib/model/source/album.dart index c9256ed4f..0dce9f30f 100644 --- a/lib/model/source/album.dart +++ b/lib/model/source/album.dart @@ -29,15 +29,25 @@ mixin AlbumMixin on SourceBase { } String getUniqueAlbumName(String album) { - final volumeRoot = androidFileUtils.getStorageVolume(album)?.path ?? ''; - final otherAlbums = _folderPaths.where((item) => item != album && item.startsWith(volumeRoot)); + final otherAlbums = _folderPaths.where((item) => item != album); final parts = album.split(separator); var partCount = 0; String testName; do { testName = separator + parts.skip(parts.length - ++partCount).join(separator); } while (otherAlbums.any((item) => item.endsWith(testName))); - return parts.skip(parts.length - partCount).join(separator); + final uniqueName = parts.skip(parts.length - partCount).join(separator); + + final volume = androidFileUtils.getStorageVolume(album); + final volumeRoot = volume?.path ?? ''; + final albumRelativePath = album.substring(volumeRoot.length); + if (uniqueName.length < albumRelativePath.length || volume == null) { + return uniqueName; + } else if (volume.isPrimary) { + return albumRelativePath; + } else { + return '$albumRelativePath (${volume.description})'; + } } Map getAlbumEntries() { diff --git a/lib/widgets/search/expandable_filter_row.dart b/lib/widgets/search/expandable_filter_row.dart index db02cadeb..5702fc9fb 100644 --- a/lib/widgets/search/expandable_filter_row.dart +++ b/lib/widgets/search/expandable_filter_row.dart @@ -105,7 +105,7 @@ class ExpandableFilterRow extends StatelessWidget { Widget _buildFilterChip(CollectionFilter filter) { return AvesFilterChip( - key: Key(filter.key), + key: ValueKey(filter), filter: filter, heroType: heroTypeBuilder?.call(filter) ?? HeroType.onTap, onTap: onTap,