forked from noxious/client
Inform user when server can't be reached on login
This commit is contained in:
parent
fbffda7da8
commit
578d210f77
@ -52,7 +52,9 @@ onMounted(async () => {
|
|||||||
/**
|
/**
|
||||||
* Fetch assets from the server
|
* 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() {
|
async function loginFunc() {
|
||||||
|
@ -21,15 +21,17 @@ export const useAssetStore = defineStore('assets', {
|
|||||||
setObjects(objects: Object[]) {
|
setObjects(objects: Object[]) {
|
||||||
this.objects = objects
|
this.objects = objects
|
||||||
},
|
},
|
||||||
fetchAssets() {
|
async fetchAssets() {
|
||||||
fetch(config.server_endpoint + '/assets')
|
return fetch(config.server_endpoint + '/assets')
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then((assets) => {
|
.then((assets) => {
|
||||||
this.setAssets(assets)
|
this.setAssets(assets);
|
||||||
|
return true;
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error('Error fetching assets:', error)
|
console.error('Error fetching assets:', error);
|
||||||
})
|
return false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user