diff --git a/src/frontend/apps/impress/src/features/docs/doc-versioning/components/VersionList.tsx b/src/frontend/apps/impress/src/features/docs/doc-versioning/components/VersionList.tsx index 96c176b7..ca574110 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-versioning/components/VersionList.tsx +++ b/src/frontend/apps/impress/src/features/docs/doc-versioning/components/VersionList.tsx @@ -65,7 +65,7 @@ const VersionListState = ({ {error && ( { */ registerRoute( ({ url }) => - isApiUrl(url.href) && url.href.match(/.*\/documents\/\?(page|ordering)=.*/), + isApiUrl(url.href) && + url.href.match(/.*\/documents\/\?(page|ordering)=.*/g), new NetworkOnly({ plugins: [ new ApiPlugin({ @@ -42,7 +43,8 @@ registerRoute( ); registerRoute( - ({ url }) => isApiUrl(url.href) && url.href.match(/.*\/documents\/.*\//), + ({ url }) => + isApiUrl(url.href) && url.href.match(/.*\/documents\/([a-z0-9\-]+)\/$/g), new NetworkOnly({ plugins: [ new ApiPlugin({ @@ -56,7 +58,8 @@ registerRoute( ); registerRoute( - ({ url }) => isApiUrl(url.href) && url.href.match(/.*\/documents\/.*\//), + ({ url }) => + isApiUrl(url.href) && url.href.match(/.*\/documents\/([a-z0-9\-]+)\/$/g), new NetworkOnly({ plugins: [ new ApiPlugin({ @@ -69,7 +72,7 @@ registerRoute( ); registerRoute( - ({ url }) => isApiUrl(url.href) && url.href.match(/.*\/documents\//), + ({ url }) => isApiUrl(url.href) && url.href.match(/.*\/documents\/$/g), new NetworkOnly({ plugins: [ new ApiPlugin({ @@ -82,7 +85,8 @@ registerRoute( ); registerRoute( - ({ url }) => isApiUrl(url.href) && url.href.match(/.*\/documents\/.*\//), + ({ url }) => + isApiUrl(url.href) && url.href.match(/.*\/documents\/([a-z0-9\-]+)\/$/g), new NetworkOnly({ plugins: [ new ApiPlugin({ @@ -103,6 +107,10 @@ registerRoute( new ExpirationPlugin({ maxAgeSeconds: 24 * 60 * 60 * DAYS_EXP, }), + new ApiPlugin({ + type: 'synch', + syncManager, + }), ], }), 'GET', diff --git a/src/frontend/apps/impress/src/features/service-worker/service-worker.ts b/src/frontend/apps/impress/src/features/service-worker/service-worker.ts index c992aa8e..94b9c37c 100644 --- a/src/frontend/apps/impress/src/features/service-worker/service-worker.ts +++ b/src/frontend/apps/impress/src/features/service-worker/service-worker.ts @@ -87,6 +87,7 @@ self.addEventListener('activate', function (event) { const FALLBACK = { offline: '/offline/', docs: '/docs/[id]/', + versions: '/docs/[id]/versions/[versionId]/', images: '/assets/img-not-found.svg', }; const precacheResources = [ @@ -99,6 +100,7 @@ const precacheResources = [ FALLBACK.offline, FALLBACK.images, FALLBACK.docs, + FALLBACK.versions, ]; const precacheStrategy = getStrategy({ @@ -117,8 +119,14 @@ setCatchHandler(async ({ request, url, event }) => { return ApiPlugin.getApiCatchHandler(); case request.destination === 'document': - if (url.pathname.match(/^\/docs\/.*\//)) { + if (url.pathname.match(/^\/docs\/([a-z0-9\-]+)\/$/g)) { return precacheStrategy.handle({ event, request: FALLBACK.docs }); + } else if ( + url.pathname.match( + /^\/docs\/([a-z0-9\-]+)\/versions\/([a-z0-9\-]+)\/$/g, + ) + ) { + return precacheStrategy.handle({ event, request: FALLBACK.versions }); } return precacheStrategy.handle({ event, request: FALLBACK.offline });