summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2022-10-14 01:16:27 +0800
committerGitHub <noreply@github.com>2022-10-14 01:16:27 +0800
commitf40833d1f0a9e3269d31090eae8fcb101fa1318c (patch)
treee63faa2ed92da86e7257b310358c3fe6811d4938
parent0e58201d1a8247561809d832eb8f576e05e5d26d (diff)
downloadgitea-f40833d1f0a9e3269d31090eae8fcb101fa1318c.tar.gz
gitea-f40833d1f0a9e3269d31090eae8fcb101fa1318c.zip
Remove useless `appVer` from JS `window.config` (#21445)
The only usage of `appVer` was in serviceworker.js, while indeed it needs the asset version.
-rw-r--r--templates/base/head_script.tmpl1
-rw-r--r--web_src/js/features/serviceworker.js4
2 files changed, 2 insertions, 3 deletions
diff --git a/templates/base/head_script.tmpl b/templates/base/head_script.tmpl
index 8369b63b35..c4ac18a86e 100644
--- a/templates/base/head_script.tmpl
+++ b/templates/base/head_script.tmpl
@@ -6,7 +6,6 @@ If you introduce mistakes in it, Gitea JavaScript code wouldn't run correctly.
<script>
window.addEventListener('error', function(e) {window._globalHandlerErrors=window._globalHandlerErrors||[]; window._globalHandlerErrors.push(e);});
window.config = {
- appVer: '{{AppVer}}',
appUrl: '{{AppUrl}}',
appSubUrl: '{{AppSubUrl}}',
assetVersionEncoded: encodeURIComponent('{{AssetVersion}}'), // will be used in URL construction directly
diff --git a/web_src/js/features/serviceworker.js b/web_src/js/features/serviceworker.js
index 23d68bced0..a072811b04 100644
--- a/web_src/js/features/serviceworker.js
+++ b/web_src/js/features/serviceworker.js
@@ -1,6 +1,6 @@
import {joinPaths, parseUrl} from '../utils.js';
-const {useServiceWorker, assetUrlPrefix, appVer, assetVersionEncoded} = window.config;
+const {useServiceWorker, assetUrlPrefix, assetVersionEncoded} = window.config;
const cachePrefix = 'static-cache-v'; // actual version is set in the service worker script
const workerUrl = `${joinPaths(assetUrlPrefix, 'serviceworker.js')}?v=${assetVersionEncoded}`;
@@ -25,7 +25,7 @@ async function invalidateCache() {
}
async function checkCacheValidity() {
- const cacheKey = appVer;
+ const cacheKey = assetVersionEncoded;
const storedCacheKey = localStorage.getItem('staticCacheKey');
// invalidate cache if it belongs to a different gitea version