show current wisp server

This commit is contained in:
Nebelung 2024-10-13 22:55:04 +00:00
parent 22394a7b18
commit c35930952d
2 changed files with 14 additions and 4 deletions

View file

@ -30,7 +30,7 @@ export default function SettingsLayout({
}
className="w-full items-center justify-start gap-2"
>
<ArrowRightLeft className="h-5 w-5" /> Wisp Switcher
<ArrowRightLeft className="h-5 w-5" /> Wisp
</Button>
</NextLink>
<NextLink href="/settings/credits/">

View file

@ -17,7 +17,7 @@ import {
import { Input } from "@/components/ui/input";
import { Separator } from "@/components/ui/separator";
import { Save, RotateCcw } from "lucide-react";
import { useState } from "react";
import { useEffect, useState } from "react";
import { toast } from "sonner";
const formSchema = z.object({
@ -34,6 +34,16 @@ export default function WispSwitcher() {
},
});
useEffect(() => {
const wispServer: string = window.chemical.getStore("wisp");
const defaultWisp: string =
(location.protocol === "https:" ? "wss" : "ws") +
"://" +
location.host +
"/wisp/";
form.setValue("wispServer", wispServer !== defaultWisp ? wispServer : "");
}, []);
function onSubmit(values: z.infer<typeof formSchema>) {
setSubmitting(true);
@ -53,7 +63,7 @@ export default function WispSwitcher() {
return (
<div>
<h1 className="text-4xl font-semibold">Wisp Switcher</h1>
<h1 className="text-4xl font-semibold">Wisp</h1>
<Separator />
<div className="mt-4">
<Form {...form}>
@ -66,7 +76,7 @@ export default function WispSwitcher() {
name="wispServer"
render={({ field }) => (
<FormItem>
<FormLabel>Wisp Server</FormLabel>
<FormLabel>Wisp Server Switcher</FormLabel>
<FormControl>
<Input placeholder="Wisp Server URL" {...field} />
</FormControl>