diff --git a/Desktop.Linux/Program.cs b/Desktop.Linux/Program.cs index ee0c02872..7c04131a7 100644 --- a/Desktop.Linux/Program.cs +++ b/Desktop.Linux/Program.cs @@ -42,7 +42,6 @@ public static async Task Main(string[] args) var services = new ServiceCollection(); - services.AddSingleton(); services.AddSingleton(); services.AddRemoteControlLinux(); @@ -58,17 +57,16 @@ public static async Task Main(string[] args) var provider = services.BuildServiceProvider(); var appState = provider.GetRequiredService(); - var orgIdProvider = provider.GetRequiredService(); if (getEmbeddedResult.IsSuccess) { - orgIdProvider.OrganizationId = getEmbeddedResult.Value.OrganizationId; + appState.OrganizationId = getEmbeddedResult.Value.OrganizationId; appState.Host = getEmbeddedResult.Value.ServerUrl.AbsoluteUri; } if (appState.ArgDict.TryGetValue("org-id", out var orgId)) { - orgIdProvider.OrganizationId = orgId; + appState.OrganizationId = orgId; } var result = await provider.UseRemoteControlClient( diff --git a/Desktop.Shared/Services/AppState.cs b/Desktop.Shared/Services/AppState.cs index efa220f89..522b29757 100644 --- a/Desktop.Shared/Services/AppState.cs +++ b/Desktop.Shared/Services/AppState.cs @@ -14,13 +14,13 @@ public interface IAppState event EventHandler ViewerAdded; event EventHandler ViewerRemoved; - string AccessKey { get; } Dictionary ArgDict { get; } string Host { get; set; } bool IsElevate { get; } bool IsRelaunch { get; } AppMode Mode { get; set; } + string OrganizationId { get; set; } string OrganizationName { get; } string PipeName { get; } string[] RelaunchViewers { get; } @@ -81,7 +81,6 @@ public Dictionary ArgDict } } - public string Host { get => _host; @@ -94,9 +93,8 @@ public string Host public bool IsElevate { get; private set; } public bool IsRelaunch { get; private set; } - public AppMode Mode { get; set; } - + public string OrganizationId { get; set; } = string.Empty; public string OrganizationName { get; private set; } = string.Empty; public string PipeName { get; private set; } = string.Empty; diff --git a/Desktop.Shared/Services/BrandingProvider.cs b/Desktop.Shared/Services/BrandingProvider.cs index 305b4c829..1d36a4d24 100644 --- a/Desktop.Shared/Services/BrandingProvider.cs +++ b/Desktop.Shared/Services/BrandingProvider.cs @@ -22,18 +22,15 @@ public class BrandingProvider : IBrandingProvider private readonly IAppState _appState; private readonly IEmbeddedServerDataProvider _embeddedDataSearcher; private readonly ILogger _logger; - private readonly IOrganizationIdProvider _orgIdProvider; private BrandingInfo? _brandingInfo; public BrandingProvider( IAppState appState, - IOrganizationIdProvider orgIdProvider, IEmbeddedServerDataProvider embeddedServerDataSearcher, ILogger logger) { _appState = appState; - _orgIdProvider = orgIdProvider; _embeddedDataSearcher = embeddedServerDataSearcher; _logger = logger; } @@ -82,7 +79,7 @@ private async Task> TryGetBrandingInfo() { try { - if (string.IsNullOrWhiteSpace(_orgIdProvider.OrganizationId) || + if (string.IsNullOrWhiteSpace(_appState.OrganizationId) || string.IsNullOrWhiteSpace(_appState.Host)) { var filePath = Process.GetCurrentProcess()?.MainModule?.FileName; @@ -98,7 +95,7 @@ private async Task> TryGetBrandingInfo() { if (!string.IsNullOrWhiteSpace(result.Value.OrganizationId)) { - _orgIdProvider.OrganizationId = result.Value.OrganizationId; + _appState.OrganizationId = result.Value.OrganizationId; } if (result.Value.ServerUrl is not null) @@ -122,7 +119,7 @@ private async Task> TryGetBrandingInfo() using var httpClient = new HttpClient(); - var brandingUrl = $"{_appState.Host.TrimEnd('/')}/api/branding/{_orgIdProvider.OrganizationId}"; + var brandingUrl = $"{_appState.Host.TrimEnd('/')}/api/branding/{_appState.OrganizationId}"; var httpResult = await httpClient.GetFromJsonAsync(brandingUrl).ConfigureAwait(false); if (httpResult is null) { diff --git a/Desktop.Shared/Services/OrganizationIdProvider.cs b/Desktop.Shared/Services/OrganizationIdProvider.cs deleted file mode 100644 index 408824a11..000000000 --- a/Desktop.Shared/Services/OrganizationIdProvider.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Desktop.Shared.Services; - -public interface IOrganizationIdProvider -{ - string OrganizationId { get; set; } -} -public class OrganizationIdProvider : IOrganizationIdProvider -{ - public string OrganizationId { get; set; } = string.Empty; -} diff --git a/Desktop.Win/Program.cs b/Desktop.Win/Program.cs index 13f48a2e4..952664775 100644 --- a/Desktop.Win/Program.cs +++ b/Desktop.Win/Program.cs @@ -45,7 +45,6 @@ public static async Task Main(string[] args) } var services = new ServiceCollection(); - services.AddSingleton(); services.AddSingleton(EmbeddedServerDataProvider.Instance); services.AddRemoteControlXplat(); @@ -64,17 +63,16 @@ public static async Task Main(string[] args) var provider = services.BuildServiceProvider(); var appState = provider.GetRequiredService(); - var orgIdProvider = provider.GetRequiredService(); if (getEmbeddedResult.IsSuccess) { - orgIdProvider.OrganizationId = getEmbeddedResult.Value.OrganizationId; + appState.OrganizationId = getEmbeddedResult.Value.OrganizationId; appState.Host = getEmbeddedResult.Value.ServerUrl.AbsoluteUri; } if (appState.ArgDict.TryGetValue("org-id", out var orgId)) { - orgIdProvider.OrganizationId = orgId; + appState.OrganizationId = orgId; } var result = await provider.UseRemoteControlClient(