mirror of
https://github.com/sp-tarkov/forge.git
synced 2025-02-13 04:30:41 -05:00
use event instead of js timeout
This commit is contained in:
parent
a4beac7863
commit
04ea8b9ccb
@ -3,12 +3,15 @@
|
||||
namespace App\Livewire\Mod;
|
||||
|
||||
use App\Models\ModeratedModel;
|
||||
use Livewire\Attributes\On;
|
||||
use Livewire\Component;
|
||||
|
||||
class ModerationActionButton extends Component
|
||||
{
|
||||
public ModeratedModel $moderatedObject;
|
||||
|
||||
public string $guid = '';
|
||||
|
||||
public string $actionType;
|
||||
|
||||
public bool $allowActions = false;
|
||||
@ -17,6 +20,11 @@ class ModerationActionButton extends Component
|
||||
|
||||
protected $listeners = ['refreshComponent' => '$refresh'];
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$this->guid = uniqid('', true);
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
$this->allowActions = ! $this->isRunning;
|
||||
@ -27,9 +35,10 @@ class ModerationActionButton extends Component
|
||||
public function runActionEvent(): void
|
||||
{
|
||||
$this->isRunning = true;
|
||||
$this->js('setTimeout(function() { $wire.invokeAction(); }, 500)');
|
||||
$this->dispatch("startAction.{$this->guid}");
|
||||
}
|
||||
|
||||
#[On('startAction.{guid}')]
|
||||
public function invokeAction(): void
|
||||
{
|
||||
switch ($this->actionType) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user