Allow updating of SDK client's server address. Fix Playnite plugin logins when no extension data exists on first start up.

net8.0
Pat Hartl 2023-11-17 20:47:11 -06:00
parent 6a3c55f669
commit 2a80964fe1
2 changed files with 11 additions and 1 deletions

View File

@ -102,6 +102,8 @@ namespace LANCommander.PlaynitePlugin.Views
if (Plugin.LANCommanderClient == null)
Plugin.LANCommanderClient = new LANCommander.SDK.Client(Context.ServerAddress);
else
Plugin.LANCommanderClient.UseServerAddress(Context.ServerAddress);
var response = await Plugin.LANCommanderClient.AuthenticateAsync(Context.UserName, Context.Password);
@ -122,6 +124,8 @@ namespace LANCommander.PlaynitePlugin.Views
}
catch (Exception ex)
{
Logger.Error(ex, ex.Message);
Plugin.PlayniteApi.Dialogs.ShowErrorMessage(ex.Message);
LoginButton.Dispatcher.Invoke(new System.Action(() =>

View File

@ -17,7 +17,7 @@ namespace LANCommander.SDK
{
private readonly ILogger Logger;
private readonly RestClient ApiClient;
private RestClient ApiClient;
private AuthToken Token;
public string BaseUrl;
@ -231,6 +231,12 @@ namespace LANCommander.SDK
Token = token;
}
public void UseServerAddress(string address)
{
BaseUrl = address;
ApiClient = new RestClient(BaseUrl);
}
public IEnumerable<Game> GetGames()
{
return GetRequest<IEnumerable<Game>>("/api/Games");