mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-25 02:36:20 +01:00
26 lines
499 B
JavaScript
26 lines
499 B
JavaScript
import { useEffect } from 'react';
|
|
import useStore, { setConfig } from 'store/app';
|
|
import useApi from 'hooks/useApi';
|
|
|
|
let loading = false;
|
|
|
|
export default function useConfig() {
|
|
const { config } = useStore();
|
|
const { get } = useApi();
|
|
|
|
async function loadConfig() {
|
|
const { data } = await get('/config');
|
|
loading = false;
|
|
setConfig(data);
|
|
}
|
|
|
|
useEffect(() => {
|
|
if (!config && !loading) {
|
|
loading = true;
|
|
loadConfig();
|
|
}
|
|
}, []);
|
|
|
|
return config || {};
|
|
}
|