reload dashboard on version change
This commit is contained in:
+14
-4
@@ -74,10 +74,6 @@ const VIEWS = Object.freeze({
|
||||
|
||||
const offlineOverlay = useTemplateRef('offlineOverlay');
|
||||
|
||||
function onOnline() {
|
||||
ready.value = true;
|
||||
}
|
||||
|
||||
fetcher.globalOptions.errorHook = (error) => {
|
||||
// network error, request killed by browser
|
||||
if (error instanceof TypeError) {
|
||||
@@ -219,10 +215,22 @@ async function refreshProfile() {
|
||||
async function refreshConfigAndFeatures() {
|
||||
const [error, result] = await dashboardModel.config();
|
||||
if (error) return console.error(error);
|
||||
|
||||
if (result.version !== localStorage.getItem('version')) {
|
||||
console.log('Dashboard version changed, reloading');
|
||||
localStorage.setItem('version', result.version);
|
||||
window.location.reload(true);
|
||||
}
|
||||
|
||||
config.value = result;
|
||||
features.value = result.features;
|
||||
}
|
||||
|
||||
async function onOnline() {
|
||||
ready.value = true;
|
||||
await refreshConfigAndFeatures(); // reload dashboard if needed after an update
|
||||
}
|
||||
|
||||
provide('subscriptionRequiredDialog', subscriptionRequiredDialog);
|
||||
provide('features', features);
|
||||
provide('profile', profile);
|
||||
@@ -259,6 +267,8 @@ onMounted(async () => {
|
||||
window.addEventListener('hashchange', onHashChange);
|
||||
onHashChange();
|
||||
|
||||
console.log(`Cloudron dashboard v${config.value.version}`);
|
||||
|
||||
ready.value = true;
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user