pstream is dead; long live pstream taciturnaxolotl.github.io/pstream-ng/
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

persist entered custom backend url when navigating the site

Pas 681172fe 0d4c6471

+33 -15
+19 -4
src/components/form/BackendSelector.tsx
··· 100 100 showCustom = true, 101 101 }: BackendSelectorProps) { 102 102 const { t } = useTranslation(); 103 - const [customUrl, setCustomUrl] = useState(""); 103 + // Helper to strip protocol from URL for display 104 + const stripProtocol = (url: string | null): string => { 105 + if (!url) return ""; 106 + return url.replace(/^https?:\/\//, ""); 107 + }; 108 + 109 + // Initialize customUrl from selectedUrl if it's a custom URL (not in availableUrls) 110 + const isCustomUrl = selectedUrl && !availableUrls.includes(selectedUrl); 111 + const [customUrl, setCustomUrl] = useState( 112 + isCustomUrl ? stripProtocol(selectedUrl) : "", 113 + ); 104 114 const [backendOptions, setBackendOptions] = useState<BackendOption[]>([]); 115 + 116 + // Update customUrl when selectedUrl changes and it's a custom URL 117 + useEffect(() => { 118 + if (selectedUrl && !availableUrls.includes(selectedUrl)) { 119 + setCustomUrl(stripProtocol(selectedUrl)); 120 + } 121 + }, [selectedUrl, availableUrls]); 105 122 106 123 // Initialize and fetch meta for backend options 107 124 useEffect(() => { ··· 142 159 }; 143 160 144 161 const isCustomUrlSelected = 145 - customUrl && 146 - selectedUrl === customUrl && 147 - !availableUrls.includes(selectedUrl); 162 + selectedUrl !== null && !availableUrls.includes(selectedUrl); 148 163 149 164 return ( 150 165 <div className="space-y-4">
+5 -4
src/pages/Login.tsx
··· 18 18 export function LoginPage() { 19 19 const navigate = useNavigate(); 20 20 const { t } = useTranslation(); 21 - const [showBackendSelection, setShowBackendSelection] = useState(true); 22 - const [selectedBackendUrl, setSelectedBackendUrl] = useState<string | null>( 23 - null, 24 - ); 25 21 const setBackendUrl = useAuthStore((s) => s.setBackendUrl); 26 22 const config = conf(); 27 23 const availableBackends = ··· 36 32 const defaultBackend = 37 33 currentBackendUrl ?? 38 34 (availableBackends.length === 1 ? availableBackends[0] : null); 35 + 36 + const [showBackendSelection, setShowBackendSelection] = useState(true); 37 + const [selectedBackendUrl, setSelectedBackendUrl] = useState<string | null>( 38 + currentBackendUrl ?? null, 39 + ); 39 40 40 41 const handleBackendSelect = (url: string | null) => { 41 42 setSelectedBackendUrl(url);
+9 -7
src/pages/Register.tsx
··· 38 38 export function RegisterPage() { 39 39 const navigate = useNavigate(); 40 40 const { t } = useTranslation(); 41 - const [step, setStep] = useState(-1); 42 - const [mnemonic, setMnemonic] = useState<null | string>(null); 43 - const [account, setAccount] = useState<null | AccountProfile>(null); 44 - const [siteKey, setSiteKey] = useState<string | null>(null); 45 - const [selectedBackendUrl, setSelectedBackendUrl] = useState<string | null>( 46 - null, 47 - ); 48 41 const setBackendUrl = useAuthStore((s) => s.setBackendUrl); 42 + const currentBackendUrl = useAuthStore((s) => s.backendUrl); 49 43 const config = conf(); 50 44 const availableBackends = 51 45 config.BACKEND_URLS.length > 0 ··· 53 47 : config.BACKEND_URL 54 48 ? [config.BACKEND_URL] 55 49 : []; 50 + 51 + const [step, setStep] = useState(-1); 52 + const [mnemonic, setMnemonic] = useState<null | string>(null); 53 + const [account, setAccount] = useState<null | AccountProfile>(null); 54 + const [siteKey, setSiteKey] = useState<string | null>(null); 55 + const [selectedBackendUrl, setSelectedBackendUrl] = useState<string | null>( 56 + currentBackendUrl ?? null, 57 + ); 56 58 57 59 const handleBackendSelect = (url: string | null) => { 58 60 setSelectedBackendUrl(url);