diff --git a/frontend/components/CalculatorNav.tsx b/frontend/components/CalculatorNav.tsx index 000acee..003e612 100644 --- a/frontend/components/CalculatorNav.tsx +++ b/frontend/components/CalculatorNav.tsx @@ -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}` : '';