refactor: resolve review comments in PR #81 (issuecomment-542)

This commit is contained in:
2026-06-11 20:06:54 +02:00
parent 039973b974
commit 81aba4b443
12 changed files with 192 additions and 84 deletions
@@ -17,6 +17,7 @@
@code {
private readonly string EditorId = $"milkdown-editor-{Guid.NewGuid():N}";
private readonly CancellationTokenSource _cts = new();
private IJSObjectReference? _module;
private DotNetObjectReference<MarkdownEditor>? _dotNetHelper;
@@ -90,11 +91,11 @@
fileContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(contentType);
content.Add(fileContent, "file", filename);
var response = await Http.PostAsync("/api/media/upload", content);
var response = await Http.PostAsync("/api/media/upload", content, _cts.Token);
if (response.IsSuccessStatusCode)
{
var result = await response.Content.ReadFromJsonAsync<NexusReader.Application.DTOs.Media.UploadResultDto>(
NexusReader.Application.Common.AppJsonContext.Default.UploadResultDto);
NexusReader.Application.Common.AppJsonContext.Default.UploadResultDto, _cts.Token);
return result?.Url ?? string.Empty;
}
else
@@ -113,6 +114,16 @@
public async ValueTask DisposeAsync()
{
try
{
_cts.Cancel();
_cts.Dispose();
}
catch
{
// Fail silently if cancellation token disposal fails
}
try
{
if (_module is not null)