mirror of
https://github.com/owncast/owncast.git
synced 2024-10-10 19:16:02 +00:00
31 lines
932 B
TypeScript
31 lines
932 B
TypeScript
import { useEffect } from 'react';
|
|
import { ReactElement } from 'react-markdown/lib/react-markdown';
|
|
import { atom, useRecoilState } from 'recoil';
|
|
import { makeEmptyClientConfig, ClientConfig } from '../../models/ClientConfig';
|
|
import ClientConfigService from '../../services/ClientConfigService';
|
|
|
|
export const clientConfigState = atom({
|
|
key: 'clientConfigState',
|
|
default: makeEmptyClientConfig(),
|
|
});
|
|
|
|
export function ClientConfigStore(): ReactElement {
|
|
const [, setClientConfig] = useRecoilState<ClientConfig>(clientConfigState);
|
|
|
|
const updateClientConfig = async () => {
|
|
try {
|
|
const config = await ClientConfigService.getConfig();
|
|
console.log(`ClientConfig: ${JSON.stringify(config)}`);
|
|
setClientConfig(config);
|
|
} catch (error) {
|
|
console.error(`ClientConfigService -> getConfig() ERROR: \n${error}`);
|
|
}
|
|
};
|
|
|
|
useEffect(() => {
|
|
updateClientConfig();
|
|
}, []);
|
|
|
|
return null;
|
|
}
|