1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2024-12-23 01:27:14 +02:00

Fixing search caching bug

This commit is contained in:
Patrik J. Braun 2023-03-05 23:45:00 +01:00
parent 6c4670daa7
commit 335033dde8
2 changed files with 6 additions and 3 deletions

View File

@ -183,6 +183,9 @@ export class GalleryCacheService {
if (Config.Gallery.enableCache === false) {
return null;
}
if (typeof query === 'string') {
throw new Error('query expected to by object. Got:' + query);
}
const key = GalleryCacheService.SEARCH_PREFIX + JSON.stringify(query);
return GalleryCacheService.loadCacheItem(key);
}

View File

@ -26,7 +26,7 @@ export class ContentService {
};
private lastDirectory: ParentDirectoryDTO;
private searchId: any;
private ongoingSearch: SearchQueryDTO = null;
private ongoingSearch: string = null;
constructor(
private networkService: NetworkService,
@ -102,7 +102,7 @@ export class ContentService {
}
}
public async search(query: SearchQueryDTO): Promise<void> {
public async search(query: string): Promise<void> {
if (this.searchId != null) {
clearTimeout(this.searchId);
}
@ -110,7 +110,7 @@ export class ContentService {
this.ongoingSearch = query;
this.setContent(new ContentWrapperWithError());
let cw = this.galleryCacheService.getSearch(query);
let cw = this.galleryCacheService.getSearch(JSON.parse(query));
if (!cw || cw.searchResult == null) {
try {
cw = await this.networkService.getJson<ContentWrapperWithError>('/search/' + query);