fix(chat): sesión persistente entre recargas + responsive móvil/desktop
- mount(): restaura userId y convId desde sesión Laravel al recargar página - abrirChat(): guarda chat_user_id y chat_conv_id en sesión - cerrarSesion(): limpia la sesión correctamente - Desktop: chat centrado como frame (420px, bordes redondeados, sombra) - Móvil: pantalla completa sin restricción de ancho - teclado virtual: ajuste de altura solo en móvil Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
4ddfdaeecc
commit
d27bd1c0d7
@@ -54,6 +54,32 @@ class PublicChat extends Component
|
||||
public $fotoComprobante = null;
|
||||
public bool $procesandoImagen = false;
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$userId = session('chat_user_id');
|
||||
$convId = session('chat_conv_id');
|
||||
|
||||
if (! $userId || ! $convId) {
|
||||
return;
|
||||
}
|
||||
|
||||
$user = User::with('saldo')->find($userId);
|
||||
$conv = ChatConversation::find($convId);
|
||||
|
||||
if (! $user || ! $conv) {
|
||||
session()->forget(['chat_user_id', 'chat_conv_id']);
|
||||
return;
|
||||
}
|
||||
|
||||
$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();
|
||||
}
|
||||
|
||||
protected $rules = [
|
||||
'email' => 'required|email|max:100',
|
||||
'nombreRegistro' => 'required|max:80',
|
||||
@@ -139,6 +165,8 @@ class PublicChat extends Component
|
||||
|
||||
public function cerrarSesion(): void
|
||||
{
|
||||
session()->forget(['chat_user_id', 'chat_conv_id']);
|
||||
|
||||
$this->email = '';
|
||||
$this->nombreRegistro = '';
|
||||
$this->cedulaRegistro = '';
|
||||
@@ -257,6 +285,10 @@ class PublicChat extends Component
|
||||
$this->convId = $conv->id;
|
||||
$this->estadoConv = $conv->estado;
|
||||
$this->paso = 'chat';
|
||||
|
||||
session()->put('chat_user_id', $this->userId);
|
||||
session()->put('chat_conv_id', $conv->id);
|
||||
|
||||
$this->cargarMensajes();
|
||||
$this->mostrarMenuPrincipal($conv->id);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user