Skip to content

Commit

Permalink
Remove now-redundant OrgIdProvider.
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbound committed Jul 16, 2024
1 parent 49e910d commit 8ddde31
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 28 deletions.
6 changes: 2 additions & 4 deletions Desktop.Linux/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public static async Task Main(string[] args)

var services = new ServiceCollection();

services.AddSingleton<IOrganizationIdProvider, OrganizationIdProvider>();
services.AddSingleton<IEmbeddedServerDataProvider, EmbeddedServerDataProvider>();
services.AddRemoteControlLinux();

Expand All @@ -58,17 +57,16 @@ public static async Task Main(string[] args)
var provider = services.BuildServiceProvider();

var appState = provider.GetRequiredService<IAppState>();
var orgIdProvider = provider.GetRequiredService<IOrganizationIdProvider>();

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(
Expand Down
6 changes: 2 additions & 4 deletions Desktop.Shared/Services/AppState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ public interface IAppState
event EventHandler<IViewer> ViewerAdded;

event EventHandler<string> ViewerRemoved;

string AccessKey { get; }
Dictionary<string, string> 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; }
Expand Down Expand Up @@ -81,7 +81,6 @@ public Dictionary<string, string> ArgDict
}
}


public string Host
{
get => _host;
Expand All @@ -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;
Expand Down
9 changes: 3 additions & 6 deletions Desktop.Shared/Services/BrandingProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,15 @@ public class BrandingProvider : IBrandingProvider
private readonly IAppState _appState;
private readonly IEmbeddedServerDataProvider _embeddedDataSearcher;
private readonly ILogger<BrandingProvider> _logger;
private readonly IOrganizationIdProvider _orgIdProvider;
private BrandingInfo? _brandingInfo;


public BrandingProvider(
IAppState appState,
IOrganizationIdProvider orgIdProvider,
IEmbeddedServerDataProvider embeddedServerDataSearcher,
ILogger<BrandingProvider> logger)
{
_appState = appState;
_orgIdProvider = orgIdProvider;
_embeddedDataSearcher = embeddedServerDataSearcher;
_logger = logger;
}
Expand Down Expand Up @@ -82,7 +79,7 @@ private async Task<Result<BrandingInfo>> TryGetBrandingInfo()
{
try
{
if (string.IsNullOrWhiteSpace(_orgIdProvider.OrganizationId) ||
if (string.IsNullOrWhiteSpace(_appState.OrganizationId) ||
string.IsNullOrWhiteSpace(_appState.Host))
{
var filePath = Process.GetCurrentProcess()?.MainModule?.FileName;
Expand All @@ -98,7 +95,7 @@ private async Task<Result<BrandingInfo>> TryGetBrandingInfo()
{
if (!string.IsNullOrWhiteSpace(result.Value.OrganizationId))
{
_orgIdProvider.OrganizationId = result.Value.OrganizationId;
_appState.OrganizationId = result.Value.OrganizationId;
}

if (result.Value.ServerUrl is not null)
Expand All @@ -122,7 +119,7 @@ private async Task<Result<BrandingInfo>> 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<BrandingInfo>(brandingUrl).ConfigureAwait(false);
if (httpResult is null)
{
Expand Down
10 changes: 0 additions & 10 deletions Desktop.Shared/Services/OrganizationIdProvider.cs

This file was deleted.

6 changes: 2 additions & 4 deletions Desktop.Win/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public static async Task Main(string[] args)
}
var services = new ServiceCollection();

services.AddSingleton<IOrganizationIdProvider, OrganizationIdProvider>();
services.AddSingleton<IEmbeddedServerDataProvider>(EmbeddedServerDataProvider.Instance);

services.AddRemoteControlXplat();
Expand All @@ -64,17 +63,16 @@ public static async Task Main(string[] args)
var provider = services.BuildServiceProvider();

var appState = provider.GetRequiredService<IAppState>();
var orgIdProvider = provider.GetRequiredService<IOrganizationIdProvider>();

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(
Expand Down

0 comments on commit 8ddde31

Please sign in to comment.