fix: fallback to first endpoint

This commit is contained in:
kieran 2024-08-21 12:12:01 +01:00
parent 86f13c171d
commit 855a87aadc
No known key found for this signature in database
GPG Key ID: DE71CEB3925BE941
3 changed files with 8 additions and 6 deletions

View File

@ -49,7 +49,8 @@ export function DashboardForLink({ link }: { link: NostrLink }) {
const provider = useMemo(() => (service ? new NostrStreamProvider("", service) : DefaultProvider), [service]);
const defaultEndpoint = useMemo(() => {
return info?.endpoints.find(a => a.name == (recording ? "Best" : "Good"));
return info?.endpoints.find(a => a.name == (recording ? "Best" : "Good"))
?? info?.endpoints[0];
}, [info, recording]);
useEffect(() => {
@ -98,9 +99,8 @@ export function DashboardForLink({ link }: { link: NostrLink }) {
</h3>
<div className="uppercase font-semibold flex items-center gap-2">
<div
className={`w-3 h-3 rounded-full ${
status === StreamState.Live ? "animate-pulse bg-green-500" : "bg-red-500"
}`}></div>
className={`w-3 h-3 rounded-full ${status === StreamState.Live ? "animate-pulse bg-green-500" : "bg-red-500"
}`}></div>
{status === StreamState.Live ? (
<FormattedMessage defaultMessage="Started" />
) : (

View File

@ -12,7 +12,8 @@ export default function DashboardIntroFinal() {
const [info, setInfo] = useState<StreamProviderInfo>();
const defaultEndpoint = useMemo(() => {
return info?.endpoints.find(a => a.name == "Best");
return info?.endpoints.find(a => a.name == "Best")
?? info?.endpoints[0];
}, [info]);
async function loadInfo() {

View File

@ -16,7 +16,8 @@ export default function DashboardIntro() {
const exampleHours = 4;
const defaultEndpoint = useMemo(() => {
return info?.endpoints.find(a => a.name == "Best");
return info?.endpoints.find(a => a.name == "Best")
?? info?.endpoints[0];
}, [info]);
const rate = useRates("BTCUSD");
const exampleCost = rate.ask * (exampleHours * (defaultEndpoint?.rate ?? 0) * 60) * 1e-8;