# Conflicts: # next.config.ts # src/app/(main)/settings/preferences/LanguageSetting.tsx # src/components/hooks/useConfig.ts
20 lines
382 B
TypeScript
20 lines
382 B
TypeScript
import { useEffect } from 'react';
|
|
import { useApp, setConfig } from '@/store/app';
|
|
import { getConfig, Config } from '@/app/actions/getConfig';
|
|
|
|
export function useConfig(): Config {
|
|
const { config } = useApp();
|
|
|
|
async function loadConfig() {
|
|
setConfig(await getConfig());
|
|
}
|
|
|
|
useEffect(() => {
|
|
if (!config) {
|
|
loadConfig();
|
|
}
|
|
}, []);
|
|
|
|
return config;
|
|
}
|