From 1295c397a2cc06a4386dc079af27ad46e36285cf Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Sun, 16 Oct 2022 13:18:47 -0700 Subject: [PATCH] Bust cache with version --- lib/Controller/PageController.php | 1 + src/services/Utils.ts | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index 3ef05f18..48aab3a9 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -69,6 +69,7 @@ class PageController extends Controller { // Apps enabled $this->initialState->provideInitialState('systemtags', $this->appManager->isEnabledForUser('systemtags') === true); $this->initialState->provideInitialState('recognize', $this->appManager->isEnabledForUser('recognize') === true); + $this->initialState->provideInitialState('version', $this->appManager->getAppInfo('memories')["version"]); $response = new TemplateResponse($this->appName, 'main'); return $response; diff --git a/src/services/Utils.ts b/src/services/Utils.ts index da379a61..ff44efe6 100644 --- a/src/services/Utils.ts +++ b/src/services/Utils.ts @@ -1,5 +1,6 @@ import { getCanonicalLocale } from "@nextcloud/l10n"; import { getCurrentUser } from '@nextcloud/auth' +import { loadState } from '@nextcloud/initial-state' import { IPhoto } from "../types"; // Memoize the result of short date conversions @@ -166,7 +167,8 @@ export const constants = { /** Cache store */ let cacheStorage: Cache | null = null; -caches.open(`memories-${getCurrentUser()!.uid}`).then((cache) => { cacheStorage = cache }); +const cacheName = `memories-${loadState('memories', 'version')}-${getCurrentUser()!.uid}`; +caches.open(cacheName).then((cache) => { cacheStorage = cache }); /** Get data from the cache */ export async function getCachedData(url: string) {