[mob][photos] Don't show PeopleSection when faces is disabled
This commit is contained in:
parent
3d906490a6
commit
1e5512b36f
3 changed files with 16 additions and 6 deletions
|
@ -127,6 +127,9 @@ class FaceMlService {
|
|||
/// hooking FaceML into [MachineLearningController]
|
||||
if (Platform.isAndroid) {
|
||||
Bus.instance.on<MachineLearningControlEvent>().listen((event) {
|
||||
if (LocalSettings.instance.isFaceIndexingEnabled == false) {
|
||||
return;
|
||||
}
|
||||
canRunMLController = event.shouldRun;
|
||||
if (canRunMLController) {
|
||||
unawaited(indexAllImages());
|
||||
|
@ -332,6 +335,11 @@ class FaceMlService {
|
|||
_logger.info("clusterAllImages is already running, skipping");
|
||||
return;
|
||||
}
|
||||
// verify faces is enabled
|
||||
if (LocalSettings.instance.isFaceIndexingEnabled == false) {
|
||||
_logger.warning("clustering is disabled by user");
|
||||
return;
|
||||
}
|
||||
|
||||
final indexingCompleteRatio = await _getIndexedDoneRatio();
|
||||
if (indexingCompleteRatio < 0.6) {
|
||||
|
@ -538,7 +546,7 @@ class FaceMlService {
|
|||
_logger.warning("indexAllImages is already running, skipping");
|
||||
return;
|
||||
}
|
||||
// verify indexing is enabled
|
||||
// verify faces is enabled
|
||||
if (LocalSettings.instance.isFaceIndexingEnabled == false) {
|
||||
_logger.warning("indexing is disabled by user");
|
||||
return;
|
||||
|
|
|
@ -64,8 +64,8 @@ class _FaceDebugSectionWidgetState extends State<FaceDebugSectionWidget> {
|
|||
if (snapshot.hasData) {
|
||||
return CaptionedTextWidget(
|
||||
title: LocalSettings.instance.isFaceIndexingEnabled
|
||||
? "Disable indexing (${snapshot.data!})"
|
||||
: "Enable indexing (${snapshot.data!})",
|
||||
? "Disable faces (${snapshot.data!})"
|
||||
: "Enable faces (${snapshot.data!})",
|
||||
);
|
||||
}
|
||||
return const SizedBox.shrink();
|
||||
|
@ -78,9 +78,7 @@ class _FaceDebugSectionWidgetState extends State<FaceDebugSectionWidget> {
|
|||
try {
|
||||
final isEnabled =
|
||||
await LocalSettings.instance.toggleFaceIndexing();
|
||||
if (isEnabled) {
|
||||
FaceMlService.instance.indexAllImages().ignore();
|
||||
} else {
|
||||
if (!isEnabled) {
|
||||
FaceMlService.instance.pauseIndexing();
|
||||
}
|
||||
if (mounted) {
|
||||
|
|
|
@ -20,6 +20,7 @@ import "package:photos/ui/viewer/search_tab/file_type_section.dart";
|
|||
import "package:photos/ui/viewer/search_tab/locations_section.dart";
|
||||
import "package:photos/ui/viewer/search_tab/moments_section.dart";
|
||||
import "package:photos/ui/viewer/search_tab/people_section.dart";
|
||||
import "package:photos/utils/local_settings.dart";
|
||||
|
||||
class SearchTab extends StatefulWidget {
|
||||
const SearchTab({Key? key}) : super(key: key);
|
||||
|
@ -114,6 +115,9 @@ class _AllSearchSectionsState extends State<AllSearchSections> {
|
|||
itemBuilder: (context, index) {
|
||||
switch (searchTypes[index]) {
|
||||
case SectionType.face:
|
||||
if (!LocalSettings.instance.isFaceIndexingEnabled) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
return PeopleSection(
|
||||
examples: snapshot.data!.elementAt(index)
|
||||
as List<GenericSearchResult>,
|
||||
|
|
Loading…
Add table
Reference in a new issue