public StateViewModel(IRecordDirectoryObserver recordObserver, IEventAggregator eventAggregator, IAppConfiguration appConfiguration, ICaptureService captureService, IOverlayService overlayService, IUpdateCheck updateCheck, IAppVersionProvider appVersionProvider, IWebVersionProvider webVersionProvider, LoginManager loginManager, IRTSSService rTSSService, ILogger <StateViewModel> logger) { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); _recordObserver = recordObserver; _eventAggregator = eventAggregator; _appConfiguration = appConfiguration; _captureService = captureService; _overlayService = overlayService; _updateCheck = updateCheck; _appVersionProvider = appVersionProvider; _logger = logger; IsCaptureModeActive = false; IsOverlayActive = _appConfiguration.IsOverlayActive && rTSSService.IsRTSSInstalled(); _captureService.IsCaptureModeActiveStream .Subscribe(state => IsCaptureModeActive = state); _captureService.IsLoggingActiveStream .Subscribe(state => IsLoggingActive = state); _overlayService.IsOverlayActiveStream .Subscribe(state => IsOverlayActive = state); IsLoggedIn = loginManager.State.Token != null; _eventAggregator.GetEvent <PubSubEvent <AppMessages.LoginState> >().Subscribe(state => { IsLoggedIn = state.IsLoggedIn; RaisePropertyChanged(nameof(IsLoggedIn)); }); Task.Run(async() => { var(updateAvailable, updateVersion) = await _updateCheck.IsUpdateAvailable(); Dispatcher.CurrentDispatcher.Invoke(() => { IsUpdateAvailable = updateAvailable; UpdateHyperlinkText = $"New version available on GitHub: v{updateVersion}"; RaisePropertyChanged(nameof(IsUpdateAvailable)); }); }); stopwatch.Stop(); _logger.LogInformation(this.GetType().Name + " {initializationTime}s initialization time", Math.Round(stopwatch.ElapsedMilliseconds * 1E-03, 1)); }
public StateViewModel(IRecordDirectoryObserver recordObserver, IEventAggregator eventAggregator, IAppConfiguration appConfiguration, ICaptureService captureService, IOverlayService overlayService, IUpdateCheck updateCheck, IAppVersionProvider appVersionProvider, IWebVersionProvider webVersionProvider, LoginManager loginManager, IRTSSService rTSSService) { _recordObserver = recordObserver; _eventAggregator = eventAggregator; _appConfiguration = appConfiguration; _captureService = captureService; _overlayService = overlayService; _updateCheck = updateCheck; _appVersionProvider = appVersionProvider; IsCaptureModeActive = false; IsOverlayActive = _appConfiguration.IsOverlayActive && rTSSService.IsRTSSInstalled(); _captureService.IsCaptureModeActiveStream .Subscribe(state => IsCaptureModeActive = state); _captureService.IsLoggingActiveStream .Subscribe(state => IsLoggingActive = state); _overlayService.IsOverlayActiveStream .Subscribe(state => IsOverlayActive = state); IsLoggedIn = loginManager.State.Token != null; _eventAggregator.GetEvent <PubSubEvent <AppMessages.LoginState> >().Subscribe(state => { IsLoggedIn = state.IsLoggedIn; RaisePropertyChanged(nameof(IsLoggedIn)); }); Task.Run(async() => { var(updateAvailable, updateVersion) = await _updateCheck.IsUpdateAvailable(); Dispatcher.CurrentDispatcher.Invoke(() => { IsUpdateAvailable = updateAvailable; UpdateHyperlinkText = $"New version available on GitHub: v{updateVersion}"; RaisePropertyChanged(nameof(IsUpdateAvailable)); }); }); }