import { useState, useEffect } from "react"; import { Button } from "@/components/ui/button"; import { RefreshCw, CheckCircle2, XCircle, Loader2 } from "lucide-react"; import { CheckAPIStatus } from "../../wailsjs/go/main/App"; import { TidalIcon, QobuzIcon, AmazonIcon } from "./PlatformIcons"; interface ApiSource { id: string; type: string; name: string; url: string; } const SOURCES: ApiSource[] = [ { id: "tidal1", type: "tidal", name: "Tidal A", url: "https://hifi-one.spotisaver.net" }, { id: "tidal2", type: "tidal", name: "Tidal B", url: "https://hifi-two.spotisaver.net" }, { id: "tidal3", type: "tidal", name: "Tidal C", url: "https://eu-central.monochrome.tf" }, { id: "tidal4", type: "tidal", name: "Tidal D", url: "https://us-west.monochrome.tf" }, { id: "tidal5", type: "tidal", name: "Tidal E", url: "https://api.monochrome.tf" }, { id: "tidal6", type: "tidal", name: "Tidal F", url: "https://monochrome-api.samidy.com" }, { id: "tidal7", type: "tidal", name: "Tidal G", url: "https://tidal.kinoplus.online" }, { id: "qobuz1", type: "qobuz", name: "Qobuz A", url: "https://dab.yeet.su" }, { id: "qobuz2", type: "qobuz", name: "Qobuz B", url: "https://dabmusic.xyz" }, { id: "qobuz3", type: "qbz", name: "Qobuz C", url: "https://qbz.afkarxyz.qzz.io" }, { id: "amazon1", type: "amazon", name: "Amazon Music", url: "https://amzn.afkarxyz.qzz.io" }, ]; export function ApiStatusTab() { const [statuses, setStatuses] = useState>({}); const [isCheckingAll, setIsCheckingAll] = useState(false); const checkStatus = async (sourceId: string, apiType: string, url: string) => { setStatuses(prev => ({ ...prev, [sourceId]: "checking" })); try { const isOnline = await CheckAPIStatus(apiType, url); setStatuses(prev => ({ ...prev, [sourceId]: isOnline ? "online" : "offline" })); } catch (error) { setStatuses(prev => ({ ...prev, [sourceId]: "offline" })); } }; const checkAll = async () => { setIsCheckingAll(true); const promises = SOURCES.map(s => checkStatus(s.id, s.type, s.url)); await Promise.allSettled(promises); setIsCheckingAll(false); }; useEffect(() => { checkAll(); }, []); return (
{SOURCES.map((source) => { const status = statuses[source.id] || "idle"; return (
{source.type === "tidal" ? : source.type === "amazon" ? : }

{source.name}

{status === "checking" && } {status === "online" && } {status === "offline" && } {status === "idle" &&
}
); })}
); }