Inform user when server can't be reached on login

This commit is contained in:
Dennis Postma 2024-07-12 00:19:42 +02:00
parent fbffda7da8
commit 578d210f77
2 changed files with 10 additions and 6 deletions

View File

@ -52,7 +52,9 @@ onMounted(async () => {
/**
* Fetch assets from the server
*/
assetStore.fetchAssets()
if (!await assetStore.fetchAssets()) {
notifications.addNotification({ message: 'Failed to fetch assets, the server may be offline or in maintenance. Please try again later.' })
}
})
async function loginFunc() {

View File

@ -21,15 +21,17 @@ export const useAssetStore = defineStore('assets', {
setObjects(objects: Object[]) {
this.objects = objects
},
fetchAssets() {
fetch(config.server_endpoint + '/assets')
async fetchAssets() {
return fetch(config.server_endpoint + '/assets')
.then((response) => response.json())
.then((assets) => {
this.setAssets(assets)
this.setAssets(assets);
return true;
})
.catch((error) => {
console.error('Error fetching assets:', error)
})
console.error('Error fetching assets:', error);
return false;
});
}
}
})