fix: limpiarChat crea conversación nueva en lugar de dejar convId null
Antes: limpiar → convId=null → 'Iniciando chat...' → refresh recuperaba la conv vieja. Ahora: limpiar → nueva conversación → menú principal inmediato, sin refresh. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
7307d87c80
commit
a9d0787076
@@ -212,13 +212,27 @@ class PublicChat extends Component
|
||||
|
||||
public function limpiarChat(): void
|
||||
{
|
||||
$this->mensajes = [];
|
||||
$this->convId = null;
|
||||
$this->flujo = '';
|
||||
$this->flujoData = [];
|
||||
$this->estadoConv = 'bot';
|
||||
session()->forget('chat_conv_id');
|
||||
// paso, userId, nombreUsuario, saldoUsuario se mantienen — sesión intacta
|
||||
$this->flujo = '';
|
||||
$this->flujoData = [];
|
||||
$this->mensajes = [];
|
||||
|
||||
// Crear nueva conversación en lugar de dejar convId en null
|
||||
if ($this->userId) {
|
||||
$contact = ChatContact::where('canal', 'web')->where('user_id', $this->userId)->first();
|
||||
if ($contact) {
|
||||
$conv = ChatConversation::create([
|
||||
'contact_id' => $contact->id,
|
||||
'canal' => 'web',
|
||||
'estado' => 'bot',
|
||||
'ultimo_mensaje_at' => now(),
|
||||
]);
|
||||
$this->convId = $conv->id;
|
||||
$this->estadoConv = 'bot';
|
||||
session()->put('chat_conv_id', $conv->id);
|
||||
$this->mostrarMenuPrincipal($conv->id);
|
||||
$this->cargarMensajes();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function cerrarSesion(): void
|
||||
|
||||
Reference in New Issue
Block a user