|
@@ -92,18 +92,18 @@ export const ChatInterface = ({ chatType }: ChatInterfaceProps) => {
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
// Solo verificar al montar el componente, antes de que el usuario interactúe
|
|
// Solo verificar al montar el componente, antes de que el usuario interactúe
|
|
|
if (!hasCheckedExistingChat) {
|
|
if (!hasCheckedExistingChat) {
|
|
|
- const storageKey = `chatMessages_${chatType}`;
|
|
|
|
|
- const storedMessages = localStorage.getItem(storageKey);
|
|
|
|
|
|
|
+ const storageKey = `chatState_${chatType}`;
|
|
|
|
|
+ const storedState = localStorage.getItem(storageKey);
|
|
|
|
|
|
|
|
- if (storedMessages) {
|
|
|
|
|
|
|
+ if (storedState) {
|
|
|
try {
|
|
try {
|
|
|
- const parsedMessages = JSON.parse(storedMessages);
|
|
|
|
|
- // Solo mostrar si hay mensajes guardados previamente
|
|
|
|
|
- if (Array.isArray(parsedMessages) && parsedMessages.length > 0) {
|
|
|
|
|
|
|
+ const parsedState = JSON.parse(storedState);
|
|
|
|
|
+ // Verificar si hay mensajes en el estado guardado
|
|
|
|
|
+ if (parsedState.messages && Array.isArray(parsedState.messages) && parsedState.messages.length > 0) {
|
|
|
setShowContinueChatModal(true);
|
|
setShowContinueChatModal(true);
|
|
|
}
|
|
}
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
- console.error('Error parsing stored messages:', error);
|
|
|
|
|
|
|
+ console.error('Error parsing stored chat state:', error);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
setHasCheckedExistingChat(true);
|
|
setHasCheckedExistingChat(true);
|