Compare commits

..

2 commits

Author SHA1 Message Date
c7842fd96c abdicate object assigning responsibility
The ImagesService itself handles the conversion of Json to the object itself, instead of the ImagesApi
2022-12-24 00:32:53 +01:00
388acfe953 live local search 2022-12-23 23:50:58 +01:00
2 changed files with 5 additions and 9 deletions

View file

@ -68,18 +68,16 @@ 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<List<ImageModel>> searchImages(
{required SearchOption searchOption,
required String imageNamePart,
bool treatAsInSequence = false}) async {
Future<List<ImageModel>> searchImages({
required SearchOption searchOption,
required String imageNamePart,
}) async {
return await _searchMutex.lockAndRun(run: (final unlock) async {
try {
switch (searchOption) {
case SearchOption.local:
final rankedKeys = _imageModels.keys
//todo(mehul): Implement atleast-matching-all-parts
.where(
(final imageName) => imageName.contains(treatAsInSequence ? imageNamePart : ''))
.where((final imageName) => imageName.contains(imageNamePart))
.toList(growable: false)
..sort((final a, final b) =>
ConstSorters.stringsSimilarityTarget(targetWord: imageNamePart, a, b));

View file

@ -64,8 +64,6 @@ class GalleryViewModel extends BaseViewModel {
.searchImages(
imageNamePart: searchTerm,
searchOption: searchOptionListenable.value,
// todo(mehul): When implemented, remove this
treatAsInSequence: true,
)
.then(
(final fetchedImageModels) => _imageSearchResultsNotifier.value = fetchedImageModels),