Server selector

This commit is contained in:
2026-08-18 16:09:08 +02:00
parent a14f6d3a0f
commit 06ca3a4bae
3 changed files with 45 additions and 12 deletions
+27 -10
View File
@@ -1,4 +1,6 @@
import Enclave from "@/app/app";
import EnclaveServer from "@/app/server";
import { getHTTPUrl, getWSUrl } from "@/lib/serverList";
export default function ServerList({
appRef,
@@ -7,16 +9,31 @@ export default function ServerList({
}) {
return (
<aside className="bg-card w-16 h-screen p-2 flex flex-col gap-2.5">
{appRef.current?.serverList.map((server) => (
<img
src={`http://${server.hostname}/icon`}
className={
server.publicKey === appRef.current?.server?.hostname
? "rounded-lg"
: "rounded-full"
}
/>
))}
{appRef.current?.serverList.map((server) => {
return (
<img
src={getHTTPUrl(server, "/icon")}
className={
server.publicKey === appRef.current?.server?.hostname
? "rounded-lg"
: "rounded-full"
}
onClick={async () => {
if (!appRef.current) {
console.error("AppRef is not initialized yet");
return;
}
if (appRef.current.server) {
appRef.current.server.disconnect();
}
appRef.current.server = new EnclaveServer(getWSUrl(server));
}}
/>
);
})}
</aside>
);
}