mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
33 lines
856 B
Plaintext
33 lines
856 B
Plaintext
@using Wabbajack.RateLimiter
|
|
@using System
|
|
@using System.Reactive.Linq
|
|
|
|
@namespace Wabbajack.App.Blazor.Components
|
|
|
|
<div id="progress-bar">
|
|
<progress value="@CurrentProgress"></progress>
|
|
<span class="text">@Text</span>
|
|
</div>
|
|
|
|
@code {
|
|
|
|
private double CurrentProgress { get; set; }
|
|
|
|
[Parameter] public IObservable<Percent> ProgressObserver { get; set; }
|
|
|
|
[Parameter] public string? Text { get; set; }
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
var textPercentage = string.IsNullOrEmpty(Text);
|
|
ProgressObserver
|
|
.Sample(TimeSpan.FromMilliseconds(250))
|
|
.DistinctUntilChanged(p => p.Value)
|
|
.Subscribe(p => {
|
|
CurrentProgress = p.Value;
|
|
if (textPercentage) Text = p.ToString();
|
|
InvokeAsync(StateHasChanged);
|
|
});
|
|
}
|
|
}
|