Merge pull request #52 from Nebelung-Dev/main

show current wisp server
This commit is contained in:
Owski 2024-10-13 17:56:57 -05:00 committed by GitHub
commit f5545dc9f8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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" 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> </Button>
</NextLink> </NextLink>
<NextLink href="/settings/credits/"> <NextLink href="/settings/credits/">

View file

@ -17,7 +17,7 @@ import {
import { Input } from "@/components/ui/input"; import { Input } from "@/components/ui/input";
import { Separator } from "@/components/ui/separator"; import { Separator } from "@/components/ui/separator";
import { Save, RotateCcw } from "lucide-react"; import { Save, RotateCcw } from "lucide-react";
import { useState } from "react"; import { useEffect, useState } from "react";
import { toast } from "sonner"; import { toast } from "sonner";
const formSchema = z.object({ 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>) { function onSubmit(values: z.infer<typeof formSchema>) {
setSubmitting(true); setSubmitting(true);
@ -53,7 +63,7 @@ export default function WispSwitcher() {
return ( return (
<div> <div>
<h1 className="text-4xl font-semibold">Wisp Switcher</h1> <h1 className="text-4xl font-semibold">Wisp</h1>
<Separator /> <Separator />
<div className="mt-4"> <div className="mt-4">
<Form {...form}> <Form {...form}>
@ -66,7 +76,7 @@ export default function WispSwitcher() {
name="wispServer" name="wispServer"
render={({ field }) => ( render={({ field }) => (
<FormItem> <FormItem>
<FormLabel>Wisp Server</FormLabel> <FormLabel>Wisp Server Switcher</FormLabel>
<FormControl> <FormControl>
<Input placeholder="Wisp Server URL" {...field} /> <Input placeholder="Wisp Server URL" {...field} />
</FormControl> </FormControl>