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:
Andras Bacsai
2025-11-02 18:27:44 +01:00
parent 8e273dd799
commit 91d752f906
3 changed files with 22 additions and 6 deletions
+10
View File
@@ -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 @@ class S3DownloadFinished implements ShouldBroadcast
// 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 @@ class S3DownloadFinished implements ShouldBroadcast
new PrivateChannel("user.{$this->userId}"),
];
}
public function broadcastWith(): array
{
return [
'downloadPath' => $this->downloadPath,
];
}
}