Skip to content

Commit

Permalink
fix: fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Lipraty committed Oct 30, 2023
1 parent cb9dfcc commit 692a518
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/local/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class LocalImageSource extends ImageSource<LocalImageSource.Config> {
if (this.imageMap.length < 1) return undefined
let pickPool = [];
// Flatten all maps
if (this.imageMap.length === 1) {
if (this.imageMap.length > 1) {
for (const storage of this.imageMap) {
if (query.tags.length > 0) {
// filter by tags
Expand All @@ -124,6 +124,7 @@ class LocalImageSource extends ImageSource<LocalImageSource.Config> {
}
}
} else {
// pick from one image map
pickPool = this.imageMap.map((storage) => {
if (query.tags.length > 0) {
// filter by tags
Expand All @@ -132,7 +133,7 @@ class LocalImageSource extends ImageSource<LocalImageSource.Config> {
// pick from all images
return storage.images
}
})
}).flat()
}
const picker = Random.pick(pickPool, query.count)
return picker.map(img => {
Expand Down

0 comments on commit 692a518

Please sign in to comment.