reload dashboard on version change

This commit is contained in:
Girish Ramakrishnan
2025-10-15 13:37:37 +02:00
parent eb7d7a2d1b
commit b063ebd6d7
+14 -4
View File
@@ -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;
});