diff --git a/package-lock.json b/package-lock.json index d77084c8..a10857dc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "pigallery2", - "version": "1.8.6", + "version": "1.8.7", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/src/frontend/app/ui/gallery/cache.gallery.service.ts b/src/frontend/app/ui/gallery/cache.gallery.service.ts index f6d19f81..12b40843 100644 --- a/src/frontend/app/ui/gallery/cache.gallery.service.ts +++ b/src/frontend/app/ui/gallery/cache.gallery.service.ts @@ -14,6 +14,7 @@ interface CacheItem { item: T; } + @Injectable() export class GalleryCacheService { @@ -25,6 +26,12 @@ export class GalleryCacheService { private static readonly VERSION = 'version'; constructor(private versionService: VersionService) { + + // if it was a forced reload not a navigation, clear cache + if (GalleryCacheService.wasAReload()) { + GalleryCacheService.deleteCache(); + } + const onNewVersion = (ver: string) => { if (ver !== null && localStorage.getItem(GalleryCacheService.VERSION) !== ver) { @@ -36,6 +43,11 @@ export class GalleryCacheService { onNewVersion(this.versionService.version.value); } + private static wasAReload(): boolean { + const perfEntries = performance.getEntriesByType('navigation') as PerformanceNavigationTiming []; + return perfEntries && perfEntries[0] && perfEntries[0].type === 'reload'; + } + private static loadCacheItem(key: string): SearchResultDTO { const tmp = localStorage.getItem(key); if (tmp != null) {