Skip to content

Commit

Permalink
refactor: cleaner expression; a more clear error message
Browse files Browse the repository at this point in the history
  • Loading branch information
sherwinski authored and sherwinski committed Nov 15, 2021
1 parent 28a272d commit 7295767
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
10 changes: 4 additions & 6 deletions src/components/Dialog/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,10 @@ export default class Dialog extends Component<DialogProps, DialogState> {
// if selected source, return images
if (Object.keys(this.state.selectedSource).length) {
const defaultQuery = `?page[number]=${this.state.page.currentIndex}&page[size]=18`;
let images;
if (query) {
images = await this.getImagePaths(query, noSearchImagesError());
} else {
images = await this.getImagePaths(defaultQuery, noOriginImagesError());
}

const images = query
? await this.getImagePaths(query, noSearchImagesError())
: await this.getImagePaths(defaultQuery, noOriginImagesError());

if (images.length > 0 && this.state.errors.length > 0) {
this.resetNErrors(this.state.errors.length);
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const ERROR_MESSAGES = {
type: 'warning',
},
noSearchImagesError: {
message: `Consider trying to search by something else.`,
message: `Consider trying to search for something else.`,
name: 'No results found',
type: 'warning',
}
Expand Down

0 comments on commit 7295767

Please sign in to comment.