[frontend/components] Allow uploading multiple attachments at a time
This commit is contained in:
parent
dcc6fd3a19
commit
9f1444740f
1 changed files with 11 additions and 6 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue