[mob] Minor fix to reflect correct status for indexing

This commit is contained in:
Neeraj Gupta 2024-05-14 16:42:13 +05:30
parent d6599f178b
commit e4dcdeb030
3 changed files with 6 additions and 2 deletions

View file

@ -1,3 +1,5 @@
import "package:photos/events/event.dart";
class EmbeddingUpdatedEvent extends Event {}
class EmbeddingCacheUpdatedEvent extends Event {}

View file

@ -190,6 +190,7 @@ class SemanticSearchService {
_logger.info(
"Loading ${_cachedEmbeddings.length} took: ${(endTime.millisecondsSinceEpoch - startTime.millisecondsSinceEpoch)}ms",
);
Bus.instance.fire(EmbeddingCacheUpdatedEvent());
_logger.info("Cached embeddings: " + _cachedEmbeddings.length.toString());
}
@ -227,6 +228,7 @@ class SemanticSearchService {
.getOwnedFileIDs(Configuration.instance.getUserID()!);
final embeddedFileIDs =
await EmbeddingsDB.instance.getFileIDs(_currentModel);
uploadedFileIDs.removeWhere(
(id) => embeddedFileIDs.contains(id),
);

View file

@ -228,13 +228,13 @@ class MagicSearchIndexStatsWidget extends StatefulWidget {
class _MagicSearchIndexStatsWidgetState
extends State<MagicSearchIndexStatsWidget> {
IndexStatus? _status;
late StreamSubscription<EmbeddingUpdatedEvent> _eventSubscription;
late StreamSubscription<EmbeddingCacheUpdatedEvent> _eventSubscription;
@override
void initState() {
super.initState();
_eventSubscription =
Bus.instance.on<EmbeddingUpdatedEvent>().listen((event) {
Bus.instance.on<EmbeddingCacheUpdatedEvent>().listen((event) {
_fetchIndexStatus();
});
_fetchIndexStatus();