Skip to content

Commit

Permalink
feat: add auto refreshing to activity page
Browse files Browse the repository at this point in the history
  • Loading branch information
Thundernerd committed Jan 1, 2024
1 parent aee1686 commit 56e36e2
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/Mangarr.Frontend/Pages/Activity/Content.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,34 @@
using Mangarr.Shared.Models;
using Mangarr.Shared.Responses;
using Microsoft.AspNetCore.Components;
using Timer = System.Timers.Timer;

namespace Mangarr.Frontend.Pages.Activity;

public partial class Content
public partial class Content : IDisposable
{
private readonly List<ChapterProgressModel> _items = new();

private bool _isRefreshing;

private Timer? _timer;

[Inject] public BackendApi BackendApi { get; set; }

protected override void OnInitialized() => RefreshAsync();
public void Dispose()
{
_timer?.Stop();
_timer?.Dispose();
}

protected override void OnInitialized()
{
_timer = new Timer(2500);
_timer.Elapsed += (_, _) => RefreshAsync();
_timer.Start();

RefreshAsync();
}

private async void RefreshAsync()
{
Expand Down

0 comments on commit 56e36e2

Please sign in to comment.