fix(plebbit options): schema error prevented to save

This commit is contained in:
Tom (plebeius.eth)
2024-12-05 23:02:18 +01:00
parent 18c55aa2f8
commit db8c51fa72
@@ -148,19 +148,50 @@ const PlebbitOptions = () => {
const solRpcRef = useRef<HTMLTextAreaElement>(null); const solRpcRef = useRef<HTMLTextAreaElement>(null);
const maticRpcRef = useRef<HTMLTextAreaElement>(null); const maticRpcRef = useRef<HTMLTextAreaElement>(null);
const avaxRpcRef = useRef<HTMLTextAreaElement>(null); const avaxRpcRef = useRef<HTMLTextAreaElement>(null);
const httpRoutersRef = useRef<HTMLTextAreaElement>(null);
const plebbitRpcRef = useRef<HTMLInputElement>(null); const plebbitRpcRef = useRef<HTMLInputElement>(null);
const plebbitDataPathRef = useRef<HTMLInputElement>(null); const plebbitDataPathRef = useRef<HTMLInputElement>(null);
const handleSave = async () => { const handleSave = async () => {
const ipfsGatewayUrls = ipfsGatewayUrlsRef.current?.value.split('\n').map((url) => url.trim()); const ipfsGatewayUrls = ipfsGatewayUrlsRef.current?.value
.split('\n')
.map((url) => url.trim())
.filter((url) => url !== '');
const mediaIpfsGatewayUrl = mediaIpfsGatewayUrlRef.current?.value.trim(); const mediaIpfsGatewayUrl = mediaIpfsGatewayUrlRef.current?.value.trim();
const pubsubHttpClientsOptions = pubsubProvidersRef.current?.value.split('\n').map((url) => url.trim());
const ethRpcUrls = ethRpcRef.current?.value.split('\n').map((url) => url.trim()); const pubsubHttpClientsOptions = pubsubProvidersRef.current?.value
const solRpcUrls = solRpcRef.current?.value.split('\n').map((url) => url.trim()); .split('\n')
const maticRpcUrls = maticRpcRef.current?.value.split('\n').map((url) => url.trim()); .map((url) => url.trim())
const avaxRpcUrls = avaxRpcRef.current?.value.split('\n').map((url) => url.trim()); .filter((url) => url !== '');
const plebbitRpcClientsOptions = plebbitRpcRef.current?.value.trim();
const plebbitDataPath = plebbitDataPathRef.current?.value.trim(); const ethRpcUrls = ethRpcRef.current?.value
.split('\n')
.map((url) => url.trim())
.filter((url) => url !== '');
const solRpcUrls = solRpcRef.current?.value
.split('\n')
.map((url) => url.trim())
.filter((url) => url !== '');
const maticRpcUrls = maticRpcRef.current?.value
.split('\n')
.map((url) => url.trim())
.filter((url) => url !== '');
const avaxRpcUrls = avaxRpcRef.current?.value
.split('\n')
.map((url) => url.trim())
.filter((url) => url !== '');
const httpRoutersOptions = httpRoutersRef.current?.value
.split('\n')
.map((url) => url.trim())
.filter((url) => url !== '');
const plebbitRpcClientsOptions = plebbitRpcRef.current?.value.trim() ? [plebbitRpcRef.current.value.trim()] : undefined;
const dataPath = plebbitDataPathRef.current?.value.trim() || undefined;
const chainProviders = { const chainProviders = {
eth: { eth: {
@@ -190,11 +221,12 @@ const PlebbitOptions = () => {
ipfsGatewayUrls, ipfsGatewayUrls,
pubsubHttpClientsOptions, pubsubHttpClientsOptions,
chainProviders, chainProviders,
httpRoutersOptions,
plebbitRpcClientsOptions, plebbitRpcClientsOptions,
plebbitDataPath, dataPath,
}, },
}); });
alert('Options saved.'); alert('Options saved, reloading...');
window.location.reload(); window.location.reload();
} catch (e) { } catch (e) {
if (e instanceof Error) { if (e instanceof Error) {