Skip to content

Commit

Permalink
Merge pull request #428 from Sidekick-Poe/feature/show-init-close
Browse files Browse the repository at this point in the history
Show time left for the Initialization view to close
  • Loading branch information
leMicin authored Dec 29, 2024
2 parents d728e29 + a468e89 commit fcfd155
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
else
{
<ButtonPrimary OnClick="CurrentView.Close">
@Resources["Close"]
@Resources["Close"] @($"({TimeLeftToCloseView}s)")
</ButtonPrimary>
}
</div>
Expand Down
16 changes: 14 additions & 2 deletions src/Sidekick.Common.Blazor/Initialization/Initialization.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public partial class Initialization : SidekickView

public override int ViewHeight => 210;

private int TimeLeftToCloseView { get; set; } = 4;

protected override async Task OnInitializedAsync()
{
InitializationTask = Handle();
Expand Down Expand Up @@ -119,8 +121,7 @@ public async Task Handle()
}
else
{
await Task.Delay(4000);
await CurrentView.Close();
await StartCountdownToClose();
}
}
catch (SidekickException e)
Expand All @@ -131,6 +132,17 @@ public async Task Handle()
}
}

private async Task StartCountdownToClose()
{
while (TimeLeftToCloseView > 0)
{
StateHasChanged();
await Task.Delay(1000);
TimeLeftToCloseView--;
}
await CurrentView.Close();
}

private async Task Run(Action action)
{
// Send the command
Expand Down

0 comments on commit fcfd155

Please sign in to comment.