albums: prevent renaming volume root album
This commit is contained in:
parent
0db76a46de
commit
562f3057ed
3 changed files with 17 additions and 8 deletions
|
@ -71,6 +71,7 @@ class EntrySetActionDelegate with FeedbackMixin, PermissionAwareMixin, SizeAware
|
|||
final restrictedDirs = await storageService.getRestrictedDirectories();
|
||||
for (final selectionDir in selectionDirs) {
|
||||
final dir = VolumeRelativeDirectory.fromPath(selectionDir);
|
||||
if (dir == null) return;
|
||||
if (restrictedDirs.contains(dir)) {
|
||||
await showRestrictedDirectoryDialog(context, dir);
|
||||
return;
|
||||
|
|
|
@ -39,13 +39,18 @@ class AlbumListPage extends StatelessWidget {
|
|||
showHeaders: settings.albumGroupFactor != AlbumChipGroupFactor.none,
|
||||
chipSetActionDelegate: AlbumChipSetActionDelegate(),
|
||||
chipActionDelegate: AlbumChipActionDelegate(),
|
||||
chipActionsBuilder: (filter) => [
|
||||
settings.pinnedFilters.contains(filter) ? ChipAction.unpin : ChipAction.pin,
|
||||
ChipAction.setCover,
|
||||
ChipAction.rename,
|
||||
ChipAction.delete,
|
||||
ChipAction.hide,
|
||||
],
|
||||
chipActionsBuilder: (filter) {
|
||||
final dir = VolumeRelativeDirectory.fromPath(filter.album);
|
||||
// do not allow renaming volume root
|
||||
final canRename = dir != null && dir.relativeDir.isNotEmpty;
|
||||
return [
|
||||
settings.pinnedFilters.contains(filter) ? ChipAction.unpin : ChipAction.pin,
|
||||
ChipAction.setCover,
|
||||
if (canRename) ChipAction.rename,
|
||||
ChipAction.delete,
|
||||
ChipAction.hide,
|
||||
];
|
||||
},
|
||||
filterSections: getAlbumEntries(context, source),
|
||||
emptyBuilder: () => EmptyContent(
|
||||
icon: AIcons.album,
|
||||
|
|
|
@ -192,10 +192,13 @@ class AlbumChipActionDelegate extends ChipActionDelegate with FeedbackMixin, Per
|
|||
final todoEntries = source.visibleEntries.where(filter.test).toSet();
|
||||
final todoCount = todoEntries.length;
|
||||
|
||||
final dir = VolumeRelativeDirectory.fromPath(album);
|
||||
// do not allow renaming volume root
|
||||
if (dir == null || dir.relativeDir.isEmpty) return;
|
||||
|
||||
// check whether renaming is possible given OS restrictions,
|
||||
// before asking to input a new name
|
||||
final restrictedDirs = await storageService.getRestrictedDirectories();
|
||||
final dir = VolumeRelativeDirectory.fromPath(album);
|
||||
if (restrictedDirs.contains(dir)) {
|
||||
await showRestrictedDirectoryDialog(context, dir);
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue