Fix GUI host prompt.

This commit is contained in:
Jared 2021-02-04 05:33:28 -08:00 committed by Jared Goodwin
parent 511ba665cb
commit 91053e21a2
3 changed files with 11 additions and 7 deletions

View File

@ -59,10 +59,14 @@ namespace Remotely.Desktop.Core.Services
{
try
{
if (Connection != null)
if (Connection?.State == HubConnectionState.Connected)
{
await Connection.StopAsync();
await Connection.DisposeAsync();
try
{
await Connection.StopAsync();
await Connection.DisposeAsync();
}
catch { }
}
Connection = new HubConnectionBuilder()
.WithUrl($"{host}/CasterHub")

View File

@ -206,7 +206,7 @@ namespace Remotely.Desktop.Linux.ViewModels
}
prompt.Owner = MainWindow.Current;
await prompt.ShowDialog(MainWindow.Current);
var result = prompt.ViewModel.Host;
var result = prompt.ViewModel.Host?.TrimEnd('/');
if (result is null)
{
@ -219,7 +219,7 @@ namespace Remotely.Desktop.Linux.ViewModels
}
if (result != Host)
{
Host = result.TrimEnd('/');
Host = result;
var config = ConfigService.GetConfig();
config.Host = Host;
ConfigService.Save(config);

View File

@ -251,14 +251,14 @@ namespace Remotely.Desktop.Win.ViewModels
}
prompt.Owner = App.Current?.MainWindow;
prompt.ShowDialog();
var result = prompt.ViewModel.Host;
var result = prompt.ViewModel.Host?.TrimEnd('/');
if (!result.StartsWith("https://") && !result.StartsWith("http://"))
{
result = $"https://{result}";
}
if (result != Host)
{
Host = result.TrimEnd('/');
Host = result;
var config = ConfigService.GetConfig();
config.Host = Host;
ConfigService.Save(config);