Skip to content

Commit

Permalink
fix: prevent flickering when auto refreshing
Browse files Browse the repository at this point in the history
  • Loading branch information
Thundernerd committed Jan 1, 2024
1 parent 0507a36 commit 7607761
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/Mangarr.Frontend/Pages/Activity/Content.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,25 @@ public void Dispose()
protected override void OnInitialized()
{
_timer = new Timer(2500);
_timer.Elapsed += (_, _) => RefreshAsync();
_timer.Elapsed += (_, _) => RefreshAsync(false);
_timer.Start();

RefreshAsync();
RefreshAsync(true);
}

private async void RefreshAsync()
private async void RefreshAsync(bool updateInitialStateChange)
{
if (_isRefreshing)
{
return;
}

_isRefreshing = true;
await InvokeAsync(StateHasChanged);

if (updateInitialStateChange)
{
await InvokeAsync(StateHasChanged);
}

Result<ChapterProgressResponse> result = await BackendApi.GetChapterProgress();

Expand Down

0 comments on commit 7607761

Please sign in to comment.