Compare commits
2 commits
c7842fd96c
...
d3a8a401c4
Author | SHA1 | Date | |
---|---|---|---|
d3a8a401c4 | |||
64ed6ae1ac |
2 changed files with 9 additions and 5 deletions
|
@ -68,16 +68,18 @@ class ImagesService {
|
||||||
/// There are lots of optimizations possible for new inputs, for example reducing search frontier
|
/// 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,
|
/// by using set-cover/subsetting optimizations on backspace, and so on, but again, not the point,
|
||||||
/// I think.
|
/// I think.
|
||||||
Future<List<ImageModel>> searchImages({
|
Future<List<ImageModel>> searchImages(
|
||||||
required SearchOption searchOption,
|
{required SearchOption searchOption,
|
||||||
required String imageNamePart,
|
required String imageNamePart,
|
||||||
}) async {
|
bool treatAsInSequence = false}) async {
|
||||||
return await _searchMutex.lockAndRun(run: (final unlock) async {
|
return await _searchMutex.lockAndRun(run: (final unlock) async {
|
||||||
try {
|
try {
|
||||||
switch (searchOption) {
|
switch (searchOption) {
|
||||||
case SearchOption.local:
|
case SearchOption.local:
|
||||||
final rankedKeys = _imageModels.keys
|
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)
|
.toList(growable: false)
|
||||||
..sort((final a, final b) =>
|
..sort((final a, final b) =>
|
||||||
ConstSorters.stringsSimilarityTarget(targetWord: imageNamePart, a, b));
|
ConstSorters.stringsSimilarityTarget(targetWord: imageNamePart, a, b));
|
||||||
|
|
|
@ -64,6 +64,8 @@ class GalleryViewModel extends BaseViewModel {
|
||||||
.searchImages(
|
.searchImages(
|
||||||
imageNamePart: searchTerm,
|
imageNamePart: searchTerm,
|
||||||
searchOption: searchOptionListenable.value,
|
searchOption: searchOptionListenable.value,
|
||||||
|
// todo(mehul): When implemented, remove this
|
||||||
|
treatAsInSequence: true,
|
||||||
)
|
)
|
||||||
.then(
|
.then(
|
||||||
(final fetchedImageModels) => _imageSearchResultsNotifier.value = fetchedImageModels),
|
(final fetchedImageModels) => _imageSearchResultsNotifier.value = fetchedImageModels),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue