diff --git a/src/ImeSense.Launchers.Belarus.Core/Manager/InitializerManager.cs b/src/ImeSense.Launchers.Belarus.Core/Manager/InitializerManager.cs index e50b255..05802d0 100644 --- a/src/ImeSense.Launchers.Belarus.Core/Manager/InitializerManager.cs +++ b/src/ImeSense.Launchers.Belarus.Core/Manager/InitializerManager.cs @@ -28,9 +28,6 @@ public class InitializerManager( private readonly IReleaseComparerService _releaseComparerService = releaseComparerService; private readonly IUpdaterService _updaterService = updaterService; - public bool IsGameReleaseCurrent { get; private set; } = true; - public bool IsUserAuthorized { get; private set; } - public async Task InitializeAsync(ISplashScreenManager splashScreenManager) { try { @@ -62,17 +59,17 @@ public async Task InitializeAsync(ISplashScreenManager splashScreenManager) _launcherStorage.GitHubRelease = await _gitStorageApiService.GetLastReleaseAsync(cancellationToken: splashScreenManager.CancellationToken); _logger.LogInformation("Check last release time: {Time}", stopwatch.ElapsedMilliseconds); - IsGameReleaseCurrent = await IsGameReleaseCurrentAsync(splashScreenManager.CancellationToken); - IsUserAuthorized = File.Exists(PathStorage.LauncherSetting); + _launcherStorage.IsGameReleaseCurrent = await IsGameReleaseCurrentAsync(splashScreenManager.CancellationToken); + _launcherStorage.IsUserAuthorized = File.Exists(PathStorage.LauncherSetting); - if (IsUserAuthorized) { + if (_launcherStorage.IsUserAuthorized) { await Task.Factory.StartNew(() => LoadNewsAsync(locale, splashScreenManager.CancellationToken)); } else { await Task.Factory.StartNew(() => LoadNewsAsync(cancellationToken: splashScreenManager.CancellationToken)); } await Task.Factory.StartNew(() => LoadWebResourcesAsync(cancellationToken: splashScreenManager.CancellationToken)); } else { - if (IsUserAuthorized) { + if (_launcherStorage.IsUserAuthorized) { _launcherStorage.NewsContents = new(LoadErrorNews(locale) ?? []); } else { _launcherStorage.NewsContents = new(LoadErrorNews() ?? []); diff --git a/src/ImeSense.Launchers.Belarus.Core/Storage/ILauncherStorage.cs b/src/ImeSense.Launchers.Belarus.Core/Storage/ILauncherStorage.cs index cae24d2..af44dfa 100644 --- a/src/ImeSense.Launchers.Belarus.Core/Storage/ILauncherStorage.cs +++ b/src/ImeSense.Launchers.Belarus.Core/Storage/ILauncherStorage.cs @@ -10,10 +10,9 @@ public interface ILauncherStorage { GitHubRelease? GitHubRelease { get; set; } IList Locales { get; } - [Reactive] ObservableCollection? NewsContents { get; set; } - [Reactive] ObservableCollection? WebResources { get; set; } - [Reactive] bool IsCheckGitHubConnection { get; set; } + bool IsGameReleaseCurrent { get; set; } + bool IsUserAuthorized { get; set; } } diff --git a/src/ImeSense.Launchers.Belarus.Core/Storage/MemoryLauncherStorage.cs b/src/ImeSense.Launchers.Belarus.Core/Storage/MemoryLauncherStorage.cs index bb1c79e..914f2c2 100644 --- a/src/ImeSense.Launchers.Belarus.Core/Storage/MemoryLauncherStorage.cs +++ b/src/ImeSense.Launchers.Belarus.Core/Storage/MemoryLauncherStorage.cs @@ -21,6 +21,7 @@ public class MemoryLauncherStorage : ReactiveObject, ILauncherStorage public ObservableCollection? NewsContents { get; set; } [Reactive] public ObservableCollection? WebResources { get; set; } - [Reactive] - public bool IsCheckGitHubConnection { get; set; } + [Reactive] public bool IsCheckGitHubConnection { get; set; } + [Reactive] public bool IsGameReleaseCurrent { get; set; } = true; + [Reactive] public bool IsUserAuthorized { get; set; } } diff --git a/src/ImeSense.Launchers.Belarus/ViewModels/MainWindowViewModel.cs b/src/ImeSense.Launchers.Belarus/ViewModels/MainWindowViewModel.cs index 02c5306..6acfe45 100644 --- a/src/ImeSense.Launchers.Belarus/ViewModels/MainWindowViewModel.cs +++ b/src/ImeSense.Launchers.Belarus/ViewModels/MainWindowViewModel.cs @@ -18,8 +18,8 @@ namespace ImeSense.Launchers.Belarus.ViewModels; public class MainWindowViewModel : ReactiveObject { private readonly ILogger? _logger; + private readonly ILauncherStorage _launcherStorage; private readonly IUpdaterService _updaterService; - private readonly InitializerManager _initializerManager; private readonly ViewModelLocator _viewModelLocator; private readonly IApplicationLocaleManager _localeManager; private readonly StartGameViewModel _startGameViewModel; @@ -28,11 +28,11 @@ public class MainWindowViewModel : ReactiveObject [Reactive] public ReactiveObject PageViewModel { get; set; } = null!; - public MainWindowViewModel(ILogger? logger, InitializerManager initializerManager, + public MainWindowViewModel(ILogger? logger, ILauncherStorage launcherStorage, IUpdaterService updaterService, ViewModelLocator viewModelLocator, IApplicationLocaleManager localeManager) { _logger = logger; - _initializerManager = initializerManager; + _launcherStorage = launcherStorage; _updaterService = updaterService; _viewModelLocator = viewModelLocator; _localeManager = localeManager; @@ -47,7 +47,7 @@ public MainWindowViewModel() _startGameViewModel = null!; _launcherViewModel = null!; - _initializerManager = null!; + _launcherStorage = null!; _updaterService = null!; _viewModelLocator = null!; _localeManager = null!; @@ -65,7 +65,7 @@ public async Task InitializeAsync(ISplashScreenManager splashScreenManager) ProcessHelper.KillAllXrEngine(); - var isCurrentRelease = _initializerManager.IsGameReleaseCurrent; + var isCurrentRelease = _launcherStorage.IsGameReleaseCurrent; if (File.Exists(PathStorage.LauncherSetting)) { try { if (!isCurrentRelease) {