Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Overview of ignored persons

laurenspriem55b0affe4aaf
diff --git a/mobile/apps/photos/lib/services/search_service.dart b/mobile/apps/photos/lib/services/search_service.dart
index f4467121ee..8115926464 100644
--- a/mobile/apps/photos/lib/services/search_service.dart
+++ b/mobile/apps/photos/lib/services/search_service.dart
@@ -808,6 +808,7 @@ class SearchService {
Future<List<GenericSearchResult>> getAllFace(
int? limit, {
required int minClusterSize,
+ bool showIgnoredOnly = false,
}) async {
try {
debugPrint("getting faces");
@@ -898,7 +899,8 @@ class SearchService {
for (final personID in orderedPersonIds) {
final files = personIdToFiles[personID]!;
final PersonEntity p = personIdToPerson[personID]!;
- if (p.data.isIgnored) continue;
+ final bool isIgnored = p.data.isIgnored;
+ if (showIgnoredOnly != isIgnored) continue;
facesResult.add(
GenericSearchResult(
ResultType.faces,
@@ -957,64 +959,68 @@ class SearchService {
.compareTo(clusterIdToFiles[a]!.length),
);
- for (final clusterId in sortedClusterIds) {
- final files = clusterIdToFiles[clusterId]!;
- final String clusterName = clusterId;
-
- if (clusterIDToPersonID[clusterId] != null) {
- final String personID = clusterIDToPersonID[clusterId]!;
- final PersonEntity? p = personIdToPerson[personID];
- if (p != null) {
- // This should not be possible since it should be handled in the above loop, logging just in case
- _logger.severe(
- "`getAllFace`: Something unexpected happened, Cluster $clusterId should not have person id $personID",
- Exception(
- 'Some unexpected error occurred in getAllFace wrt cluster to person mapping',
- ),
- );
- } else {
- // This should not happen, means a clusterID is still assigned to a personID of a person that no longer exists
- // Logging the error and deleting the clusterID to personID mapping
- _logger.severe(
- "`getAllFace`: Cluster $clusterId should not have person id ${clusterIDToPersonID[clusterId]}, deleting the mapping",
- Exception('ClusterID assigned to a person that no longer exists'),
- );
- await mlDataDB.removeClusterToPerson(
- personID: personID,
- clusterID: clusterId,
- );
- }
- }
- if (files.length < minClusterSize) continue;
- facesResult.add(
- GenericSearchResult(
- ResultType.faces,
- "",
- files,
- params: {
- kClusterParamId: clusterId,
- kFileID: files.first.uploadedFileID,
- },
- onResultTap: (ctx) {
- routeToPage(
- ctx,
- ClusterPage(
- files,
- tagPrefix: "${ResultType.faces.toString()}_$clusterName",
- clusterID: clusterId,
+ if (!showIgnoredOnly) {
+ for (final clusterId in sortedClusterIds) {
+ final files = clusterIdToFiles[clusterId]!;
+ final String clusterName = clusterId;
+
+ if (clusterIDToPersonID[clusterId] != null) {
+ final String personID = clusterIDToPersonID[clusterId]!;
+ final PersonEntity? p = personIdToPerson[personID];
+ if (p != null) {
+ // This should not be possible since it should be handled in the above loop, logging just in case
+ _logger.severe(
+ "`getAllFace`: Something unexpected happened, Cluster $clusterId should not have person id $personID",
+ Exception(
+ 'Some unexpected error occurred in getAllFace wrt cluster to person mapping',
),
);
- },
- hierarchicalSearchFilter: FaceFilter(
- personId: null,
- clusterId: clusterId,
- faceName: null,
- faceFile: files.first,
- occurrence: kMostRelevantFilter,
- matchedUploadedIDs: filesToUploadedFileIDs(files),
+ } else {
+ // This should not happen, means a clusterID is still assigned to a personID of a person that no longer exists
+ // Logging the error and deleting the clusterID to personID mapping
+ _logger.severe(
+ "`getAllFace`: Cluster $clusterId should not have person id ${clusterIDToPersonID[clusterId]}, deleting the mapping",
+ Exception(
+ 'ClusterID assigned to a person that no longer exists',
+ ),
+ );
+ await mlDataDB.removeClusterToPerson(
+ personID: personID,
+ clusterID: clusterId,
+ );
+ }
+ }
+ if (files.length < minClusterSize) continue;
+ facesResult.add(
+ GenericSearchResult(
+ ResultType.faces,
+ "",
+ files,
+ params: {
+ kClusterParamId: clusterId,
+ kFileID: files.first.uploadedFileID,
+ },
+ onResultTap: (ctx) {
+ routeToPage(
+ ctx,
+ ClusterPage(
+ files,
+ tagPrefix: "${ResultType.faces.toString()}_$clusterName",
+ clusterID: clusterId,
+ ),
+ );
+ },
+ hierarchicalSearchFilter: FaceFilter(
+ personId: null,
+ clusterId: clusterId,
+ faceName: null,
+ faceFile: files.first,
+ occurrence: kMostRelevantFilter,
+ matchedUploadedIDs: filesToUploadedFileIDs(files),
+ ),
),
- ),
- );
+ );
+ }
}
if (facesResult.isEmpty) return [];
sortPeopleFaces(
diff --git a/mobile/apps/photos/lib/ui/viewer/search/result/people_section_all_page.dart b/mobile/apps/photos/lib/ui/viewer/search/result/people_section_all_page.dart
index bf4c6edb93..b9e123d71f 100644
--- a/mobile/apps/photos/lib/ui/viewer/search/result/people_section_all_page.dart
+++ b/mobile/apps/photos/lib/ui/viewer/search/result/people_section_all_page.dart
@@ -367,6 +367,7 @@ class _PeopleSectionAllWidgetState extends State<PeopleSectionAllWidget> {
List<GenericSearchResult> extraFaces = [];
final streamSubscriptions = <StreamSubscription>[];
bool _showingAllFaces = false;
+ bool _showingIgnoredPeople = false;
bool _isLoaded = false;
bool _isInitialLoad = true;
bool userDismissedPersonGallerySuggestion = false;
@@ -383,7 +384,10 @@ class _PeopleSectionAllWidgetState extends State<PeopleSectionAllWidget> {
bool get _isSearching => _searchQuery.trim().isNotEmpty;
bool get _showMoreLessOption =>
- !_isSearching && !widget.namedOnly && extraFaces.isNotEmpty;
+ !_isSearching &&
+ !widget.namedOnly &&
+ !_showingIgnoredPeople &&
+ extraFaces.isNotEmpty;
List<GenericSearchResult> _filterFaces(
List<GenericSearchResult> faces,
@@ -418,6 +422,14 @@ class _PeopleSectionAllWidgetState extends State<PeopleSectionAllWidget> {
}
}
+ void _toggleIgnoredPeopleView() {
+ setState(() {
+ _showingIgnoredPeople = !_showingIgnoredPeople;
+ _isLoaded = false;
+ sectionData = getResults();
+ });
+ }
+
@override
void initState() {
super.initState();
@@ -459,28 +471,36 @@ class _PeopleSectionAllWidgetState extends State<PeopleSectionAllWidget> {
}
Future<List<GenericSearchResult>> getResults({bool init = false}) async {
- final allFaces = await SearchService.instance
- .getAllFace(null, minClusterSize: kMinimumClusterSizeAllFaces);
+ final allFaces = await SearchService.instance.getAllFace(
+ null,
+ minClusterSize: kMinimumClusterSizeAllFaces,
+ showIgnoredOnly: _showingIgnoredPeople,
+ );
normalFaces.clear();
extraFaces.clear();
- for (final face in allFaces) {
- if (face.fileCount() >= kMinimumClusterSizeSearchResult ||
- face.name().isNotEmpty) {
- normalFaces.add(face);
- } else {
- extraFaces.add(face);
+ if (_showingIgnoredPeople) {
+ normalFaces.addAll(allFaces);
+ } else {
+ for (final face in allFaces) {
+ if (face.fileCount() >= kMinimumClusterSizeSearchResult ||
+ face.name().isNotEmpty) {
+ normalFaces.add(face);
+ } else {
+ extraFaces.add(face);
+ }
+ }
+ if (normalFaces.isEmpty && extraFaces.isNotEmpty) {
+ normalFaces.addAll(extraFaces);
+ extraFaces.clear();
}
- }
- if (normalFaces.isEmpty && extraFaces.isNotEmpty) {
- normalFaces = extraFaces;
- extraFaces = [];
}
if (widget.showSearchBar) {
_sortFaces(normalFaces);
_sortFaces(extraFaces);
}
+ final showAllFaces = _showingAllFaces || _showingIgnoredPeople;
final results =
- _showingAllFaces ? [...normalFaces, ...extraFaces] : normalFaces;
+ showAllFaces ? [...normalFaces, ...extraFaces] : normalFaces;
if (widget.namedOnly) {
results.removeWhere(
@@ -593,6 +613,10 @@ class _PeopleSectionAllWidgetState extends State<PeopleSectionAllWidget> {
searchIconPadding:
const EdgeInsets.fromLTRB(12, 12, horizontalEdgePadding, 12),
actions: [
+ Padding(
+ padding: const EdgeInsets.only(right: 12),
+ child: _buildIgnoredPeopleToggle(colorScheme),
+ ),
Padding(
padding: const EdgeInsets.only(right: horizontalEdgePadding),
child: _buildSortMenu(context, textTheme, colorScheme),
@@ -692,11 +716,14 @@ class _PeopleSectionAllWidgetState extends State<PeopleSectionAllWidget> {
),
);
} else {
+ final showAllFaces = _showingAllFaces || _showingIgnoredPeople;
final showExtraFaces =
- _showingAllFaces && filteredExtraFaces.isNotEmpty;
+ showAllFaces && filteredExtraFaces.isNotEmpty;
slivers.addAll(
[
- (!userDismissedPersonGallerySuggestion && !widget.namedOnly)
+ (!userDismissedPersonGallerySuggestion &&
+ !widget.namedOnly &&
+ !_showingIgnoredPeople)
? SliverToBoxAdapter(
child: Dismissible(
key: const Key("personGallerySuggestionAll"),
@@ -878,6 +905,17 @@ class _PeopleSectionAllWidgetState extends State<PeopleSectionAllWidget> {
);
}
+ Widget _buildIgnoredPeopleToggle(EnteColorScheme colorScheme) {
+ return IconButtonWidget(
+ icon: _showingIgnoredPeople
+ ? Icons.visibility_rounded
+ : Icons.visibility_off_rounded,
+ iconButtonType: IconButtonType.secondary,
+ iconColor: colorScheme.textMuted,
+ onTap: _toggleIgnoredPeopleView,
+ );
+ }
+
PopupMenuItem<PeopleSortKey> _buildSortMenuItem(
PeopleSortKey key,
bool isLast,