[mob][photos] SemanticSearchService minor changes

This commit is contained in:
laurenspriem
2024-07-05 13:26:26 +05:30
parent f95331c8f5
commit 9232cd150b

View File

@@ -61,6 +61,7 @@ class SemanticSearchService {
await EmbeddingsDB.instance.init();
await _loadImageEmbeddings();
Bus.instance.on<EmbeddingUpdatedEvent>().listen((event) {
if (!_hasInitialized) return;
_embeddingLoaderDebouncer.run(() async {
await _loadImageEmbeddings();
});
@@ -74,6 +75,13 @@ class SemanticSearchService {
});
}
Future<void> dispose() async {
if (!_hasInitialized) return;
_hasInitialized = false;
await ClipTextEncoder.instance.release();
_cachedImageEmbeddings.clear();
}
Future<void> sync() async {
if (_isSyncing) {
return;
@@ -90,6 +98,11 @@ class SemanticSearchService {
_cachedImageEmbeddings.isNotEmpty;
}
bool bothClipModelsLoaded() {
return ClipImageEncoder.instance.isInitialized &&
ClipTextEncoder.instance.isInitialized;
}
// searchScreenQuery should only be used for the user initiate query on the search screen.
// If there are multiple call tho this method, then for all the calls, the result will be the same as the last query.
Future<(String, List<EnteFile>)> searchScreenQuery(String query) async {