2
0
mirror of https://github.com/inventree/InvenTree.git synced 2026-02-06 05:15:52 +00:00

refactor(frontend): load server and auth info in paralell (#11245)

This commit is contained in:
Matthias Mair
2026-02-02 22:16:17 +01:00
committed by GitHub
parent 02b10ccd75
commit 619da6e619

View File

@@ -37,27 +37,29 @@ export const useServerApiState = create<ServerApiStateProps>()(
server: emptyServerAPI, server: emptyServerAPI,
setServer: (newServer: ServerAPIProps) => set({ server: newServer }), setServer: (newServer: ServerAPIProps) => set({ server: newServer }),
fetchServerApiState: async () => { fetchServerApiState: async () => {
// Fetch server data await Promise.all([
await api // Fetch server data
.get(apiUrl(ApiEndpoints.api_server_info)) api
.then((response) => { .get(apiUrl(ApiEndpoints.api_server_info))
set({ server: response.data }); .then((response) => {
}) set({ server: response.data });
.catch(() => { })
console.error('ERR: Error fetching server info'); .catch(() => {
}); console.error('ERR: Error fetching server info');
}),
// Fetch login/SSO behaviour // Fetch login/SSO behaviour
await api api
.get(apiUrl(ApiEndpoints.auth_config), { .get(apiUrl(ApiEndpoints.auth_config), {
headers: { Authorization: '' } headers: { Authorization: '' }
}) })
.then((response) => { .then((response) => {
set({ auth_config: response.data.data }); set({ auth_config: response.data.data });
}) })
.catch(() => { .catch(() => {
console.error('ERR: Error fetching SSO information'); console.error('ERR: Error fetching SSO information');
}); })
]);
}, },
auth_config: undefined, auth_config: undefined,
auth_context: undefined, auth_context: undefined,