fix: chain providers, i18n, dedup isWebRuntime, and a11y label

Conditionally build `chainProviders` so empty `urls` arrays are never passed downstream. Replace hardcoded "Chain ticker: " with `capitalize(t('chain_ticker'))` and add the translation key to all locales. Remove the duplicate `isWebRuntime` in `media-hosting-settings.tsx` in favor of the shared implementation in `show-upload-controls`. Add `aria-label` to the directory codes input in `TopbarEditModal`.
This commit is contained in:
plebeius
2026-02-20 16:23:09 +08:00
parent 291dbf125d
commit 15d608764b
39 changed files with 79 additions and 50 deletions
@@ -226,16 +226,13 @@ const AdvancedSettings = () => {
const plebbitRpcClientsOptions = p2pRpcRef.current?.value.trim() ? [p2pRpcRef.current.value.trim()] : undefined;
const dataPath = p2pDataPathRef.current?.value.trim() || undefined;
const chainProviders = {
eth: {
urls: ethRpcUrls,
chainId: 1,
},
sol: {
urls: solRpcUrls,
chainId: 101,
},
};
const chainProviders: Record<string, { urls: string[] | undefined; chainId: number }> = {};
if (ethRpcUrls && ethRpcUrls.length > 0) {
chainProviders.eth = { urls: ethRpcUrls, chainId: 1 };
}
if (solRpcUrls && solRpcUrls.length > 0) {
chainProviders.sol = { urls: solRpcUrls, chainId: 101 };
}
try {
await setAccount({
@@ -102,7 +102,7 @@ const CryptoWalletsForm = ({ account }: { account: Account | undefined }) => {
walletsArray.length > 0 ? (
<div key={selectedWallet} className={styles.walletBox}>
<div className={`${styles.walletField} ${styles.step1}`}>
<span className={styles.walletFieldTitle}>Chain ticker: </span>
<span className={styles.walletFieldTitle}>{capitalize(t('chain_ticker'))}: </span>
<input
type='text'
onChange={(e) => setWalletsArrayProperty(selectedWallet, 'chainTicker', e.target.value)}
@@ -1,16 +1,12 @@
import { Capacitor } from '@capacitor/core';
import { useTranslation } from 'react-i18next';
import useMediaHostingStore, { MEDIA_HOSTING_PROVIDERS } from '../../../stores/use-media-hosting-store';
import type { ProviderId } from '../../../lib/media-hosting/types';
import { isWebRuntime } from '../../../lib/media-hosting/show-upload-controls';
import styles from '../interface-settings/interface-settings.module.css';
const RADIO_NAME = 'media-hosting-provider';
const RELEASES_URL = 'https://github.com/bitsocialhq/5chan/releases/latest';
function isWebRuntime(): boolean {
return Capacitor.getPlatform() === 'web' && !window.electronApi?.isElectron;
}
const MediaHostingSettings = () => {
const { t } = useTranslation();
const uploadMode = useMediaHostingStore((state) => state.uploadMode);
@@ -59,6 +59,7 @@ const TopbarEditModalForm = ({
type='text'
className={styles.directoryInput}
placeholder='Example: jp tg mu'
aria-label='Directory codes'
value={localDirectoryInput}
onChange={(e) => setLocalDirectoryInput(e.target.value)}
/>