feat(p2p options): add http routers field

This commit is contained in:
plebeius
2026-01-02 16:48:21 +01:00
parent fa32833b2a
commit 3d676062af
2 changed files with 35 additions and 0 deletions
@@ -25,6 +25,10 @@
height: unset;
}
.httpRoutersSettings textarea {
height: unset;
}
.blockchainProvidersSettings textarea {
height: unset;
}
@@ -7,6 +7,7 @@ interface SettingsProps {
ipfsGatewayUrlsRef?: RefObject<HTMLTextAreaElement>;
mediaIpfsGatewayUrlRef?: RefObject<HTMLInputElement>;
pubsubProvidersRef?: RefObject<HTMLTextAreaElement>;
httpRoutersRef?: RefObject<HTMLTextAreaElement>;
ethRpcRef?: RefObject<HTMLTextAreaElement>;
solRpcRef?: RefObject<HTMLTextAreaElement>;
maticRpcRef?: RefObject<HTMLTextAreaElement>;
@@ -75,6 +76,30 @@ const PubsubProvidersSettings = ({ pubsubProvidersRef }: SettingsProps) => {
);
};
const HttpRoutersSettings = ({ httpRoutersRef }: SettingsProps) => {
const account = useAccount();
const { plebbitOptions } = account || {};
const { httpRoutersOptions } = plebbitOptions || {};
const plebbitRpc = usePlebbitRpcSettings();
const isConnectedToRpc = plebbitRpc?.state === 'connected';
const httpRoutersDefaultValue = httpRoutersOptions?.join('\n');
return (
<div className={styles.httpRoutersSettings}>
<textarea
defaultValue={httpRoutersDefaultValue}
ref={httpRoutersRef}
disabled={isConnectedToRpc}
autoCorrect='off'
autoCapitalize='off'
autoComplete='off'
spellCheck='false'
rows={httpRoutersOptions?.length || 1}
/>
</div>
);
};
const BlockchainProvidersSettings = ({ ethRpcRef, solRpcRef, maticRpcRef }: SettingsProps) => {
const account = useAccount();
const { plebbitOptions } = account || {};
@@ -278,6 +303,12 @@ const P2pOptions = () => {
<PubsubProvidersSettings pubsubProvidersRef={pubsubProvidersRef} />
</span>
</div>
<div className={styles.category}>
<span className={styles.categoryTitle}>http routers:</span>
<span className={styles.categorySettings}>
<HttpRoutersSettings httpRoutersRef={httpRoutersRef} />
</span>
</div>
<div className={styles.category}>
<span className={styles.categoryTitle} style={{ marginBottom: '-5px' }}>
blockchain providers: