// @flow import { COMMENT_SERVER_NAME } from 'config'; import React from 'react'; import Comments from 'comments'; import { FormField } from 'component/common/form'; const DEBOUNCE_TEXT_INPUT_MS = 500; type Props = { customServerEnabled: boolean, customServerUrl: string, setCustomServerEnabled: (boolean) => void, setCustomServerUrl: (string) => void, }; function SettingCommentsServer(props: Props) { const { customServerEnabled, customServerUrl, setCustomServerEnabled, setCustomServerUrl } = props; const [customUrl, setCustomUrl] = React.useState(customServerUrl); React.useEffect(() => { const timer = setTimeout(() => { setCustomServerUrl(customUrl); Comments.url = customUrl; }, DEBOUNCE_TEXT_INPUT_MS); return () => clearTimeout(timer); }, [customUrl, setCustomServerUrl]); return ( { if (e.target.checked) { setCustomServerEnabled(false); } }} /> { if (e.target.checked) { setCustomServerEnabled(true); } }} /> {customServerEnabled && (
setCustomUrl(e.target.value)} />
)}
); } export default SettingCommentsServer;