umami/src/components/hooks/useConfig.ts
Mike Cao ffc8f6faae
Some checks are pending
Node.js CI / build (postgresql, 18.18) (push) Waiting to run
Fixed config fetch.
2025-09-18 15:38:55 -07:00

34 lines
676 B
TypeScript

import { useEffect } from 'react';
import { useApp, setConfig } from '@/store/app';
import { useApi } from '@/components/hooks/useApi';
export type Config = {
cloudMode: boolean;
cloudUrl?: string;
faviconUrl?: string;
linksUrl?: string;
pixelsUrl?: string;
privateMode: boolean;
telemetryDisabled: boolean;
trackerScriptName?: string;
updatesDisabled: boolean;
};
export function useConfig(): Config {
const { config } = useApp();
const { get } = useApi();
async function loadConfig() {
const data = await get(`/config`);
setConfig(data);
}
useEffect(() => {
if (!config) {
loadConfig();
}
}, []);
return config;
}