forked from eatvio/eatvio-infra
36 lines
773 B
PHP
36 lines
773 B
PHP
<?php
|
|
|
|
namespace App\Livewire\Chat;
|
|
|
|
use Livewire\Component;
|
|
use Illuminate\Contracts\View\Factory as ViewFactory;
|
|
use Illuminate\Contracts\View\View;
|
|
|
|
|
|
class Tracker extends Component
|
|
{
|
|
public bool $showNewMessageNotifycation = false;
|
|
|
|
public array $myMessages = [];
|
|
|
|
// Special Syntax: ['echo:{channel},{event}' => '{method}']
|
|
/**
|
|
* some Listeners
|
|
*
|
|
* @var array
|
|
*
|
|
* */
|
|
protected $listeners = ['echo:direct-chat,ChatMessageUpdated' => 'notifyNewMessage'];
|
|
|
|
public function notifyNewMessage(mixed $payload): void
|
|
{
|
|
$this->myMessages[] = $payload;
|
|
$this->showNewMessageNotifycation = true;
|
|
}
|
|
|
|
public function render(): View|ViewFactory
|
|
{
|
|
return view('livewire.chat.tracker');
|
|
}
|
|
}
|