[frontend/components] Allow uploading multiple attachments at a time

This commit is contained in:
pancakes 2025-03-08 23:38:53 +10:00
parent dcc6fd3a19
commit 9f1444740f
No known key found for this signature in database

View file

@ -61,7 +61,7 @@
<Icon Name="Icons.Upload" Size="1.3rem"></Icon>
</button>
<div class="file-input">
<InputFile @ref="UploadInput" OnChange="Upload">Upload!</InputFile>
<InputFile @ref="UploadInput" OnChange="Upload" multiple>Upload!</InputFile>
</div>
<button class="btn" title="@Loc["Poll"]" @onclick="TogglePoll" aria-label="poll">
<Icon Name="Icons.MicrophoneStage" Size="1.3rem"></Icon>
@ -396,7 +396,7 @@
SendButton.State = StateButton.StateEnum.Loading;
if (Attachments.Count > 0)
{
NoteDraft.MediaIds = Attachments.Select(x => x.Id).ToList();
NoteDraft.MediaIds = Attachments.Select(x => x.Id).Distinct().ToList();
}
NoteDraft.RenoteId ??= AttachedQuote;
@ -471,10 +471,15 @@
private async Task Upload(InputFileChangeEventArgs e)
{
UploadingFiles += 1;
var res = await ApiService.Drive.UploadFileAsync(e.File);
Attachments.Add(res);
UploadingFiles -= 1;
UploadingFiles += e.FileCount;
foreach (var file in e.GetMultipleFiles())
{
var res = await ApiService.Drive.UploadFileAsync(file);
Attachments.Add(res);
UploadingFiles -= 1;
}
Attachments = Attachments.DistinctBy(a => a.Id).ToList();
}
private void RemoveAttachment(string id)