fixed unique name for albums with the same name on different volumes

This commit is contained in:
Thibault Deckers 2021-01-08 11:51:26 +09:00
parent cd2811be02
commit 9ca5f7b492
2 changed files with 14 additions and 4 deletions

View file

@ -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<String, ImageEntry> getAlbumEntries() {

View file

@ -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,