mirror of
https://github.com/umami-software/umami.git
synced 2026-02-07 22:27:16 +01:00
Refactored useConfig.
This commit is contained in:
parent
cc574e6da4
commit
183dab3ddc
11 changed files with 27 additions and 39 deletions
|
|
@ -7,15 +7,16 @@ let loading = false;
|
|||
export function useConfig() {
|
||||
const { config } = useStore();
|
||||
const { get } = useApi();
|
||||
const configUrl = process.env.configUrl;
|
||||
|
||||
async function loadConfig() {
|
||||
const data = await get('/config');
|
||||
const data = await get(configUrl);
|
||||
loading = false;
|
||||
setConfig(data);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (!config && !loading) {
|
||||
if (!config && !loading && configUrl) {
|
||||
loading = true;
|
||||
loadConfig();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue