diff --git a/app/Actions/CoolifyTask/RunRemoteProcess.php b/app/Actions/CoolifyTask/RunRemoteProcess.php index baf5406bd..ef0c9e59b 100644 --- a/app/Actions/CoolifyTask/RunRemoteProcess.php +++ b/app/Actions/CoolifyTask/RunRemoteProcess.php @@ -17,8 +17,6 @@ class RunRemoteProcess public bool $hide_from_output; - public bool $is_finished; - public bool $ignore_errors; public $call_event_on_finish = null; @@ -36,7 +34,7 @@ class RunRemoteProcess /** * Create a new job instance. */ - public function __construct(Activity $activity, bool $hide_from_output = false, bool $is_finished = false, bool $ignore_errors = false, $call_event_on_finish = null) + public function __construct(Activity $activity, bool $hide_from_output = false, bool $ignore_errors = false, $call_event_on_finish = null) { if ($activity->getExtraProperty('type') !== ActivityTypes::INLINE->value) { @@ -45,7 +43,6 @@ class RunRemoteProcess $this->activity = $activity; $this->hide_from_output = $hide_from_output; - $this->is_finished = $is_finished; $this->ignore_errors = $ignore_errors; $this->call_event_on_finish = $call_event_on_finish; } @@ -82,7 +79,7 @@ class RunRemoteProcess if ($this->activity->properties->get('status') === ProcessStatus::ERROR->value) { $status = ProcessStatus::ERROR; } else { - if ($processResult->exitCode() == 0 && $this->is_finished) { + if ($processResult->exitCode() == 0) { $status = ProcessStatus::FINISHED; } if ($processResult->exitCode() != 0 && !$this->ignore_errors) { @@ -110,7 +107,6 @@ class RunRemoteProcess try { event(resolve("App\\Events\\$this->call_event_on_finish", [ 'userId' => $this->activity->causer_id, - 'typeUuid' => $this->activity->getExtraProperty('type_uuid'), ])); } catch (\Throwable $e) { ray($e); diff --git a/app/Events/ServiceStatusChanged.php b/app/Events/ServiceStatusChanged.php index 34df1b711..d5de9f3a7 100644 --- a/app/Events/ServiceStatusChanged.php +++ b/app/Events/ServiceStatusChanged.php @@ -16,6 +16,12 @@ class ServiceStatusChanged implements ShouldBroadcast public $userId; public function __construct($userId = null) { + if (is_null($userId)) { + $userId = auth()->user()->id ?? null; + } + if (is_null($userId)) { + throw new \Exception("User id is null"); + } $this->userId = $userId; } diff --git a/app/Livewire/Project/Service/Navbar.php b/app/Livewire/Project/Service/Navbar.php index 0fe5e6bd9..25cbeb17e 100644 --- a/app/Livewire/Project/Service/Navbar.php +++ b/app/Livewire/Project/Service/Navbar.php @@ -4,6 +4,7 @@ namespace App\Livewire\Project\Service; use App\Actions\Service\StartService; use App\Actions\Service\StopService; +use App\Events\ServiceStatusChanged; use App\Jobs\ContainerStatusJob; use App\Models\Service; use Livewire\Component; @@ -16,7 +17,8 @@ class Navbar extends Component public array $query; public $isDeploymentProgress = false; - public function checkDeployments() { + public function checkDeployments() + { $activity = Activity::where('properties->type_uuid', $this->service->uuid)->latest()->first(); $status = data_get($activity, 'properties.status'); if ($status === 'queued' || $status === 'in_progress') { @@ -64,6 +66,6 @@ class Navbar extends Component } else { $this->dispatch('success', 'Service stopped successfully.'); } - $this->dispatch('checkStatus'); + event(new ServiceStatusChanged(userId: auth()->user()->id)); } }