From 23fdad1d9fbab46e17610ad45b915636f0e1c38b Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Sun, 2 Nov 2025 18:16:09 +0100 Subject: [PATCH] fix: broadcast S3DownloadFinished event to hide download message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Make S3DownloadFinished implement ShouldBroadcast - Add listener in Import component to handle S3DownloadFinished event - Set s3DownloadInProgress to false when download completes - This hides "Downloading from S3..." message after download finishes - Follows the same pattern as DatabaseStatusChanged event 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- app/Events/S3DownloadFinished.php | 31 ++++++++++++++++++++++-- app/Livewire/Project/Database/Import.php | 6 +++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/app/Events/S3DownloadFinished.php b/app/Events/S3DownloadFinished.php index 4ca11fdd0..f7ec1bf0e 100644 --- a/app/Events/S3DownloadFinished.php +++ b/app/Events/S3DownloadFinished.php @@ -3,16 +3,32 @@ namespace App\Events; use App\Models\Server; +use App\Models\User; use Illuminate\Broadcasting\InteractsWithSockets; +use Illuminate\Broadcasting\PrivateChannel; +use Illuminate\Contracts\Broadcasting\ShouldBroadcast; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; -class S3DownloadFinished +class S3DownloadFinished implements ShouldBroadcast { use Dispatchable, InteractsWithSockets, SerializesModels; - public function __construct($data) + public int|string|null $userId = null; + + public function __construct($teamId, $data = null) { + // Get the first user from the team to broadcast to + $user = User::whereHas('teams', function ($query) use ($teamId) { + $query->where('teams.id', $teamId); + })->first(); + + $this->userId = $user?->id; + + if (is_null($data)) { + return; + } + $containerName = data_get($data, 'containerName'); $serverId = data_get($data, 'serverId'); @@ -24,4 +40,15 @@ public function __construct($data) instant_remote_process($commands, Server::find($serverId), throwError: false); } } + + public function broadcastOn(): ?array + { + if (is_null($this->userId)) { + return []; + } + + return [ + new PrivateChannel("user.{$this->userId}"), + ]; + } } diff --git a/app/Livewire/Project/Database/Import.php b/app/Livewire/Project/Database/Import.php index fe30b6f67..9b502339f 100644 --- a/app/Livewire/Project/Database/Import.php +++ b/app/Livewire/Project/Database/Import.php @@ -74,9 +74,15 @@ public function getListeners() return [ "echo-private:user.{$userId},DatabaseStatusChanged" => '$refresh', + "echo-private:user.{$userId},S3DownloadFinished" => 'handleS3DownloadFinished', ]; } + public function handleS3DownloadFinished(): void + { + $this->s3DownloadInProgress = false; + } + public function mount() { if (isDev()) {