import React, { useState, type PropsWithChildren } from 'react'; import { useAsyncEffect } from '@wener/reaction'; import { LoadingIndicator } from '../../console'; import { getSiteStore, type SiteConfInit } from './SiteStore'; export const SiteLoader: React.FC< PropsWithChildren & { getSiteConf?: () => Promise; } > = ({ children, getSiteConf }) => { const [init, setInit] = useState(!getSiteConf); useAsyncEffect(async () => { if (!getSiteConf) return; const cfg = await getSiteConf(); getSiteStore().getState().load(cfg); setTimeout(() => { setInit(true); }, 0); }, []); if (!init) { return ; } return children; };