fix: make settings and server lists not mandatory
This commit is contained in:
parent
6293374bb7
commit
9a8a1e034e
2 changed files with 21 additions and 14 deletions
|
|
@ -111,25 +111,31 @@ const APP = {
|
||||||
},
|
},
|
||||||
|
|
||||||
load: async function() {
|
load: async function() {
|
||||||
this.server = {};
|
this.server = {
|
||||||
|
name: document.title,
|
||||||
|
url: window.location.origin ?? window.location.href,
|
||||||
|
icon: '/icons/favicon-128x128.png',
|
||||||
|
icon_background: undefined
|
||||||
|
};
|
||||||
|
|
||||||
this.suggested_servers = [];
|
this.suggested_servers = [];
|
||||||
try {
|
try {
|
||||||
const server_info_response = await api.fetch( '/files/settings/settings.json' );
|
const server_info_response = await api.fetch( '/files/settings/settings.json' );
|
||||||
if ( !server_info_response.ok ) {
|
if ( server_info_response.ok ) {
|
||||||
throw new Error( 'Could not get server info.' );
|
const this_server_info = await server_info_response.json();
|
||||||
|
|
||||||
|
this.server = {
|
||||||
|
name: this_server_info.name ?? this.server.name,
|
||||||
|
url: this_server_info.url ?? this.server.url,
|
||||||
|
icon: this_server_info.icon ?? this.server.icon,
|
||||||
|
icon_background: this_server_info.icon_background ?? this.server.icon_background
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const this_server_info = await server_info_response.json();
|
const suggested_servers_response = await api.fetch( '/files/settings/suggested_servers.json' );
|
||||||
|
if ( suggested_servers_response.ok ) {
|
||||||
this.server = {
|
this.suggested_servers = await suggested_servers_response.json();
|
||||||
name: this_server_info?.name ?? document.title,
|
}
|
||||||
url: this_server_info?.url ?? window.location.origin ?? window.location.href,
|
|
||||||
icon: this_server_info?.icon ?? '/icons/favicon-128x128.png',
|
|
||||||
icon_background: this_server_info?.icon_background ?? undefined
|
|
||||||
};
|
|
||||||
|
|
||||||
const suggested_servers = await (await api.fetch( '/files/settings/suggested_servers.json' )).json();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch( error ) {
|
catch( error ) {
|
||||||
console.error( error );
|
console.error( error );
|
||||||
|
|
|
||||||
|
|
@ -447,6 +447,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
APP.on( 'load', update_servers_list );
|
APP.on( 'load', update_servers_list );
|
||||||
|
APP.on( 'user_logged_in', update_servers_list );
|
||||||
</script>
|
</script>
|
||||||
<style>
|
<style>
|
||||||
#server-list-container {
|
#server-list-container {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue