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();
|
final restrictedDirs = await storageService.getRestrictedDirectories();
|
||||||
for (final selectionDir in selectionDirs) {
|
for (final selectionDir in selectionDirs) {
|
||||||
final dir = VolumeRelativeDirectory.fromPath(selectionDir);
|
final dir = VolumeRelativeDirectory.fromPath(selectionDir);
|
||||||
|
if (dir == null) return;
|
||||||
if (restrictedDirs.contains(dir)) {
|
if (restrictedDirs.contains(dir)) {
|
||||||
await showRestrictedDirectoryDialog(context, dir);
|
await showRestrictedDirectoryDialog(context, dir);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -39,13 +39,18 @@ class AlbumListPage extends StatelessWidget {
|
||||||
showHeaders: settings.albumGroupFactor != AlbumChipGroupFactor.none,
|
showHeaders: settings.albumGroupFactor != AlbumChipGroupFactor.none,
|
||||||
chipSetActionDelegate: AlbumChipSetActionDelegate(),
|
chipSetActionDelegate: AlbumChipSetActionDelegate(),
|
||||||
chipActionDelegate: AlbumChipActionDelegate(),
|
chipActionDelegate: AlbumChipActionDelegate(),
|
||||||
chipActionsBuilder: (filter) => [
|
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,
|
settings.pinnedFilters.contains(filter) ? ChipAction.unpin : ChipAction.pin,
|
||||||
ChipAction.setCover,
|
ChipAction.setCover,
|
||||||
ChipAction.rename,
|
if (canRename) ChipAction.rename,
|
||||||
ChipAction.delete,
|
ChipAction.delete,
|
||||||
ChipAction.hide,
|
ChipAction.hide,
|
||||||
],
|
];
|
||||||
|
},
|
||||||
filterSections: getAlbumEntries(context, source),
|
filterSections: getAlbumEntries(context, source),
|
||||||
emptyBuilder: () => EmptyContent(
|
emptyBuilder: () => EmptyContent(
|
||||||
icon: AIcons.album,
|
icon: AIcons.album,
|
||||||
|
|
|
@ -192,10 +192,13 @@ class AlbumChipActionDelegate extends ChipActionDelegate with FeedbackMixin, Per
|
||||||
final todoEntries = source.visibleEntries.where(filter.test).toSet();
|
final todoEntries = source.visibleEntries.where(filter.test).toSet();
|
||||||
final todoCount = todoEntries.length;
|
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,
|
// check whether renaming is possible given OS restrictions,
|
||||||
// before asking to input a new name
|
// before asking to input a new name
|
||||||
final restrictedDirs = await storageService.getRestrictedDirectories();
|
final restrictedDirs = await storageService.getRestrictedDirectories();
|
||||||
final dir = VolumeRelativeDirectory.fromPath(album);
|
|
||||||
if (restrictedDirs.contains(dir)) {
|
if (restrictedDirs.contains(dir)) {
|
||||||
await showRestrictedDirectoryDialog(context, dir);
|
await showRestrictedDirectoryDialog(context, dir);
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue