Skip to content

Commit

Permalink
Properly switch the transmission type
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack-Edwards committed Sep 10, 2024
1 parent f3dc53a commit f5b6061
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Crypter.Web/Shared/Transfer/UploadFileTransfer.razor
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<i class="bi bi-file-arrow-up d-block fs-1 my-3"></i>
<span class="fw-bold">Choose a file</span> or drag it here to upload
</p>
<InputFile id="fileInput" OnChange="@HandleFileInputChange" @ondragenter="@HandleDragEnter" @ondragleave="@HandleDragLeave"/>
<InputFile id="fileInput" OnChange="@HandleFileInputChangeAsync" @ondragenter="@HandleDragEnter" @ondragleave="@HandleDragLeave"/>
</div>
<div hidden="@(string.IsNullOrEmpty(ErrorMessage))" class="validation-errors my-3">
<div class="alert alert-danger" role="alert">
Expand Down
20 changes: 10 additions & 10 deletions Crypter.Web/Shared/Transfer/UploadFileTransfer.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,22 @@ private void HandleDragLeave()
_dropClass = string.Empty;
}

private void HandleFileInputChange(InputFileChangeEventArgs e)
private async Task HandleFileInputChangeAsync(InputFileChangeEventArgs e)
{
_dropClass = string.Empty;
ErrorMessage = string.Empty;

IBrowserFile file = e.File;

if (await UserSessionService.IsLoggedInAsync())
{
TransmissionType = TransferTransmissionType.Multipart;
}
else if (BrowserFunctions.BrowserSupportsRequestStreaming())
{
TransmissionType = TransferTransmissionType.Stream;
}

// ReSharper disable once SwitchStatementHandlesSomeKnownEnumValuesWithDefault
switch (TransmissionType)
{
Expand All @@ -97,15 +106,6 @@ protected async Task OnEncryptClicked()
ErrorMessage = NoFileSelected;
return;
}

if (await UserSessionService.IsLoggedInAsync())
{
TransmissionType = TransferTransmissionType.Multipart;
}
else if (BrowserFunctions.BrowserSupportsRequestStreaming())
{
TransmissionType = TransferTransmissionType.Stream;
}

EncryptionInProgress = true;
ErrorMessage = string.Empty;
Expand Down

0 comments on commit f5b6061

Please sign in to comment.