feat: Enhance EditServerModal initialization logic by ensuring local state is synchronized with props only on modal open, improving state management and preventing unnecessary updates.
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 2m11s

This commit is contained in:
2025-12-07 01:41:22 +07:00
parent 62ceb95233
commit 9fb92c19cb
+8 -2
View File
@@ -1445,6 +1445,7 @@ function ServerManager() {
// Модальное окно для редактирования сервера с backdrop и анимацией
function EditServerModal({ show, server, onChange, onSave, onClose }) {
const modalRef = useRef(null);
const initializedRef = useRef(false);
// Локальное состояние для формы
const [localServer, setLocalServer] = useState({});
@@ -1462,12 +1463,17 @@ function EditServerModal({ show, server, onChange, onSave, onClose }) {
return { ...srv, gateways };
};
// Синхронизируем локальное состояние с пропсами при открытии модалки
// Синхронизируем локальное состояние с пропсами ТОЛЬКО при открытии модалки
useEffect(() => {
if (show && server) {
if (show && server && !initializedRef.current) {
const prepared = ensureGateways(server);
console.log('[EditServerModal] Инициализация с сервером:', prepared);
setLocalServer(prepared);
initializedRef.current = true;
}
// Сбрасываем флаг при закрытии
if (!show) {
initializedRef.current = false;
}
}, [show, server]);