diff --git a/src/common/SearchQueryParser.ts b/src/common/SearchQueryParser.ts index 84c78d3b..1bb22edf 100644 --- a/src/common/SearchQueryParser.ts +++ b/src/common/SearchQueryParser.ts @@ -173,7 +173,11 @@ export class SearchQueryParser { const intFromRegexp = (str: string) => { - return parseInt(new RegExp(/\d+/).exec(str)[0], 10); + const numSTR = new RegExp(/\d+/).exec(str); + if (!numSTR) { + return 0; + } + return parseInt(numSTR[0], 10); }; if (str.charAt(0) === '(' && str.charAt(str.length - 1) === ')') { str = str.slice(1, str.length - 1); diff --git a/src/common/entities/ConentWrapper.ts b/src/common/entities/ConentWrapper.ts index 25c34767..cde723d1 100644 --- a/src/common/entities/ConentWrapper.ts +++ b/src/common/entities/ConentWrapper.ts @@ -9,14 +9,14 @@ import {PhotoDTO} from './PhotoDTO'; export class ContentWrapper { - private map: { + private map?: { faces: string[], keywords: string[], lens: string[], camera: string[], directories: DirectoryPathDTO[] }; - private reverseMap: { + private reverseMap?: { faces: Map, keywords: Map, lens: Map, @@ -25,7 +25,7 @@ export class ContentWrapper { }; public directory: ParentDirectoryDTO; public searchResult: SearchResultDTO; - public notModified: boolean; + public notModified?: boolean; constructor( directory: ParentDirectoryDTO = null, diff --git a/src/frontend/app/ui/gallery/contentLoader.service.ts b/src/frontend/app/ui/gallery/contentLoader.service.ts index 9c01cd99..80367ea2 100644 --- a/src/frontend/app/ui/gallery/contentLoader.service.ts +++ b/src/frontend/app/ui/gallery/contentLoader.service.ts @@ -111,10 +111,14 @@ export class ContentLoaderService { cw = await this.networkService.getJson('/search/' + query); this.galleryCacheService.setSearch(cw); } catch (e) { + cw = cw || { + directory: null, + searchResult: null + }; if (e.code === ErrorCodes.LocationLookUp_ERROR) { - cw.error = 'Cannot find location: ' + e.message; + cw.error = $localize`Cannot find location` + ': ' + e.message; } else { - throw e; + cw.error = $localize`Unknown server error` + ': ' + e.message; } } } diff --git a/src/frontend/app/ui/gallery/gallery.component.ts b/src/frontend/app/ui/gallery/gallery.component.ts index 2ae046f1..8586bcd9 100644 --- a/src/frontend/app/ui/gallery/gallery.component.ts +++ b/src/frontend/app/ui/gallery/gallery.component.ts @@ -13,12 +13,11 @@ import {PhotoDTO} from '../../../../common/entities/PhotoDTO'; import {QueryParams} from '../../../../common/QueryParams'; import {take} from 'rxjs/operators'; import {GallerySortingService, GroupedDirectoryContent} from './navigator/sorting.service'; -import {MediaDTO} from '../../../../common/entities/MediaDTO'; import {FilterService} from './filter/filter.service'; import {PiTitleService} from '../../model/pi-title.service'; import {GPXFilesFilterPipe} from '../../pipes/GPXFilesFilterPipe'; import {MDFilesFilterPipe} from '../../pipes/MDFilesFilterPipe'; -import { ContentLoaderService,ContentWrapperWithError } from './contentLoader.service'; +import {ContentLoaderService, ContentWrapperWithError} from './contentLoader.service'; @Component({ selector: 'app-gallery',