fix: Исправлен порядок вызова React hooks в CalculatorNav

This commit is contained in:
dosai 2025-11-01 20:23:31 +03:00
parent 5e88427368
commit 186c85738d

View File

@ -19,11 +19,17 @@ export default function CalculatorNav() {
if (typeof window !== 'undefined') {
const params = new URLSearchParams(window.location.search);
const id = params.get('chat_id');
if (id) {
if (id && id !== chatId) {
setChatId(id);
} else if (!id) {
// Пробуем восстановить из sessionStorage
const savedChatId = sessionStorage.getItem('chat_id');
if (savedChatId && savedChatId !== chatId) {
setChatId(savedChatId);
}
}
}
}, [pathname]);
}, [pathname, chatId]);
// Сохраняем chat_id при переходах
const queryString = chatId ? `?chat_id=${chatId}` : '';