mirror of
https://github.com/actualbudget/actual.git
synced 2026-03-21 15:36:50 -05:00
🐛 Fix to show the notification for updating service worker (#5963)
* Fix to show the notification for updating service worker * cleanup * Add release notes for PR #5963 * trigger pipeline --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
@@ -9,7 +9,6 @@ rm -fr build
|
||||
|
||||
export IS_GENERIC_BROWSER=1
|
||||
export REACT_APP_BACKEND_WORKER_HASH=`ls "$ROOT"/../public/kcab/kcab.worker.*.js | sed 's/.*kcab\.worker\.\(.*\)\.js/\1/'`
|
||||
export REACT_APP_PLUGIN_SERVICE_WORKER_HASH=`ls "$ROOT"/../service-worker/plugin-sw.*.js | sed 's/.*plugin-sw\.\(.*\)\.js/\1/'`
|
||||
|
||||
yarn build
|
||||
|
||||
|
||||
@@ -6,6 +6,5 @@ cd "$ROOT/.."
|
||||
export IS_GENERIC_BROWSER=1
|
||||
export PORT=3001
|
||||
export REACT_APP_BACKEND_WORKER_HASH="dev"
|
||||
export REACT_APP_PLUGIN_SERVICE_WORKER_HASH="dev"
|
||||
|
||||
yarn start
|
||||
|
||||
@@ -26,15 +26,6 @@ const addWatchers = (): Plugin => ({
|
||||
},
|
||||
});
|
||||
|
||||
// Get service worker filename from environment variable
|
||||
function getServiceWorkerFilename(): string {
|
||||
const hash = process.env.REACT_APP_PLUGIN_SERVICE_WORKER_HASH;
|
||||
if (hash) {
|
||||
return `plugin-sw.${hash}.js`;
|
||||
}
|
||||
return 'plugin-sw.js'; // fallback
|
||||
}
|
||||
|
||||
// Inject build shims using the inject plugin
|
||||
const injectShims = (): Plugin[] => {
|
||||
const buildShims = path.resolve('./src/build-shims.js');
|
||||
@@ -170,7 +161,7 @@ export default defineConfig(async ({ mode }) => {
|
||||
registerType: 'prompt',
|
||||
strategies: 'injectManifest',
|
||||
srcDir: 'service-worker',
|
||||
filename: getServiceWorkerFilename(),
|
||||
filename: 'plugin-sw.js',
|
||||
manifest: {
|
||||
name: 'Actual',
|
||||
short_name: 'Actual',
|
||||
@@ -182,7 +173,7 @@ export default defineConfig(async ({ mode }) => {
|
||||
},
|
||||
injectManifest: {
|
||||
maximumFileSizeToCacheInBytes: 10 * 1024 * 1024, // 10MB
|
||||
swSrc: `service-worker/${getServiceWorkerFilename()}`,
|
||||
swSrc: `service-worker/plugin-sw.js`,
|
||||
},
|
||||
devOptions: {
|
||||
enabled: true, // We need service worker in dev mode to work with plugins
|
||||
|
||||
@@ -28,7 +28,6 @@ const fileList = new Map<string, string>();
|
||||
// Log installation event
|
||||
self.addEventListener('install', (_event: ExtendableEvent) => {
|
||||
console.log('Plugins Worker installing...');
|
||||
self.skipWaiting(); // Forces activation immediately
|
||||
});
|
||||
|
||||
// Log activation event
|
||||
@@ -64,6 +63,8 @@ self.addEventListener('fetch', (event: FetchEvent) => {
|
||||
? pathSegments[slugIndex + 1].split('?')[0]
|
||||
: '';
|
||||
event.respondWith(handlePlugin(slug, fileName.replace('?import', '')));
|
||||
} else {
|
||||
event.respondWith(fetch(event.request));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ import { defineConfig } from 'vite';
|
||||
export default defineConfig(({ mode }) => {
|
||||
const isDev = mode === 'development';
|
||||
const outDir = path.resolve(__dirname, 'dist');
|
||||
const buildHash = Date.now().toString(36);
|
||||
|
||||
return {
|
||||
mode,
|
||||
@@ -18,8 +17,7 @@ export default defineConfig(({ mode }) => {
|
||||
entry: path.resolve(__dirname, 'src/plugin-service-worker.ts'),
|
||||
name: 'plugin_sw',
|
||||
formats: ['iife'],
|
||||
fileName: () =>
|
||||
isDev ? `plugin-sw.dev.js` : `plugin-sw.${buildHash}.js`,
|
||||
fileName: () => `plugin-sw.js`,
|
||||
},
|
||||
sourcemap: true,
|
||||
minify: isDev ? false : 'terser',
|
||||
|
||||
7
upcoming-release-notes/5963.md
Normal file
7
upcoming-release-notes/5963.md
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
category: Bugfix
|
||||
authors: [lelemm]
|
||||
---
|
||||
|
||||
Fix notification display for updating the service worker in the application.
|
||||
|
||||
Reference in New Issue
Block a user