parent
5c031a1121
commit
2b8fec6a40
10
src/App.vue
10
src/App.vue
|
@ -71,6 +71,7 @@ import { emit, subscribe } from '@nextcloud/event-bus';
|
||||||
|
|
||||||
import * as utils from './services/Utils';
|
import * as utils from './services/Utils';
|
||||||
import * as nativex from './native';
|
import * as nativex from './native';
|
||||||
|
import staticConfig from './services/static-config';
|
||||||
import UserConfig from './mixins/UserConfig';
|
import UserConfig from './mixins/UserConfig';
|
||||||
import Timeline from './components/Timeline.vue';
|
import Timeline from './components/Timeline.vue';
|
||||||
import Settings from './components/Settings.vue';
|
import Settings from './components/Settings.vue';
|
||||||
|
@ -280,6 +281,9 @@ export default defineComponent({
|
||||||
|
|
||||||
async beforeMount() {
|
async beforeMount() {
|
||||||
if ('serviceWorker' in navigator) {
|
if ('serviceWorker' in navigator) {
|
||||||
|
// Get the config before loading
|
||||||
|
const previousVersion = staticConfig.getSync('version');
|
||||||
|
|
||||||
// Use the window load event to keep the page load performant
|
// Use the window load event to keep the page load performant
|
||||||
window.addEventListener('load', async () => {
|
window.addEventListener('load', async () => {
|
||||||
try {
|
try {
|
||||||
|
@ -288,6 +292,12 @@ export default defineComponent({
|
||||||
scope: generateUrl('/apps/memories'),
|
scope: generateUrl('/apps/memories'),
|
||||||
});
|
});
|
||||||
console.log('SW registered: ', registration);
|
console.log('SW registered: ', registration);
|
||||||
|
|
||||||
|
// Check for updates
|
||||||
|
const currentVersion = await staticConfig.get('version');
|
||||||
|
if (previousVersion !== currentVersion) {
|
||||||
|
registration.update();
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('SW registration failed: ', error);
|
console.error('SW registration failed: ', error);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,19 +36,15 @@ class StaticConfig {
|
||||||
const old = this.getDefault();
|
const old = this.getDefault();
|
||||||
if (old.version !== this.config.version) {
|
if (old.version !== this.config.version) {
|
||||||
if (old.version) {
|
if (old.version) {
|
||||||
showInfo(t('memories', 'Memories has been updated. Please reload to get the new version.'));
|
showInfo(
|
||||||
|
t('memories', 'Memories has been updated to {version}. Reload to get the new version.', {
|
||||||
|
version: this.config.version,
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear page cache, keep other caches
|
// Clear page cache, keep other caches
|
||||||
window.caches?.delete('pages');
|
window.caches?.delete('pages');
|
||||||
|
|
||||||
// Update service worker if present
|
|
||||||
navigator.serviceWorker
|
|
||||||
?.getRegistration()
|
|
||||||
.then((reg) => {
|
|
||||||
reg?.update();
|
|
||||||
})
|
|
||||||
.catch(() => {});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assign to existing default
|
// Assign to existing default
|
||||||
|
|
Loading…
Reference in New Issue