diff --git a/Pkmds.Web/Services/AppService.cs b/Pkmds.Web/Services/AppService.cs index 3b46ab89..7f3dc004 100644 --- a/Pkmds.Web/Services/AppService.cs +++ b/Pkmds.Web/Services/AppService.cs @@ -1,7 +1,11 @@ namespace Pkmds.Web.Services; -public record AppService(IAppState AppState, IRefreshService RefreshService) : IAppService +public class AppService(IAppState appState, IRefreshService refreshService) : IAppService { + private IAppState AppState { get; } = appState; + + private IRefreshService RefreshService { get; } = refreshService; + private const string EnglishLang = "en"; private const string DefaultPkmFileName = "pkm.bin"; diff --git a/Pkmds.Web/Services/RefreshService.cs b/Pkmds.Web/Services/RefreshService.cs index 3565152c..a7e22800 100644 --- a/Pkmds.Web/Services/RefreshService.cs +++ b/Pkmds.Web/Services/RefreshService.cs @@ -1,12 +1,21 @@ namespace Pkmds.Web.Services; -public record RefreshService(IAppState AppState) : IRefreshService +public class RefreshService : IRefreshService { + public static RefreshService? Instance { get; private set; } + public event Action? OnAppStateChanged; public event Action? OnBoxStateChanged; public event Action? OnPartyStateChanged; public event Action? OnUpdateAvailable; + public RefreshService() => Instance = this; // Set the singleton instance + + [JSInvokable(nameof(ShowUpdateMessage))] + public static void ShowUpdateMessage() => Instance?.OnUpdateAvailable?.Invoke(); + + void IRefreshService.ShowUpdateMessage() => ShowUpdateMessage(); + public void Refresh() => OnAppStateChanged?.Invoke(); public void RefreshBoxState() => OnBoxStateChanged?.Invoke(); @@ -18,7 +27,4 @@ public void RefreshBoxAndPartyState() RefreshBoxState(); RefreshPartyState(); } - - [JSInvokable("ShowUpdateMessage")] - public void ShowUpdateMessage() => OnUpdateAvailable?.Invoke(); }