mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix ipfs options
This commit is contained in:
@@ -45,6 +45,30 @@ const SettingsModal = ({ isOpen, closeModal }) => {
|
|||||||
const author = {...account?.author, address: ensName};
|
const author = {...account?.author, address: ensName};
|
||||||
const { resolvedAddress, state } = useResolvedAuthorAddress({ author, cache: false });
|
const { resolvedAddress, state } = useResolvedAuthorAddress({ author, cache: false });
|
||||||
|
|
||||||
|
const isElectron = window.electron && window.electron.isElectron;
|
||||||
|
|
||||||
|
const defaultGatewayUrls = isElectron ? undefined : [
|
||||||
|
'https://ipfs.io',
|
||||||
|
'https://ipfsgateway.xyz',
|
||||||
|
'https://cloudflare-ipfs.com',
|
||||||
|
'https://plebpubsub.live'
|
||||||
|
];
|
||||||
|
|
||||||
|
const defaultPubsubHttpClientsOptions = isElectron ? undefined : [
|
||||||
|
'https://pubsubprovider.xyz/api/v0',
|
||||||
|
'https://plebpubsub.live/api/v0'
|
||||||
|
];
|
||||||
|
|
||||||
|
const defaultEthereumRpcUrls = [
|
||||||
|
'ethers.js',
|
||||||
|
'https://ethrpc.xyz',
|
||||||
|
'viem',
|
||||||
|
];
|
||||||
|
|
||||||
|
const defaultPolygonRpcUrls = [
|
||||||
|
'https://polygon-rpc.com',
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (checkedENS && resolvedAddress && state === 'succeeded') {
|
if (checkedENS && resolvedAddress && state === 'succeeded') {
|
||||||
@@ -87,29 +111,6 @@ const SettingsModal = ({ isOpen, closeModal }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const defaultGatewayUrls = [
|
|
||||||
'https://ipfs.io',
|
|
||||||
'https://ipfsgateway.xyz',
|
|
||||||
'https://cloudflare-ipfs.com',
|
|
||||||
'https://plebpubsub.live'
|
|
||||||
];
|
|
||||||
|
|
||||||
const defaultPubsubHttpClientsOptions = [
|
|
||||||
'https://pubsubprovider.xyz/api/v0',
|
|
||||||
'https://plebpubsub.live/api/v0'
|
|
||||||
];
|
|
||||||
|
|
||||||
const defaultEthereumRpcUrls = [
|
|
||||||
'ethers.js',
|
|
||||||
'https://ethrpc.xyz',
|
|
||||||
'viem',
|
|
||||||
];
|
|
||||||
|
|
||||||
const defaultPolygonRpcUrls = [
|
|
||||||
'https://polygon-rpc.com',
|
|
||||||
];
|
|
||||||
|
|
||||||
|
|
||||||
const isValidURL = (url) => {
|
const isValidURL = (url) => {
|
||||||
try {
|
try {
|
||||||
new URL(url);
|
new URL(url);
|
||||||
@@ -147,22 +148,22 @@ const SettingsModal = ({ isOpen, closeModal }) => {
|
|||||||
|
|
||||||
|
|
||||||
const handleSavePlebbitOptions = async () => {
|
const handleSavePlebbitOptions = async () => {
|
||||||
let gatewayUrls = gatewayRef.current.value.split('\n').filter(url => url.trim());
|
let gatewayUrls = gatewayRef.current.value.split('\n').filter((url) => url.trim());
|
||||||
let ipfsClientsOptions = ipfsRef.current.value.split('\n').filter(url => url.trim());
|
let ipfsClientsOptions = ipfsRef.current.value.split('\n').filter(url => url.trim());
|
||||||
let pubsubClientsOptions = pubsubRef.current.value.split('\n').filter(url => url.trim());
|
let pubsubClientsOptions = pubsubRef.current.value.split('\n').filter((url) => url.trim());
|
||||||
|
|
||||||
if (!gatewayUrls.length) {
|
if (!isElectron) {
|
||||||
gatewayUrls = defaultGatewayUrls;
|
if (!gatewayUrls.length) gatewayUrls = defaultGatewayUrls;
|
||||||
|
if (!pubsubClientsOptions.length) pubsubClientsOptions = defaultPubsubHttpClientsOptions;
|
||||||
|
} else {
|
||||||
|
if (!gatewayUrls.length) gatewayUrls = undefined;
|
||||||
|
if (!pubsubClientsOptions.length) pubsubClientsOptions = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ipfsClientsOptions.length) {
|
if (!ipfsClientsOptions.length) {
|
||||||
ipfsClientsOptions = undefined;
|
ipfsClientsOptions = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pubsubClientsOptions.length) {
|
|
||||||
pubsubClientsOptions = defaultPubsubHttpClientsOptions;
|
|
||||||
}
|
|
||||||
|
|
||||||
const invalidUrls = [
|
const invalidUrls = [
|
||||||
...gatewayUrls || defaultGatewayUrls,
|
...gatewayUrls || defaultGatewayUrls,
|
||||||
...(ipfsClientsOptions || []),
|
...(ipfsClientsOptions || []),
|
||||||
@@ -571,7 +572,7 @@ const SettingsModal = ({ isOpen, closeModal }) => {
|
|||||||
</li>
|
</li>
|
||||||
<div className="settings-input">
|
<div className="settings-input">
|
||||||
<textarea placeholder="IPFS Gateway URLs"
|
<textarea placeholder="IPFS Gateway URLs"
|
||||||
defaultValue={account?.plebbitOptions?.ipfsGatewayUrls.join("\n")}
|
defaultValue={isElectron ? '' : account?.plebbitOptions?.ipfsGatewayUrls.join('\n')}
|
||||||
ref={gatewayRef}
|
ref={gatewayRef}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -593,7 +594,7 @@ const SettingsModal = ({ isOpen, closeModal }) => {
|
|||||||
<li className="settings-tip">Optional URLs or IpfsHttpClientOptions used for pubsub publishing when ipfsHttpClientOptions isn't available, like in the browser.</li>
|
<li className="settings-tip">Optional URLs or IpfsHttpClientOptions used for pubsub publishing when ipfsHttpClientOptions isn't available, like in the browser.</li>
|
||||||
<div className="settings-input">
|
<div className="settings-input">
|
||||||
<textarea placeholder="PubSub HTTP Clients Options"
|
<textarea placeholder="PubSub HTTP Clients Options"
|
||||||
defaultValue={account?.plebbitOptions?.pubsubHttpClientsOptions.join("\n")}
|
defaultValue={isElectron ? '' : account?.plebbitOptions?.pubsubHttpClientsOptions.join('\n')}
|
||||||
ref={pubsubRef}
|
ref={pubsubRef}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user