Skip to content

armgit / ente

Public Imported from GitHub
0

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

Display index status within the UI

vishnukvmd4ea80d391ba3
diff --git a/lib/generated/intl/messages_en.dart b/lib/generated/intl/messages_en.dart
index 9348ae18c9..272725c8b8 100644
--- a/lib/generated/intl/messages_en.dart
+++ b/lib/generated/intl/messages_en.dart
@@ -716,6 +716,7 @@ class MessageLookup extends MessageLookupByLibrary {
"The recovery key you entered is incorrect"),
"incorrectRecoveryKeyTitle":
MessageLookupByLibrary.simpleMessage("Incorrect recovery key"),
+ "indexedItems": MessageLookupByLibrary.simpleMessage("Indexed items"),
"insecureDevice":
MessageLookupByLibrary.simpleMessage("Insecure device"),
"installManually":
@@ -901,6 +902,7 @@ class MessageLookup extends MessageLookupByLibrary {
"paymentFailed": MessageLookupByLibrary.simpleMessage("Payment failed"),
"paymentFailedTalkToProvider": m33,
"paymentFailedWithReason": m34,
+ "pendingItems": MessageLookupByLibrary.simpleMessage("Pending items"),
"pendingSync": MessageLookupByLibrary.simpleMessage("Pending sync"),
"peopleUsingYourCode":
MessageLookupByLibrary.simpleMessage("People using your code"),
@@ -1187,6 +1189,7 @@ class MessageLookup extends MessageLookupByLibrary {
"sortOldestFirst": MessageLookupByLibrary.simpleMessage("Oldest first"),
"sparkleSuccess": MessageLookupByLibrary.simpleMessage("✨ Success"),
"startBackup": MessageLookupByLibrary.simpleMessage("Start backup"),
+ "status": MessageLookupByLibrary.simpleMessage("Status"),
"storage": MessageLookupByLibrary.simpleMessage("Storage"),
"storageBreakupFamily": MessageLookupByLibrary.simpleMessage("Family"),
"storageBreakupYou": MessageLookupByLibrary.simpleMessage("You"),
diff --git a/lib/generated/l10n.dart b/lib/generated/l10n.dart
index c732cc098e..ae9e3101c5 100644
--- a/lib/generated/l10n.dart
+++ b/lib/generated/l10n.dart
@@ -2887,6 +2887,36 @@ class S {
);
}
+ /// `Status`
+ String get status {
+ return Intl.message(
+ 'Status',
+ name: 'status',
+ desc: '',
+ args: [],
+ );
+ }
+
+ /// `Indexed items`
+ String get indexedItems {
+ return Intl.message(
+ 'Indexed items',
+ name: 'indexedItems',
+ desc: '',
+ args: [],
+ );
+ }
+
+ /// `Pending items`
+ String get pendingItems {
+ return Intl.message(
+ 'Pending items',
+ name: 'pendingItems',
+ desc: '',
+ args: [],
+ );
+ }
+
/// `Select folders for backup`
String get selectFoldersForBackup {
return Intl.message(
diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb
index bfabb401cc..f44f70dbfe 100644
--- a/lib/l10n/intl_en.arb
+++ b/lib/l10n/intl_en.arb
@@ -409,6 +409,9 @@
"machineLearning": "Machine learning",
"magicSearch": "Magic search",
"magicSearchDescription": "Please note that this will result in a higher bandwidth and battery usage until all items are indexed.",
+ "status": "Status",
+ "indexedItems": "Indexed items",
+ "pendingItems": "Pending items",
"selectFoldersForBackup": "Select folders for backup",
"selectedFoldersWillBeEncryptedAndBackedUp": "Selected folders will be encrypted and backed up",
"unselectAll": "Unselect all",
diff --git a/lib/services/semantic_search/embedding_store.dart b/lib/services/semantic_search/embedding_store.dart
index d38dc68ebc..fabb9712b3 100644
--- a/lib/services/semantic_search/embedding_store.dart
+++ b/lib/services/semantic_search/embedding_store.dart
@@ -52,10 +52,11 @@ class EmbeddingStore {
Future<void> storeEmbedding(EnteFile file, Embedding embedding) async {
await FilesDB.instance.upsertEmbedding(embedding);
- await _pushEmbedding(file, embedding);
+ _pushEmbedding(file, embedding);
}
Future<void> _pushEmbedding(EnteFile file, Embedding embedding) async {
+ return;
final encryptionKey = getFileKey(file);
final embeddingData =
Uint8List.view(Float64List.fromList(embedding.embedding).buffer);
diff --git a/lib/ui/settings/machine_learning_settings_page.dart b/lib/ui/settings/machine_learning_settings_page.dart
index ac1f31096a..c731c150d9 100644
--- a/lib/ui/settings/machine_learning_settings_page.dart
+++ b/lib/ui/settings/machine_learning_settings_page.dart
@@ -1,21 +1,35 @@
+import "dart:async";
+
import "package:flutter/material.dart";
+import "package:intl/intl.dart";
+import "package:photos/core/event_bus.dart";
+import "package:photos/events/file_indexed_event.dart";
import "package:photos/generated/l10n.dart";
+import "package:photos/services/semantic_search/semantic_search_service.dart";
import "package:photos/theme/ente_theme.dart";
+import "package:photos/ui/common/loading_widget.dart";
import "package:photos/ui/components/buttons/icon_button_widget.dart";
import "package:photos/ui/components/captioned_text_widget.dart";
import "package:photos/ui/components/menu_item_widget/menu_item_widget.dart";
import "package:photos/ui/components/menu_section_description_widget.dart";
+import "package:photos/ui/components/menu_section_title.dart";
import "package:photos/ui/components/title_bar_title_widget.dart";
import "package:photos/ui/components/title_bar_widget.dart";
import "package:photos/ui/components/toggle_switch_widget.dart";
import "package:photos/utils/local_settings.dart";
-class MachineLearningSettingsPage extends StatelessWidget {
+class MachineLearningSettingsPage extends StatefulWidget {
const MachineLearningSettingsPage({super.key});
+ @override
+ State<MachineLearningSettingsPage> createState() =>
+ _MachineLearningSettingsPageState();
+}
+
+class _MachineLearningSettingsPageState
+ extends State<MachineLearningSettingsPage> {
@override
Widget build(BuildContext context) {
- final colorScheme = getEnteColorScheme(context);
return Scaffold(
body: CustomScrollView(
primary: false,
@@ -46,37 +60,7 @@ class MachineLearningSettingsPage extends StatelessWidget {
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
- Column(
- children: [
- Column(
- children: [
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: S.of(context).magicSearch,
- ),
- menuItemColor: colorScheme.fillFaint,
- trailingWidget: ToggleSwitchWidget(
- value: () => LocalSettings.instance
- .hasEnabledMagicSearch(),
- onChanged: () {
- return LocalSettings.instance
- .setShouldEnableMagicSearch(
- !LocalSettings.instance
- .hasEnabledMagicSearch(),
- );
- },
- ),
- singleBorderRadius: 8,
- alignCaptionedTextToLeft: true,
- isGestureDetectorDisabled: true,
- ),
- MenuSectionDescriptionWidget(
- content: S.of(context).magicSearchDescription,
- ),
- ],
- ),
- ],
- ),
+ _getMagicSearchSettings(context),
],
),
),
@@ -89,4 +73,126 @@ class MachineLearningSettingsPage extends StatelessWidget {
),
);
}
+
+ Widget _getMagicSearchSettings(BuildContext context) {
+ final colorScheme = getEnteColorScheme(context);
+ final hasEnabled = LocalSettings.instance.hasEnabledMagicSearch();
+ return Column(
+ children: [
+ MenuItemWidget(
+ captionedTextWidget: CaptionedTextWidget(
+ title: S.of(context).magicSearch,
+ ),
+ menuItemColor: colorScheme.fillFaint,
+ trailingWidget: ToggleSwitchWidget(
+ value: () => LocalSettings.instance.hasEnabledMagicSearch(),
+ onChanged: () async {
+ await LocalSettings.instance.setShouldEnableMagicSearch(
+ !LocalSettings.instance.hasEnabledMagicSearch(),
+ );
+ if (LocalSettings.instance.hasEnabledMagicSearch()) {
+ await SemanticSearchService.instance.startBackFill();
+ }
+ setState(() {});
+ },
+ ),
+ singleBorderRadius: 8,
+ alignCaptionedTextToLeft: true,
+ isGestureDetectorDisabled: true,
+ ),
+ const SizedBox(
+ height: 4,
+ ),
+ MenuSectionDescriptionWidget(
+ content: S.of(context).magicSearchDescription,
+ ),
+ const SizedBox(
+ height: 12,
+ ),
+ hasEnabled
+ ? const MagicSearchIndexStatsWidget()
+ : const SizedBox.shrink(),
+ ],
+ );
+ }
+}
+
+class MagicSearchIndexStatsWidget extends StatefulWidget {
+ const MagicSearchIndexStatsWidget({
+ super.key,
+ });
+
+ @override
+ State<MagicSearchIndexStatsWidget> createState() =>
+ _MagicSearchIndexStatsWidgetState();
+}
+
+class _MagicSearchIndexStatsWidgetState
+ extends State<MagicSearchIndexStatsWidget> {
+ IndexStatus? _status;
+ late StreamSubscription<FileIndexedEvent> _eventSubscription;
+
+ @override
+ void initState() {
+ super.initState();
+ _eventSubscription = Bus.instance.on<FileIndexedEvent>().listen((event) {
+ _fetchIndexStatus();
+ });
+ _fetchIndexStatus();
+ }
+
+ void _fetchIndexStatus() {
+ SemanticSearchService.instance.getIndexStatus().then((status) {
+ _status = status;
+ setState(() {});
+ });
+ }
+
+ @override
+ void dispose() {
+ super.dispose();
+ _eventSubscription.cancel();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ if (_status == null) {
+ return const EnteLoadingWidget();
+ }
+ return Column(
+ children: [
+ MenuSectionTitle(title: S.of(context).status),
+ MenuItemWidget(
+ captionedTextWidget: CaptionedTextWidget(
+ title: S.of(context).indexedItems,
+ ),
+ trailingWidget: Text(
+ NumberFormat().format(_status!.indexedItems),
+ style: Theme.of(context).textTheme.bodySmall,
+ ),
+ // menuItemColor: colorScheme.fillFaint,
+ singleBorderRadius: 8,
+ alignCaptionedTextToLeft: true,
+ isGestureDetectorDisabled: true,
+ // Setting a key here to ensure trailingWidget is refreshed
+ key: ValueKey("indexed_items_" + _status!.indexedItems.toString()),
+ ),
+ MenuItemWidget(
+ captionedTextWidget: CaptionedTextWidget(
+ title: S.of(context).pendingItems,
+ ),
+ trailingWidget: Text(
+ NumberFormat().format(_status!.pendingItems),
+ style: Theme.of(context).textTheme.bodySmall,
+ ),
+ // menuItemColor: colorScheme.fillFaint,
+ singleBorderRadius: 8,
+ alignCaptionedTextToLeft: true,
+ isGestureDetectorDisabled: true,
+ // Setting a key here to ensure trailingWidget is refreshed
+ key: ValueKey("pending_items_" + _status!.pendingItems.toString()),
+ ),
+ ],
+ );
+ }
}