diff --git a/lib/features/home/services/images_service.dart b/lib/features/home/services/images_service.dart index 20deb8c..9a1fda7 100644 --- a/lib/features/home/services/images_service.dart +++ b/lib/features/home/services/images_service.dart @@ -68,16 +68,18 @@ class ImagesService { /// There are lots of optimizations possible for new inputs, for example reducing search frontier /// by using set-cover/subsetting optimizations on backspace, and so on, but again, not the point, /// I think. - Future> searchImages({ - required SearchOption searchOption, - required String imageNamePart, - }) async { + Future> searchImages( + {required SearchOption searchOption, + required String imageNamePart, + bool treatAsInSequence = false}) async { return await _searchMutex.lockAndRun(run: (final unlock) async { try { switch (searchOption) { case SearchOption.local: final rankedKeys = _imageModels.keys - .where((final imageName) => imageName.contains(imageNamePart)) + //todo(mehul): Implement atleast-matching-all-parts + .where( + (final imageName) => imageName.contains(treatAsInSequence ? imageNamePart : '')) .toList(growable: false) ..sort((final a, final b) => ConstSorters.stringsSimilarityTarget(targetWord: imageNamePart, a, b)); diff --git a/lib/features/home/views/gallery/gallery_view_model.dart b/lib/features/home/views/gallery/gallery_view_model.dart index 5de2262..ac15c37 100644 --- a/lib/features/home/views/gallery/gallery_view_model.dart +++ b/lib/features/home/views/gallery/gallery_view_model.dart @@ -64,6 +64,8 @@ class GalleryViewModel extends BaseViewModel { .searchImages( imageNamePart: searchTerm, searchOption: searchOptionListenable.value, + // todo(mehul): When implemented, remove this + treatAsInSequence: true, ) .then( (final fetchedImageModels) => _imageSearchResultsNotifier.value = fetchedImageModels),