From 76077615e5be783fc4bf13eb93bd6a45b7cf0ed3 Mon Sep 17 00:00:00 2001 From: Christiaan Bloemendaal Date: Mon, 1 Jan 2024 16:46:45 +0100 Subject: [PATCH] fix: prevent flickering when auto refreshing --- src/Mangarr.Frontend/Pages/Activity/Content.razor.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Mangarr.Frontend/Pages/Activity/Content.razor.cs b/src/Mangarr.Frontend/Pages/Activity/Content.razor.cs index a0a78b1..553c36c 100644 --- a/src/Mangarr.Frontend/Pages/Activity/Content.razor.cs +++ b/src/Mangarr.Frontend/Pages/Activity/Content.razor.cs @@ -26,13 +26,13 @@ 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) { @@ -40,7 +40,11 @@ private async void RefreshAsync() } _isRefreshing = true; - await InvokeAsync(StateHasChanged); + + if (updateInitialStateChange) + { + await InvokeAsync(StateHasChanged); + } Result result = await BackendApi.GetChapterProgress();