fix(chat): limpiarChat no cierra sesión, solo borra mensajes
mount() ahora solo requiere chat_user_id (no chat_conv_id) para mantener al usuario logueado. limpiarChat() borra mensajes y convId pero preserva userId, nombreUsuario, saldoUsuario y paso='chat'. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
c3f9984a9d
commit
eb448794c5
@@ -63,16 +63,13 @@ class PublicChat extends Component
|
||||
public function mount(): void
|
||||
{
|
||||
$userId = session('chat_user_id');
|
||||
$convId = session('chat_conv_id');
|
||||
|
||||
if (! $userId || ! $convId) {
|
||||
if (! $userId) {
|
||||
return;
|
||||
}
|
||||
|
||||
$user = User::with('saldo')->find($userId);
|
||||
$conv = ChatConversation::find($convId);
|
||||
|
||||
if (! $user || ! $conv) {
|
||||
if (! $user) {
|
||||
session()->forget(['chat_user_id', 'chat_conv_id']);
|
||||
return;
|
||||
}
|
||||
@@ -80,10 +77,19 @@ class PublicChat extends Component
|
||||
$this->userId = $user->id;
|
||||
$this->nombreUsuario = $user->name;
|
||||
$this->saldoUsuario = $user->saldo?->valor ?? 0;
|
||||
$this->convId = $conv->id;
|
||||
$this->estadoConv = $conv->estado;
|
||||
$this->paso = 'chat';
|
||||
$this->cargarMensajes();
|
||||
|
||||
$convId = session('chat_conv_id');
|
||||
if ($convId) {
|
||||
$conv = ChatConversation::find($convId);
|
||||
if ($conv) {
|
||||
$this->convId = $conv->id;
|
||||
$this->estadoConv = $conv->estado;
|
||||
$this->cargarMensajes();
|
||||
} else {
|
||||
session()->forget('chat_conv_id');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected $rules = [
|
||||
@@ -193,12 +199,13 @@ class PublicChat extends Component
|
||||
|
||||
public function limpiarChat(): void
|
||||
{
|
||||
// Cierra la conversación actual y abre una nueva en la próxima interacción
|
||||
$this->mensajes = [];
|
||||
$this->convId = null;
|
||||
$this->flujo = '';
|
||||
$this->flujoData = [];
|
||||
$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
|
||||
}
|
||||
|
||||
public function cerrarSesion(): void
|
||||
|
||||
Reference in New Issue
Block a user