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