mirror of
https://github.com/BrenBroZAYT/gameyfin.git
synced 2026-06-13 16:40:01 +00:00
Fix checkbox inputs always being unchecked on load
This commit is contained in:
@@ -10,7 +10,9 @@ const CheckboxInput = ({label, ...props}) => {
|
||||
<div className="flex flex-row flex-grow items-center gap-2 my-2">
|
||||
<Checkbox
|
||||
{...field}
|
||||
id={field.name}>
|
||||
id={field.name}
|
||||
isSelected={field.value}
|
||||
>
|
||||
{label}
|
||||
</Checkbox>
|
||||
</div>
|
||||
|
||||
@@ -8,7 +8,7 @@ const Input = ({label, ...props}) => {
|
||||
const [field, meta] = useField(props);
|
||||
|
||||
return (
|
||||
<div className="grid w-full max-w-sm items-center gap-2 my-2">
|
||||
<div className="flex flex-grow max-w-sm items-center gap-2 my-2">
|
||||
<NextUiInput
|
||||
{...props}
|
||||
{...field}
|
||||
|
||||
@@ -5,6 +5,7 @@ import {Form, Formik} from "formik";
|
||||
import ConfigFormField from "Frontend/components/administration/ConfigFormField";
|
||||
import {Button, Divider, Skeleton} from "@nextui-org/react";
|
||||
import {toast} from "sonner";
|
||||
import {Check} from "@phosphor-icons/react";
|
||||
|
||||
type NestedConfig = {
|
||||
[field: string]: any;
|
||||
@@ -17,6 +18,7 @@ type ConfigValuePair = {
|
||||
|
||||
export function LibraryManagement() {
|
||||
const isInitialized = useRef(false);
|
||||
const [configSaved, setConfigSaved] = useState(false);
|
||||
const [configDtos, setConfigDtos] = useState<ConfigEntryDto[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -26,6 +28,12 @@ export function LibraryManagement() {
|
||||
});
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (configSaved) {
|
||||
setTimeout(() => setConfigSaved(false), 2000);
|
||||
}
|
||||
}, [configSaved])
|
||||
|
||||
async function handleSubmit(values: NestedConfig) {
|
||||
const configValues = toConfigValuePair(values);
|
||||
await Promise.all(configValues.map(async (c: ConfigValuePair) => {
|
||||
@@ -37,6 +45,7 @@ export function LibraryManagement() {
|
||||
await ConfigController.setConfig(c.key, c.value.toString());
|
||||
}));
|
||||
|
||||
setConfigSaved(true);
|
||||
toast.success("Configuration saved");
|
||||
}
|
||||
|
||||
@@ -122,9 +131,10 @@ export function LibraryManagement() {
|
||||
<Button
|
||||
color="secondary"
|
||||
isLoading={formik.isSubmitting}
|
||||
disabled={formik.isSubmitting || configSaved}
|
||||
type="submit"
|
||||
>
|
||||
{formik.isSubmitting ? "" : "Save"}
|
||||
{formik.isSubmitting ? "" : configSaved ? <Check/> : "Save"}
|
||||
</Button>
|
||||
</div>
|
||||
<div className="mb-8 flex flex-col flex-grow">
|
||||
@@ -145,7 +155,6 @@ export function LibraryManagement() {
|
||||
<ConfigFormField
|
||||
configElement={getConfig("library.display.games-per-page")}></ConfigFormField>
|
||||
</div>
|
||||
<pre>{JSON.stringify(formik.values, null, 2)}</pre>
|
||||
</Form>
|
||||
)}
|
||||
</Formik>
|
||||
|
||||
@@ -8,11 +8,11 @@ import org.springframework.web.servlet.HandlerInterceptor
|
||||
|
||||
|
||||
@Component
|
||||
@Profile("development")
|
||||
@Profile("dev")
|
||||
class DelayInterceptor : HandlerInterceptor {
|
||||
|
||||
override fun preHandle(request: HttpServletRequest, response: HttpServletResponse, handler: Any): Boolean {
|
||||
Thread.sleep(2000)
|
||||
if (request.requestURI.startsWith("/connect")) Thread.sleep(2000)
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user