fix: only set s3DownloadedFile when download actually completes
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 <noreply@anthropic.com>
This commit is contained in:
parent
8e273dd799
commit
91d752f906
3 changed files with 22 additions and 6 deletions
|
|
@ -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,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -151,7 +151,8 @@
|
|||
<div class="text-sm text-warning">Downloading from S3... This may take a few minutes for large
|
||||
backups.</div>
|
||||
@if ($s3DownloadInProgress)
|
||||
<livewire:activity-monitor wire:key="s3-download-{{ $resource->uuid }}" header="S3 Download Progress" :showWaiting="false" />
|
||||
<livewire:activity-monitor wire:key="s3-download-{{ $resource->uuid }}" header="S3 Download Progress"
|
||||
:showWaiting="false" />
|
||||
@endif
|
||||
</div>
|
||||
|
||||
|
|
@ -176,7 +177,8 @@
|
|||
</div>
|
||||
@if ($importRunning)
|
||||
<div class="container w-full mx-auto">
|
||||
<livewire:activity-monitor wire:key="database-restore-{{ $resource->uuid }}" header="Database Restore Output" :showWaiting="false" />
|
||||
<livewire:activity-monitor wire:key="database-restore-{{ $resource->uuid }}" header="Database Restore Output"
|
||||
:showWaiting="false" />
|
||||
</div>
|
||||
@endif
|
||||
@else
|
||||
|
|
|
|||
Loading…
Reference in a new issue