From 5c5a9fb78c45f80330775286b65b5d78e3e99934 Mon Sep 17 00:00:00 2001 From: Rory& Date: Mon, 31 Mar 2025 09:32:24 +0200 Subject: Cleanup and some error handling --- ModerationClient/Services/ClientContainer.cs | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'ModerationClient/Services') diff --git a/ModerationClient/Services/ClientContainer.cs b/ModerationClient/Services/ClientContainer.cs index 957e3cc..ebdbab6 100644 --- a/ModerationClient/Services/ClientContainer.cs +++ b/ModerationClient/Services/ClientContainer.cs @@ -5,18 +5,10 @@ using Microsoft.Extensions.Logging; namespace ModerationClient.Services; -public class ClientContainer { - private readonly ILogger _logger; - private readonly MatrixAuthenticationService _authService; - private readonly CommandLineConfiguration _cfg; +public class ClientContainer(ILogger logger, MatrixAuthenticationService authService, CommandLineConfiguration cfg) { + private readonly CommandLineConfiguration _cfg = cfg; - public ClientContainer(ILogger logger, MatrixAuthenticationService authService, CommandLineConfiguration cfg) { - _logger = logger; - _authService = authService; - _cfg = cfg; - } - - private bool _isRunning = false; + private bool _isRunning; public void EnsureRunning() { @@ -25,7 +17,7 @@ public class ClientContainer { _ = Task.Run(Run).ContinueWith(t => { if (t.IsFaulted) { - _logger.LogError(t.Exception, "Error in client container task"); + logger.LogError(t.Exception, "Error in client container task"); } return _isRunning = false; }); @@ -34,7 +26,7 @@ public class ClientContainer { private async Task Run() { Console.WriteLine("Running client view model loop..."); - ArgumentNullException.ThrowIfNull(_authService.Homeserver, nameof(_authService.Homeserver)); + ArgumentNullException.ThrowIfNull(authService.Homeserver, nameof(authService.Homeserver)); } } \ No newline at end of file -- cgit 1.5.1