feat: Refactor gateway addition logic in EditServerModal to ensure safe state updates and improve clarity in handling gateways, enhancing server configuration reliability.
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 2m7s

This commit is contained in:
2025-12-07 00:47:35 +07:00
parent f246d5407a
commit e14839ca21
+5 -3
View File
@@ -1634,11 +1634,13 @@ function EditServerModal({ show, server, onChange, onSave, onClose }) {
type="button" type="button"
className="btn btn-outline-primary btn-sm" className="btn btn-outline-primary btn-sm"
onClick={() => { onClick={() => {
const list = Array.isArray(localServer.gateways) ? localServer.gateways : []; setLocalServer((prev) => {
const list = Array.isArray(prev?.gateways) ? prev.gateways : [];
const nextList = [...list, makeGateway({ primary: list.length === 0 })]; const nextList = [...list, makeGateway({ primary: list.length === 0 })];
const next = { ...localServer, gateways: nextList }; const next = { ...(prev || {}), gateways: nextList };
setLocalServer(next);
onChange && onChange(next); onChange && onChange(next);
return next;
});
}} }}
> >
<IconPlus className="icon" /> <IconPlus className="icon" />