Refactor PandocDialog to simplify state management

This commit is contained in:
Thorsten Sommer 2025-05-30 13:56:02 +02:00
parent 1330519334
commit a6703f108d
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108
2 changed files with 3 additions and 8 deletions

View File

@ -128,7 +128,7 @@
else else
{ {
<MudItem Class="px-8 py-2" Style="height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;"> <MudItem Class="px-8 py-2" Style="height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;">
@if (this.showSkeleton) @if (this.pandocInstallation == default)
{ {
<MudSkeleton SkeletonType="SkeletonType.Circle" Animation="Animation.Pulse" Class="mb-4" Style="width: 4em; height: 4em;"/> <MudSkeleton SkeletonType="SkeletonType.Circle" Animation="Animation.Pulse" Class="mb-4" Style="width: 4em; height: 4em;"/>
<MudSkeleton SkeletonType="SkeletonType.Rectangle" Animation="Animation.Pulse" Width="230px" Height="35px"/> <MudSkeleton SkeletonType="SkeletonType.Rectangle" Animation="Animation.Pulse" Width="230px" Height="35px"/>

View File

@ -33,8 +33,7 @@ public partial class PandocDialog : ComponentBase
private static readonly string LICENCE_URI = "https://raw.githubusercontent.com/jgm/pandoc/refs/heads/main/COPYING.md"; private static readonly string LICENCE_URI = "https://raw.githubusercontent.com/jgm/pandoc/refs/heads/main/COPYING.md";
private static string LATEST_PANDOC_VERSION = string.Empty; private static string LATEST_PANDOC_VERSION = string.Empty;
private bool isPandocAvailable; private PandocInstallation pandocInstallation;
private bool showSkeleton;
private bool showInstallPage; private bool showInstallPage;
private string? licenseText; private string? licenseText;
private bool isLoadingLicence; private bool isLoadingLicence;
@ -49,7 +48,6 @@ public partial class PandocDialog : ComponentBase
{ {
await base.OnInitializedAsync(); await base.OnInitializedAsync();
this.showSkeleton = true;
LATEST_PANDOC_VERSION = await Pandoc.FetchLatestVersionAsync(); LATEST_PANDOC_VERSION = await Pandoc.FetchLatestVersionAsync();
await this.CheckPandocAvailabilityAsync(); await this.CheckPandocAvailabilityAsync();
} }
@ -60,10 +58,7 @@ public partial class PandocDialog : ComponentBase
private async Task CheckPandocAvailabilityAsync() private async Task CheckPandocAvailabilityAsync()
{ {
var pandocInstallation = await Pandoc.CheckAvailabilityAsync(this.RustService); this.pandocInstallation = await Pandoc.CheckAvailabilityAsync(this.RustService);
this.isPandocAvailable = pandocInstallation.IsAvailable;
this.showSkeleton = false;
await this.InvokeAsync(this.StateHasChanged); await this.InvokeAsync(this.StateHasChanged);
} }