Merge pull request #455 from ente-io/bugFix
Fix minor bugs in share warning for collections with hidden files
This commit is contained in:
commit
8b28493803
3 changed files with 20 additions and 10 deletions
|
@ -445,7 +445,7 @@ class FilesDB {
|
|||
whereArgs: [ownerID, visibility],
|
||||
distinct: true,
|
||||
);
|
||||
Set<int> collectionIDsOfHiddenFiles = {};
|
||||
final Set<int> collectionIDsOfHiddenFiles = {};
|
||||
for (var result in results) {
|
||||
collectionIDsOfHiddenFiles.add(result['collection_id']);
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ class FeatureFlagService {
|
|||
}
|
||||
|
||||
bool isInternalUserOrDebugBuild() {
|
||||
String email = Configuration.instance.getEmail();
|
||||
final String email = Configuration.instance.getEmail();
|
||||
return (email != null && email.endsWith("@ente.io")) || kDebugMode;
|
||||
}
|
||||
|
||||
|
|
|
@ -133,8 +133,9 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
|
|||
child: IconButton(
|
||||
icon: Icon(Icons.adaptive.share),
|
||||
onPressed: () async {
|
||||
if (FeatureFlagService.instance.isInternalUserOrDebugBuild() &&
|
||||
await _collectionHasHiddenFiles(widget.collection.id)) {
|
||||
final bool showHiddenWarning =
|
||||
await _shouldShowHiddenFilesWarning(widget.collection);
|
||||
if (showHiddenWarning) {
|
||||
final choice = await showChoiceDialog(
|
||||
context,
|
||||
'Share hidden items?',
|
||||
|
@ -144,12 +145,11 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
|
|||
secondActionColor:
|
||||
Theme.of(context).colorScheme.defaultTextColor,
|
||||
);
|
||||
if (choice == DialogUserChoice.secondChoice) {
|
||||
_showShareCollectionDialog();
|
||||
if (choice != DialogUserChoice.secondChoice) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
_showShareCollectionDialog();
|
||||
}
|
||||
await _showShareCollectionDialog();
|
||||
},
|
||||
),
|
||||
),
|
||||
|
@ -246,11 +246,21 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
|
|||
}
|
||||
}
|
||||
|
||||
Future<bool> _collectionHasHiddenFiles(int collectionID) async {
|
||||
Future<bool> _shouldShowHiddenFilesWarning(Collection collection) async {
|
||||
// collection can be null for device folders which are not marked for
|
||||
// back up
|
||||
if (!FeatureFlagService.instance.isInternalUserOrDebugBuild() ||
|
||||
collection == null) {
|
||||
return false;
|
||||
}
|
||||
// collection is already shared
|
||||
if (collection.sharees.isNotEmpty || collection.publicURLs.isNotEmpty) {
|
||||
return false;
|
||||
}
|
||||
final collectionIDsWithHiddenFiles =
|
||||
await FilesDB.instance.getCollectionIDsOfHiddenFiles(
|
||||
Configuration.instance.getUserID(),
|
||||
);
|
||||
return collectionIDsWithHiddenFiles.contains(collectionID);
|
||||
return collectionIDsWithHiddenFiles.contains(collection.id);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue