From dc3dddf410376874470c5e897189f67d280d1b44 Mon Sep 17 00:00:00 2001 From: "Tom (plebeius.eth)" Date: Wed, 4 Dec 2024 17:10:50 +0100 Subject: [PATCH 01/11] fix(plebbit options): schema error prevented to save --- .../avatar-settings.module.css | 4 -- .../plebbit-options/plebbit-options.tsx | 59 ++++++++++++++++--- 2 files changed, 50 insertions(+), 13 deletions(-) diff --git a/src/views/settings/avatar-settings/avatar-settings.module.css b/src/views/settings/avatar-settings/avatar-settings.module.css index c83041b8..cb4838d7 100644 --- a/src/views/settings/avatar-settings/avatar-settings.module.css +++ b/src/views/settings/avatar-settings/avatar-settings.module.css @@ -82,10 +82,6 @@ text-transform: lowercase; } -.hideAvatarsCheckbox label { - cursor: pointer; -} - .hideAvatarsCheckbox input { margin-right: .5em; } diff --git a/src/views/settings/plebbit-options/plebbit-options.tsx b/src/views/settings/plebbit-options/plebbit-options.tsx index c38c4944..487f8b39 100644 --- a/src/views/settings/plebbit-options/plebbit-options.tsx +++ b/src/views/settings/plebbit-options/plebbit-options.tsx @@ -163,15 +163,40 @@ const PlebbitOptions = () => { const plebbitDataPathRef = useRef(null); 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 pubsubHttpClientsOptions = pubsubProvidersRef.current?.value.split('\n').map((url) => url.trim()); - const ethRpcUrls = ethRpcRef.current?.value.split('\n').map((url) => url.trim()); - const solRpcUrls = solRpcRef.current?.value.split('\n').map((url) => url.trim()); - const maticRpcUrls = maticRpcRef.current?.value.split('\n').map((url) => url.trim()); - const avaxRpcUrls = avaxRpcRef.current?.value.split('\n').map((url) => url.trim()); - const plebbitRpcClientsOptions = plebbitRpcRef.current?.value.trim(); - const dataPath = plebbitDataPathRef.current?.value.trim(); + + const pubsubHttpClientsOptions = pubsubProvidersRef.current?.value + .split('\n') + .map((url) => url.trim()) + .filter((url) => url !== ''); + + 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 plebbitRpcClientsOptions = plebbitRpcRef.current?.value.trim() ? [plebbitRpcRef.current.value.trim()] : undefined; + const dataPath = plebbitDataPathRef.current?.value.trim() || undefined; const chainProviders = { eth: { @@ -191,6 +216,21 @@ const PlebbitOptions = () => { chainId: 43114, }, }; + const accountToSave = { + ...account, + mediaIpfsGatewayUrl, + plebbitOptions: { + ...plebbitOptions, + ipfsGatewayUrls, + pubsubHttpClientsOptions, + chainProviders, + plebbitRpcClientsOptions, + dataPath, + }, + }; + + console.log('existing account', account); + console.log('saving account', accountToSave); try { await setAccount({ @@ -205,7 +245,8 @@ const PlebbitOptions = () => { dataPath, }, }); - alert('Options saved.'); + alert('Options saved, reloading...'); + window.location.reload(); } catch (e) { if (e instanceof Error) { alert('Error saving options: ' + e.message); From cfe004cf07614f523fe5788d508bc23dc7218ef3 Mon Sep 17 00:00:00 2001 From: "Tom (plebeius.eth)" Date: Wed, 4 Dec 2024 20:53:23 +0100 Subject: [PATCH 02/11] feat(settings): add http routers setting to plebbit options --- .../plebbit-options/plebbit-options.tsx | 42 ++++++++++++------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/src/views/settings/plebbit-options/plebbit-options.tsx b/src/views/settings/plebbit-options/plebbit-options.tsx index 487f8b39..032d4308 100644 --- a/src/views/settings/plebbit-options/plebbit-options.tsx +++ b/src/views/settings/plebbit-options/plebbit-options.tsx @@ -12,6 +12,7 @@ interface SettingsProps { solRpcRef?: RefObject; maticRpcRef?: RefObject; avaxRpcRef?: RefObject; + httpRoutersRef?: RefObject; plebbitRpcRef?: RefObject; plebbitDataPathRef?: RefObject; } @@ -68,6 +69,19 @@ const PubsubProvidersSettings = ({ pubsubProvidersRef }: SettingsProps) => { ); }; +const HttpRoutersSettings = ({ httpRoutersRef }: SettingsProps) => { + const account = useAccount(); + const { plebbitOptions } = account || {}; + const { httpRoutersOptions } = plebbitOptions || {}; + const httpRoutersDefaultValue = httpRoutersOptions?.join('\n'); + + return ( +
+