From 91d752f906d3e12755a079cf1f299bc9ffa07a63 Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Sun, 2 Nov 2025 18:27:44 +0100 Subject: [PATCH] fix: only set s3DownloadedFile when download actually completes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The s3DownloadedFile was being set immediately when download started, causing the "Restore" button to appear while still downloading and the download message to not hide properly. - Remove immediate setting of s3DownloadedFile in downloadFromS3() - Set s3DownloadedFile only in handleS3DownloadFinished() event handler - Add broadcastWith() to S3DownloadFinished to send downloadPath - Store downloadPath as public property for broadcasting - Now download message hides and restore button shows only when complete 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- app/Events/S3DownloadFinished.php | 10 ++++++++++ app/Livewire/Project/Database/Import.php | 12 ++++++++---- .../views/livewire/project/database/import.blade.php | 6 ++++-- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/app/Events/S3DownloadFinished.php b/app/Events/S3DownloadFinished.php index ddc2ead30..32744cfa6 100644 --- a/app/Events/S3DownloadFinished.php +++ b/app/Events/S3DownloadFinished.php @@ -15,6 +15,8 @@ class S3DownloadFinished implements ShouldBroadcast public int|string|null $userId = null; + public ?string $downloadPath = null; + public function __construct($teamId, $data = null) { if (is_null($data)) { @@ -23,6 +25,7 @@ public function __construct($teamId, $data = null) // Get userId from event data (the user who triggered the download) $this->userId = data_get($data, 'userId'); + $this->downloadPath = data_get($data, 'downloadPath'); $containerName = data_get($data, 'containerName'); $serverId = data_get($data, 'serverId'); @@ -46,4 +49,11 @@ public function broadcastOn(): ?array new PrivateChannel("user.{$this->userId}"), ]; } + + public function broadcastWith(): array + { + return [ + 'downloadPath' => $this->downloadPath, + ]; + } } diff --git a/app/Livewire/Project/Database/Import.php b/app/Livewire/Project/Database/Import.php index 9cf11c26c..ad018a1eb 100644 --- a/app/Livewire/Project/Database/Import.php +++ b/app/Livewire/Project/Database/Import.php @@ -78,9 +78,16 @@ public function getListeners() ]; } - public function handleS3DownloadFinished(): void + public function handleS3DownloadFinished($data): void { $this->s3DownloadInProgress = false; + + // Set the downloaded file path from the event data + $downloadPath = data_get($data, 'downloadPath'); + if (filled($downloadPath)) { + $this->s3DownloadedFile = $downloadPath; + $this->filename = $downloadPath; + } } public function mount() @@ -408,9 +415,6 @@ public function downloadFromS3() 'resourceUuid' => $this->resource->uuid, ]); - $this->s3DownloadedFile = $downloadPath; - $this->filename = $downloadPath; - $this->dispatch('activityMonitor', $activity->id); $this->dispatch('info', 'Downloading file from S3. This may take a few minutes for large backups...'); } catch (\Throwable $e) { diff --git a/resources/views/livewire/project/database/import.blade.php b/resources/views/livewire/project/database/import.blade.php index 2cbfc6943..b8bed1d44 100644 --- a/resources/views/livewire/project/database/import.blade.php +++ b/resources/views/livewire/project/database/import.blade.php @@ -151,7 +151,8 @@
Downloading from S3... This may take a few minutes for large backups.
@if ($s3DownloadInProgress) - + @endif @@ -176,7 +177,8 @@ @if ($importRunning)
- +
@endif @else